ScummVM API documentation
configuration.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef NUVIE_CONF_CONFIGURATION_H
23 #define NUVIE_CONF_CONFIGURATION_H
24 
25 #include "ultima/shared/std/string.h"
26 #include "ultima/shared/std/containers.h"
27 #include "ultima/detection.h"
28 
29 namespace Ultima {
30 namespace Shared {
31 class XMLTree;
32 } // End of namespace Shared
33 
34 namespace Nuvie {
35 
36 class ConfigNode;
37 
38 #define NUVIE_CONF_READONLY true
39 #define NUVIE_CONF_READWRITE false
40 
62 private:
65  Common::IgnoreCase_EqualTo> _localKeys;
66  Common::HashMap<Common::String, Common::String, Common::IgnoreCase_Hash,
67  Common::IgnoreCase_EqualTo> _settings;
68  Std::string _configFilename;
69  bool _configChanged;
70 
71  // Sets default configurations common to both enhanced and unhenaced
72  void setCommonDefaults(GameId gameType);
73 
74  // sets up unenhanced version defaults
75  void setUnenhancedDefaults(GameId gameType);
76 
77  // sets up enhanced version defaults
78  void setEnhancedDefaults(GameId gameType);
79 public:
80  Configuration();
81  ~Configuration();
82 
83  // read config file. Multiple files may be read. Order is important.
84  bool readConfigFile(const Std::string &fname, const Std::string &root, bool readonly = true);
85 
86  // Loads up the configuration settings
87  void load(GameId gameId, bool isEnhanced);
88 
89  // write all (writable) config files
90  void write();
91 
92  // clear everything
93  void clear();
94 
95  // get value
96  void value(const Std::string &key, Std::string &ret, const char *defaultvalue = "") const;
97  void value(const Std::string &key, int &ret, int defaultvalue = 0) const;
98  void value(const Std::string &key, bool &ret, bool defaultvalue = false) const;
99 
100  void pathFromValue(const Std::string &key, const Std::string &file, Common::Path &full_path) const;
101 
102  // set value
103  bool set(const Std::string &key, const Std::string &value);
104  bool set(const Std::string &key, const char *value);
105  bool set(const Std::string &key, int value);
106  bool set(const Std::string &key, bool value);
107 
108  // get node ref. (delete it afterwards)
109  ConfigNode *getNode(const Std::string &key);
110 
111  // list all subkeys of a key. (no guaranteed order in result)
112  Std::set<Std::string> listKeys(const Std::string &key, bool longformat = false) const;
113 
116 
117  void getSubkeys(KeyTypeList &ktl, const Std::string &basekey);
118 };
119 
120 } // End of namespace Nuvie
121 } // End of namespace Ultima
122 
123 #endif
Definition: containers.h:120
Definition: str.h:59
Definition: configuration.h:61
Definition: array.h:52
Definition: config_node.h:31
Definition: path.h:52
Definition: detection.h:27
Definition: hashmap.h:85
Definition: string.h:30
Definition: containers.h:38
Definition: hash-str.h:49
Definition: hash-str.h:45