1 | // Aseprite Config Library |
2 | // Copyright (C) 2019 Igara Studio S.A. |
3 | // Copyright (C) 2014-2016 David Capello |
4 | // |
5 | // This file is released under the terms of the MIT license. |
6 | // Read LICENSE.txt for more information. |
7 | |
8 | #ifndef CFG_CFG_H_INCLUDED |
9 | #define CFG_CFG_H_INCLUDED |
10 | #pragma once |
11 | |
12 | #include <string> |
13 | #include <vector> |
14 | |
15 | namespace cfg { |
16 | |
17 | class CfgFile { |
18 | public: |
19 | CfgFile(); |
20 | ~CfgFile(); |
21 | |
22 | const std::string& filename() const; |
23 | |
24 | void getAllSections(std::vector<std::string>& sections) const; |
25 | void getAllKeys(const char* section, std::vector<std::string>& keys) const; |
26 | |
27 | const char* getValue(const char* section, const char* name, const char* defaultValue) const; |
28 | bool getBoolValue(const char* section, const char* name, bool defaultValue); |
29 | int getIntValue(const char* section, const char* name, int defaultValue); |
30 | double getDoubleValue(const char* section, const char* name, double defaultValue); |
31 | |
32 | void setValue(const char* section, const char* name, const char* value); |
33 | void setBoolValue(const char* section, const char* name, bool value); |
34 | void setIntValue(const char* section, const char* name, int value); |
35 | void setDoubleValue(const char* section, const char* name, double value); |
36 | |
37 | void deleteValue(const char* section, const char* name); |
38 | void deleteSection(const char* section); |
39 | |
40 | void load(const std::string& filename); |
41 | void save(); |
42 | |
43 | private: |
44 | class CfgFileImpl; |
45 | CfgFileImpl* m_impl; |
46 | }; |
47 | |
48 | } // namespace cfg |
49 | |
50 | #endif |
51 | |