ScummVM API documentation
config_node.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_CONFIG_NODE_H
23 #define NUVIE_CONF_CONFIG_NODE_H
24 
25 #include "ultima/shared/std/string.h"
26 #include "ultima/nuvie/conf/configuration.h"
27 
28 namespace Ultima {
29 namespace Nuvie {
30 
31 class ConfigNode {
32  friend class Configuration;
33  ConfigNode(Configuration &config_, Std::string key_)
34  : config(config_), key(key_) {
35  }
36 
37 public:
38  ~ConfigNode() { }
39 
40  // fix "assignment operator could not be generated" warning
41  const ConfigNode &operator = (const ConfigNode &other) {
42  config = other.config;
43  key = other.key;
44  return *this;
45  }
46 
47  Std::string get_string(const char *defaultvalue = "") {
48  Std::string s;
49  config.value(key, s, defaultvalue);
50  return s;
51  }
52  int get_int(int defaultvalue = 0) {
53  int i;
54  config.value(key, i, defaultvalue);
55  return i;
56  }
57  bool get_bool(bool defaultvalue = false) {
58  bool b;
59  config.value(key, b, defaultvalue);
60  return b;
61  }
62 
63  void set(const Std::string &value) {
64  config.set(key, value);
65  }
66  void set(const char *value) {
67  config.set(key, value);
68  }
69  void set(int value) {
70  config.set(key, value);
71  }
72  void set(bool value) {
73  config.set(key, value);
74  }
75 
76 private:
77  Configuration &config;
78  Std::string key;
79 
80 };
81 
82 } // End of namespace Nuvie
83 } // End of namespace Ultima
84 
85 #endif
Definition: configuration.h:61
Definition: config_node.h:31
Definition: detection.h:27
Definition: string.h:30