diff options
author | dpolukhin@chromium.org <dpolukhin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-26 05:06:44 +0000 |
---|---|---|
committer | dpolukhin@chromium.org <dpolukhin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-26 05:06:44 +0000 |
commit | 57391d0577690634db7c973f2df0ae60c8e5721d (patch) | |
tree | 47df4b5eeeb554652f253a31bb2d5cc37948ddeb /chrome/browser/chromeos/name_value_pairs_parser.h | |
parent | dee9ae9dcf06e90c04c8ccbf9876b76cfebabb63 (diff) | |
download | chromium_src-57391d0577690634db7c973f2df0ae60c8e5721d.zip chromium_src-57391d0577690634db7c973f2df0ae60c8e5721d.tar.gz chromium_src-57391d0577690634db7c973f2df0ae60c8e5721d.tar.bz2 |
HWID and VPD values should be accessible via SystemAccess::GetMachineStatistic
BUG=chromium-os:13019
TEST=NameValuePairsParser.* StartupCustomizationDocumentTest.*
Review URL: http://codereview.chromium.org/6899021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82987 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/name_value_pairs_parser.h')
-rw-r--r-- | chrome/browser/chromeos/name_value_pairs_parser.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/chrome/browser/chromeos/name_value_pairs_parser.h b/chrome/browser/chromeos/name_value_pairs_parser.h new file mode 100644 index 0000000..ae8823b --- /dev/null +++ b/chrome/browser/chromeos/name_value_pairs_parser.h @@ -0,0 +1,52 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_CHROMEOS_NAME_VALUE_PAIRS_PARSER_H_ +#define CHROME_BROWSER_CHROMEOS_NAME_VALUE_PAIRS_PARSER_H_ +#pragma once + +#include <map> +#include <string> +#include <vector> + +#include "base/basictypes.h" + +namespace chromeos { + +// The parser is used to get machine info as name-value pairs. Defined +// here to be accessable by tests. +class NameValuePairsParser { + public: + typedef std::map<std::string, std::string> NameValueMap; + + // The obtained info will be written into machine_info. + explicit NameValuePairsParser(NameValueMap* map); + + void AddNameValuePair(const std::string& key, const std::string& value); + + // Executes tool and inserts (key, <output>) into map_. + bool GetSingleValueFromTool(int argc, const char* argv[], + const std::string& key); + // Executes tool, parses the output using ParseNameValuePairs, + // and inserts the results into name_value_pairs_. + bool ParseNameValuePairsFromTool(int argc, const char* argv[], + const std::string& eq, + const std::string& delim); + + private: + // This will parse strings with output in the format: + // <key><EQ><value><DELIM>[<key><EQ><value>][...] + // e.g. ParseNameValuePairs("key1=value1 key2=value2", "=", " ") + bool ParseNameValuePairs(const std::string& in_string, + const std::string& eq, + const std::string& delim); + + NameValueMap* map_; + + DISALLOW_COPY_AND_ASSIGN(NameValuePairsParser); +}; + +} // namespace chromeos + +#endif // CHROME_BROWSER_CHROMEOS_NAME_VALUE_PAIRS_PARSER_H_ |