Index: base/ini_parser.h |
diff --git a/base/ini_parser.h b/base/ini_parser.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ea5d2aaf36b97b0dc68bac823f95fde8c6340999 |
--- /dev/null |
+++ b/base/ini_parser.h |
@@ -0,0 +1,47 @@ |
+// Copyright 2013 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 BASE_INI_PARSER_H_ |
+#define BASE_INI_PARSER_H_ |
+ |
+#include <string> |
+ |
+#include "base/base_export.h" |
+#include "base/values.h" |
+ |
+namespace base { |
+ |
+// A simple class to parse INI files in a string. Users should inherit from this |
Mark Mentovai
2013/06/17 18:52:37
Is there a textual reference to the ini format som
tommycli
2013/06/17 19:49:24
Done.
erikwright (departed)
2013/06/17 20:30:47
Use the descriptive in the opening sentence.
// P
tommycli
2013/06/17 21:23:25
Done.
|
+// class and override the HandlePair method. |
+class BASE_EXPORT INIParser { |
+ public: |
+ INIParser(); |
+ virtual ~INIParser(); |
+ |
+ void Parse(const std::string& content); |
erikwright (departed)
2013/06/17 20:30:47
Is it correct to call this method more than once?
tommycli
2013/06/17 21:23:25
Yes, it's correct to call multiple times. I added
erikwright (departed)
2013/06/18 00:56:14
The benefit is that it's a stateless class. It doe
tommycli
2013/06/18 16:29:47
Well in some cases, such as the DictionaryValue bu
|
+ private: |
Mark Mentovai
2013/06/17 18:52:37
Blank line before this one to break up the section
tommycli
2013/06/17 19:49:24
Done.
erikwright (departed)
2013/06/17 20:30:47
NL before private: here and below.
tommycli
2013/06/17 21:23:25
Done.
|
+ virtual void HandlePair(const std::string& section, const std::string& key, |
Mark Mentovai
2013/06/17 18:52:37
This method is misnamed. It’s not really handling
tommycli
2013/06/17 19:49:24
Done.
erikwright (departed)
2013/06/17 20:30:47
nit, styleguide would have each on its own line if
tommycli
2013/06/17 21:23:25
Done.
|
+ const std::string& value) = 0; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(INIParser); |
Mark Mentovai
2013/06/17 18:52:37
Include What You Use: #include "base/basictypes.h"
tommycli
2013/06/17 19:49:24
Done.
erikwright (departed)
2013/06/17 20:30:47
Not required for this abstract class.
tommycli
2013/06/17 21:23:25
Done.
|
+}; |
+ |
+class BASE_EXPORT DictionaryValueINIParser : public INIParser { |
erikwright (departed)
2013/06/17 20:30:47
Add a class comment. It should, at a minimum, expl
erikwright (departed)
2013/06/17 20:30:47
Will your new client of this code use INIParser di
tommycli
2013/06/17 21:23:25
Done.
tommycli
2013/06/17 21:23:25
Will use INIParser directly.
|
+ public: |
+ DictionaryValueINIParser(); |
+ virtual ~DictionaryValueINIParser(); |
+ |
+ const DictionaryValue& root() const { return root_; } |
+ private: |
+ virtual void HandlePair(const std::string& section, const std::string& key, |
erikwright (departed)
2013/06/17 20:30:47
Add a comment:
// INIParser implementation.
tommycli
2013/06/17 21:23:25
Done.
|
+ const std::string& value) OVERRIDE; |
+ |
+ DictionaryValue root_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(DictionaryValueINIParser); |
+}; |
+ |
+} // namespace base |
+ |
+#endif // BASE_INI_PARSER_H_ |