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

Unified Diff: chrome/browser/chromeos/system/name_value_pairs_parser.h

Issue 10127009: Make NameValuePairsParser support values that contain the 'equal' separator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/system/name_value_pairs_parser.h
diff --git a/chrome/browser/chromeos/system/name_value_pairs_parser.h b/chrome/browser/chromeos/system/name_value_pairs_parser.h
index bcf4f4380157af723f62953cac838002866f9000..b80db71fcf46b512dafc1f9cce79e3f05cc0dfe2 100644
--- a/chrome/browser/chromeos/system/name_value_pairs_parser.h
+++ b/chrome/browser/chromeos/system/name_value_pairs_parser.h
@@ -17,43 +17,51 @@ namespace chromeos {
namespace system {
// The parser is used to get machine info as name-value pairs. Defined
-// here to be accessable by tests.
+// here to be accessible by tests.
class NameValuePairsParser {
public:
typedef std::map<std::string, std::string> NameValueMap;
- // The obtained info will be written into machine_info.
+ // The obtained info will be written into |map|.
explicit NameValuePairsParser(NameValueMap* map);
void AddNameValuePair(const std::string& key, const std::string& value);
- // Executes tool and inserts (key, <output>) into map_.
- // The program name (argv[0]) should be an absolute path. The function
+ // Executes tool and inserts (key, <output>) into |map_|.
+ // The program name |argv[0]| should be an absolute path. The function
Mattias Nissler (ping if slow) 2012/04/19 13:51:39 There's been a recent discussion on whether or not
Joao da Silva 2012/04/19 16:01:30 I was under the impression that was the preferred
// checks if the program exists before executing it as some programs
- // don't exist on Linux desktop.
+ // don't exist on Linux desktop; returns false in that case.
bool GetSingleValueFromTool(int argc, const char* argv[],
const std::string& key);
// Parses name-value pairs from the file.
- void GetNameValuePairsFromFile(const FilePath& file_path,
+ // Returns false if there was any error in the file. Valid pairs will still be
+ // added to the map.
+ bool GetNameValuePairsFromFile(const FilePath& file_path,
const std::string& eq,
const std::string& delim);
// These will parse strings with output in the format:
// <key><EQ><value><DELIM>[<key><EQ><value>][...]
// e.g. ParseNameValuePairs("key1=value1 key2=value2", "=", " ")
+ // Returns false if there was any error in |in_string|. Valid pairs will still
+ // be added to the map.
bool ParseNameValuePairs(const std::string& in_string,
const std::string& eq,
const std::string& delim);
// This version allows for values which end with a comment
- // beginning with comment_delim.
- // e.g."key2=value2 # Explanation of value\n"
+ // beginning with |comment_delim|.
+ // e.g. "key2=value2 # Explanation of value\n"
+ // Returns false if there was any error in |in_string|. Valid pairs will still
+ // be added to the map.
bool ParseNameValuePairsWithComments(const std::string& in_string,
const std::string& eq,
const std::string& delim,
const std::string& comment_delim);
+ // Same as ParseNameValuePairsWithComments(), but uses the output of the given
+ // tool as the input to parse.
bool ParseNameValuePairsFromTool(
int argc,
const char* argv[],

Powered by Google App Engine
This is Rietveld 408576698