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

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

Issue 12163003: Add FilePath to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROMEOS_SYSTEM_NAME_VALUE_PAIRS_PARSER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_SYSTEM_NAME_VALUE_PAIRS_PARSER_H_
6 #define CHROME_BROWSER_CHROMEOS_SYSTEM_NAME_VALUE_PAIRS_PARSER_H_ 6 #define CHROME_BROWSER_CHROMEOS_SYSTEM_NAME_VALUE_PAIRS_PARSER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 12
13 namespace base {
13 class FilePath; 14 class FilePath;
15 }
14 16
15 namespace chromeos { 17 namespace chromeos {
16 namespace system { 18 namespace system {
17 19
18 // The parser is used to get machine info as name-value pairs. Defined 20 // The parser is used to get machine info as name-value pairs. Defined
19 // here to be accessible by tests. 21 // here to be accessible by tests.
20 class NameValuePairsParser { 22 class NameValuePairsParser {
21 public: 23 public:
22 typedef std::map<std::string, std::string> NameValueMap; 24 typedef std::map<std::string, std::string> NameValueMap;
23 25
24 // The obtained info will be written into the given map. 26 // The obtained info will be written into the given map.
25 explicit NameValuePairsParser(NameValueMap* map); 27 explicit NameValuePairsParser(NameValueMap* map);
26 28
27 void AddNameValuePair(const std::string& key, const std::string& value); 29 void AddNameValuePair(const std::string& key, const std::string& value);
28 30
29 // Executes tool and inserts (key, <output>) into map_. 31 // Executes tool and inserts (key, <output>) into map_.
30 // The program name (argv[0]) should be an absolute path. The function 32 // The program name (argv[0]) should be an absolute path. The function
31 // checks if the program exists before executing it as some programs 33 // checks if the program exists before executing it as some programs
32 // don't exist on Linux desktop; returns false in that case. 34 // don't exist on Linux desktop; returns false in that case.
33 bool GetSingleValueFromTool(int argc, const char* argv[], 35 bool GetSingleValueFromTool(int argc, const char* argv[],
34 const std::string& key); 36 const std::string& key);
35 37
36 // Parses name-value pairs from the file. 38 // Parses name-value pairs from the file.
37 // Returns false if there was any error in the file. Valid pairs will still be 39 // Returns false if there was any error in the file. Valid pairs will still be
38 // added to the map. 40 // added to the map.
39 bool GetNameValuePairsFromFile(const FilePath& file_path, 41 bool GetNameValuePairsFromFile(const base::FilePath& file_path,
40 const std::string& eq, 42 const std::string& eq,
41 const std::string& delim); 43 const std::string& delim);
42 44
43 // These will parse strings with output in the format: 45 // These will parse strings with output in the format:
44 // <key><EQ><value><DELIM>[<key><EQ><value>][...] 46 // <key><EQ><value><DELIM>[<key><EQ><value>][...]
45 // e.g. ParseNameValuePairs("key1=value1 key2=value2", "=", " ") 47 // e.g. ParseNameValuePairs("key1=value1 key2=value2", "=", " ")
46 // Returns false if there was any error in in_string. Valid pairs will still 48 // Returns false if there was any error in in_string. Valid pairs will still
47 // be added to the map. 49 // be added to the map.
48 bool ParseNameValuePairs(const std::string& in_string, 50 bool ParseNameValuePairs(const std::string& in_string,
49 const std::string& eq, 51 const std::string& eq,
(...skipping 21 matching lines...) Expand all
71 private: 73 private:
72 NameValueMap* map_; 74 NameValueMap* map_;
73 75
74 DISALLOW_COPY_AND_ASSIGN(NameValuePairsParser); 76 DISALLOW_COPY_AND_ASSIGN(NameValuePairsParser);
75 }; 77 };
76 78
77 } // namespace system 79 } // namespace system
78 } // namespace chromeos 80 } // namespace chromeos
79 81
80 #endif // CHROME_BROWSER_CHROMEOS_SYSTEM_NAME_VALUE_PAIRS_PARSER_H_ 82 #endif // CHROME_BROWSER_CHROMEOS_SYSTEM_NAME_VALUE_PAIRS_PARSER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/settings/owner_key_util.h ('k') | chrome/browser/component_updater/component_updater_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698