Change the app list folder management back button to a smaller size one(24x24).
[chromium-blink-merge.git] / base / ini_parser.h
blob0aa7754d34d8020fa2ae57ce3b92ca97df9dc6b9
1 // Copyright 2013 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.
5 #ifndef BASE_INI_PARSER_H_
6 #define BASE_INI_PARSER_H_
8 #include <string>
10 #include "base/base_export.h"
11 #include "base/basictypes.h"
12 #include "base/values.h"
14 namespace base {
16 // Parses INI files in a string. Users should in inherit from this class.
17 // This is a very basic INI parser with these characteristics:
18 // - Ignores blank lines.
19 // - Ignores comment lines beginning with '#' or ';'.
20 // - Duplicate key names in the same section will simply cause repeated calls
21 // to HandleTriplet with the same |section| and |key| parameters.
22 // - No escape characters supported.
23 // - Global properties result in calls to HandleTriplet with an empty string in
24 // the |section| argument.
25 // - Section headers begin with a '[' character. It is recommended, but
26 // not required to close the header bracket with a ']' character. All
27 // characters after a closing ']' character is ignored.
28 // - Key value pairs are indicated with an '=' character. Whitespace is not
29 // ignored. Quoting is not supported. Everything before the first '='
30 // is considered the |key|, and everything after is the |value|.
31 class BASE_EXPORT INIParser {
32 public:
33 INIParser();
34 virtual ~INIParser();
36 // May only be called once per instance.
37 void Parse(const std::string& content);
39 private:
40 virtual void HandleTriplet(const std::string& section,
41 const std::string& key,
42 const std::string& value) = 0;
44 bool used_;
47 // Parsed values are stored as strings at the "section.key" path. Triplets with
48 // |section| or |key| parameters containing '.' are ignored.
49 class BASE_EXPORT DictionaryValueINIParser : public INIParser {
50 public:
51 DictionaryValueINIParser();
52 virtual ~DictionaryValueINIParser();
54 const DictionaryValue& root() const { return root_; }
56 private:
57 // INIParser implementation.
58 virtual void HandleTriplet(const std::string& section,
59 const std::string& key,
60 const std::string& value) OVERRIDE;
62 DictionaryValue root_;
64 DISALLOW_COPY_AND_ASSIGN(DictionaryValueINIParser);
67 } // namespace base
69 #endif // BASE_INI_PARSER_H_