ScummVM API documentation
xml_tree.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 SHARED_CONF_XML_TREE_H
23 #define SHARED_CONF_XML_TREE_H
24 
25 #include "common/array.h"
26 #include "common/path.h"
27 #include "common/str.h"
28 #include "common/stream.h"
29 #include "common/util.h"
30 
31 namespace Ultima {
32 namespace Shared {
33 
34 class XMLNode;
35 
36 class XMLTree {
37  friend class XMLNode;
38 private:
39  XMLNode *_tree;
40  Common::Path _filename;
41  bool _isFile;
42  bool _readOnly;
43 public:
44  XMLTree();
45  XMLTree(const Common::Path &fname);
47  ~XMLTree();
48 
49  bool readConfigFile(const Common::Path &fname);
50  bool readConfigStream(Common::SeekableReadStream *stream);
51  bool readConfigString(const Common::String &s);
52 
53  void clear();
54 
55  Common::String dump();
56  void write();
57 
58  void setReadonly() {
59  _readOnly = true;
60  }
61  bool isReadonly() const {
62  return _readOnly;
63  }
64  XMLNode *getTree() const {
65  return _tree;
66  }
67 
68  const XMLNode *getNode(const Common::String &key) const;
69  bool hasNode(const Common::String &key) const;
70  bool checkRoot(const Common::String &key) const;
71 
72  // get value
73  void value(const Common::String &key, Common::String &ret,
74  const char *defaultvalue = "") const;
75  void value(const Common::String &key, int &ret, int defaultvalue = 0) const;
76  void value(const Common::String &key, bool &ret, bool defaultvalue = false) const;
77 
78  // set value
79  void set(const Common::String &key, const Common::String &value);
80  void set(const Common::String &key, const char *value);
81  void set(const Common::String &key, int value);
82  void set(const Common::String &key, bool value);
83 
84  Common::Array<Common::String> listKeys(const Common::String &key, bool longformat = false);
85 
88 
89  void getSubkeys(KeyTypeList &ktl, const Common::String &basekey);
90 };
91 
92 } // End of namespace Shared
93 } // End of namespace Ultima
94 
95 #endif
Definition: str.h:59
Definition: xml_tree.h:36
Definition: path.h:52
Definition: xml_node.h:36
Definition: stream.h:745
Definition: detection.h:27