Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: chrome/browser/chromeos/name_value_pairs_parser.h

Issue 6899021: HWID and VPD values should be accessible via SystemAccess::GetMachineStatistic (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move ChromeosInfo to UI thread only Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_NAME_VALUE_PAIRS_PARSER_H_
6 #define CHROME_BROWSER_CHROMEOS_NAME_VALUE_PAIRS_PARSER_H_
7 #pragma once
8
9 #include <map>
10 #include <string>
11 #include <vector>
12
13 #include "base/basictypes.h"
14
15 namespace chromeos {
16
17 // Machine information is represented as a key-value map.
18 typedef std::map<std::string, std::string> MachineInfo;
stevenjb 2011/04/25 17:07:33 Now that we are abstracting this, we should rename
Dmitry Polukhin 2011/04/25 18:50:00 Done.
19
20 // The parser is used to get machine info as name-value pairs. Defined
21 // here to be accessable by tests.
22 class NameValuePairsParser {
23 public:
24 typedef std::vector<std::pair<std::string, std::string> > NameValuePairs;
25
26 // The obtained machine info will be written into machine_info.
27 explicit NameValuePairsParser(MachineInfo* machine_info);
28
29 void AddNameValuePair(const std::string& key, const std::string& value);
30
31 // Executes tool and inserts (key, <output>) into name_value_pairs_.
32 bool GetSingleValueFromTool(int argc, const char* argv[],
33 const std::string& key);
34 // Executes tool, parses the output using ParseNameValuePairs,
35 // and inserts the results into name_value_pairs_.
36 bool ParseNameValuePairsFromTool(int argc, const char* argv[],
37 const std::string& eq,
38 const std::string& delim);
39
40 private:
41 // This will parse strings with output in the format:
42 // <key><EQ><value><DELIM>[<key><EQ><value>][...]
43 // e.g. ParseNameValuePairs("key1=value1 key2=value2", "=", " ")
44 bool ParseNameValuePairs(const std::string& in_string,
45 const std::string& eq,
46 const std::string& delim);
47
48 MachineInfo* machine_info_;
49
50 DISALLOW_COPY_AND_ASSIGN(NameValuePairsParser);
51 };
52
53 } // namespace chromeos
54
55 #endif // CHROME_BROWSER_CHROMEOS_NAME_VALUE_PAIRS_PARSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698