]> git.vomp.tv Git - vompclient.git/blob - config.h
Rewrite of ImageOMX to fix the PNG problem
[vompclient.git] / config.h
1 /*
2     Copyright 2021 Chris Tallon
3
4     This file is part of VOMP.
5
6     VOMP is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
18 */
19
20 #ifndef CONFIG_H
21 #define CONFIG_H
22
23 #include <functional>
24
25 #include <jsoncpp/json/json.h>
26
27 class Config
28 {
29   public:
30     Config();
31     ~Config();
32     static Config* getInstance();
33
34     bool loadFile();
35
36     bool getString(const std::string& section, const std::string& key, std::string& out) const;
37     bool getInt(const std::string& section, const std::string& key, int& out) const;
38     bool getBool(const std::string& section, const std::string& key, bool& out) const;
39     void dump() const;
40     bool foreachInArray(const std::string& section, const std::string& key, std::function<void(const std::string&)> callback) const;
41     bool foreachPairInObject(const std::string& section, const std::string& key, std::function<void(const std::string&, const std::string&)> callback) const;
42
43     void set(const std::string& section, const std::string& key, const std::string& value);
44     void set(const std::string& section, const std::string& key, bool value);
45     void set(const std::string& section, const std::string& key, const char* value);
46     void set(const std::string& section, const std::string& key, int value);
47
48   private:
49     static Config* instance;
50
51     void applyDefaults();
52
53     Json::Value jconfig;
54     const Json::Value& jconfigro;
55
56 };
57
58 #endif