My Project
IniParser.h
1 /*
2  * Copyright (C) 2013 Canonical Ltd
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License version 3 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Jussi Pakkanen <jussi.pakkanen@canonical.com>
17  */
18 
19 #ifndef UNITY_UTIL_INIPARSER_H
20 #define UNITY_UTIL_INIPARSER_H
21 
22 #include <unity/SymbolExport.h>
23 #include <unity/util/DefinesPtrs.h>
24 
25 #include<string>
26 #include<vector>
27 
28 namespace unity
29 {
30 
31 namespace util
32 {
33 
34 namespace internal
35 {
36 struct IniParserPrivate;
37 }
38 
68 class UNITY_API IniParser final {
69 public:
71  IniParser(const char* filename);
72  ~IniParser() noexcept;
73 
76 
77  IniParser(const IniParser& ip) = delete;
78  IniParser() = delete;
80 
86  //{@
87  bool has_group(const std::string& group) const noexcept;
88  bool has_key(const std::string& group, const std::string& key) const;
89  std::string get_string(const std::string& group, const std::string& key) const;
90  std::string get_locale_string(const std::string& group,
91  const std::string& key,
92  const std::string& locale = std::string()) const;
93  bool get_boolean(const std::string& group, const std::string& key) const;
94  int get_int(const std::string& group, const std::string& key) const;
95 
96  std::vector<std::string> get_string_array(const std::string& group, const std::string& key) const;
97  std::vector<std::string> get_locale_string_array(const std::string& group,
98  const std::string& key,
99  const std::string& locale = std::string()) const;
100  std::vector<int> get_int_array(const std::string& group, const std::string& key) const;
101  std::vector<bool> get_boolean_array(const std::string& group, const std::string& key) const;
102 
103  std::string get_start_group() const;
104  std::vector<std::string> get_groups() const;
105  std::vector<std::string> get_keys(const std::string& group) const;
107 
108 private:
109  internal::IniParserPrivate* p;
110 };
111 
112 
113 } // namespace util
114 
115 } // namespace unity
116 
117 #endif
Top-level namespace for all things Unity-related.
Definition: Version.h:37
Helper class to read configuration files.
Definition: IniParser.h:68
#define UNITY_DEFINES_PTRS(classname)
Macro to add smart pointer definitions to a class.
Definition: DefinesPtrs.h:52