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 "common/str.h"
26 #include "ultima/detection.h"
27 
28 namespace Ultima {
29 namespace Shared {
30 class XMLTree;
31 } // End of namespace Shared
32 
33 namespace Nuvie {
34 
35 class ConfigNode;
36 
37 #define NUVIE_CONF_READONLY true
38 #define NUVIE_CONF_READWRITE false
39 
61 private:
64  Common::IgnoreCase_EqualTo> _localKeys;
65  Common::HashMap<Common::String, Common::String, Common::IgnoreCase_Hash,
66  Common::IgnoreCase_EqualTo> _settings;
67  Common::String _configFilename;
68  bool _configChanged;
69 
70  // Sets default configurations common to both enhanced and unhenaced
71  void setCommonDefaults(GameId gameType);
72 
73  // sets up unenhanced version defaults
74  void setUnenhancedDefaults(GameId gameType);
75 
76  // sets up enhanced version defaults
77  void setEnhancedDefaults(GameId gameType);
78 public:
79  Configuration();
80  ~Configuration();
81 
82  // read config file. Multiple files may be read. Order is important.
83  bool readConfigFile(const Common::String &fname, const Common::String &root, bool readonly = true);
84 
85  // Loads up the configuration settings
86  void load(GameId gameId, bool isEnhanced);
87 
88  // write all (writable) config files
89  void write();
90 
91  // clear everything
92  void clear();
93 
94  // get value
95  void value(const Common::String &key, Common::String &ret, const char *defaultvalue = "") const;
96  void value(const Common::String &key, int &ret, int defaultvalue = 0) const;
97  void value(const Common::String &key, bool &ret, bool defaultvalue = false) const;
98 
99  void pathFromValue(const Common::String &key, const Common::String &file, Common::Path &full_path) const;
100 
101  // set value
102  bool set(const Common::String &key, const Common::String &value);
103  bool set(const Common::String &key, const char *value);
104  bool set(const Common::String &key, int value);
105  bool set(const Common::String &key, bool value);
106 
107  // get node ref. (delete it afterwards)
108  ConfigNode *getNode(const Common::String &key);
109 
112 
113  void getSubkeys(KeyTypeList &ktl, const Common::String &basekey);
114 };
115 
116 } // End of namespace Nuvie
117 } // End of namespace Ultima
118 
119 #endif
Definition: str.h:59
Definition: configuration.h:60
Definition: array.h:52
Definition: config_node.h:31
Definition: path.h:52
Definition: detection.h:27
Definition: hashmap.h:85
Definition: hash-str.h:49
Definition: hash-str.h:45