22 #ifndef __MYGUI_XML_DOCUMENT_H__
23 #define __MYGUI_XML_DOCUMENT_H__
55 return a.value == b.value;
59 return a.value != b.value;
87 return getValueName(value);
91 const char* getValueName(
int _index)
const
93 static const char* values[
MAX + 1] =
95 "Failed to open XML file",
96 "Failed to ceate XML file",
97 "XML file contain incorrect content",
98 "XML file contain not closed elements",
99 "XML file without declaration",
100 "XML file contain closed but not opened element",
101 "XML file contain inconsistent elements",
102 "XML file contain more than one declaration",
103 "XML file contain more than one root element",
104 "XML file contain incorrect attribute",
107 return values[(_index < MAX && _index >= 0) ? _index :
MAX];
133 bool next(
const std::string& _name);
139 #ifndef MYGUI_DONT_USE_OBSOLETE
146 MYGUI_OBSOLETE(
"use : bool ElementEnumerator::next(const std::string& _name)")
147 bool nextNode(const std::
string& _name)
157 #endif // MYGUI_DONT_USE_OBSOLETE
161 VectorElement::iterator m_current, m_end;
177 void save(std::ostream& _stream,
size_t _level);
183 template <
typename T>
184 void addAttribute(
const std::string& _key,
const T& _value)
189 void addAttribute(
const std::string& _key,
const std::string& _value);
191 void removeAttribute(
const std::string& _key);
193 void setAttribute(
const std::string& _key,
const std::string& _value);
195 template <
typename T>
196 void addContent(
const T& _content)
201 void addContent(
const std::string& _content);
203 template <
typename T>
204 void setContent(
const T& _content)
209 void setContent(
const std::string& _content);
213 bool findAttribute(
const std::string& _name, std::string& _value);
214 std::string findAttribute(
const std::string& _name);
216 const std::string& getName()
const;
218 const std::string& getContent()
const;
231 #ifndef MYGUI_DONT_USE_OBSOLETE
233 template <
typename T>
234 MYGUI_OBSOLETE(
"use : template <typename T> void Element::addAttribute(const std::string &_key, const T& _value)")
235 void addAttributes(const std::
string& _key, const T& _value)
237 addAttribute<T>(_key, _value);
239 MYGUI_OBSOLETE(
"use : void Element::addAttribute(const std::string& _key, const std::string& _value)")
240 void addAttributes(const std::
string& _key, const std::
string& _value)
242 addAttribute(_key, _value);
245 template <
typename T>
246 MYGUI_OBSOLETE(
"use : template <typename T> void Element::addContent(const T& _content)")
247 void addBody(const T& _content)
249 addContent<T>(_content);
251 MYGUI_OBSOLETE(
"use : void Element::addContent(const std::string& _content)")
252 void addBody(const std::
string& _content)
254 addContent(_content);
256 template <
typename T>
257 MYGUI_OBSOLETE(
"use : template <typename T> void Element::setContent(const T& _content)")
258 void setBody(const T& _content)
260 setContent<T>(_content);
262 MYGUI_OBSOLETE(
"use : void Element::setContent(const std::string& _content)")
263 void setBody(const std::
string& _content)
265 setContent(_content);
269 const std::
string& getBody()
const
273 MYGUI_OBSOLETE(
"use : ElementEnumerator Element::getElementEnumerator()")
276 return getElementEnumerator();
279 #endif // MYGUI_DONT_USE_OBSOLETE
283 std::string mContent;
300 bool open(
const std::string& _filename);
303 bool open(
const std::wstring& _filename);
306 bool open(std::istream& _stream);
308 bool open(
const UString& _filename);
313 bool save(
const std::string& _filename);
316 bool save(
const std::wstring& _filename);
318 bool save(std::ostream& _stream);
320 bool save(
const UString& _filename);
324 std::string getLastError();
326 void clearLastError();
328 ElementPtr createDeclaration(
const std::string& _version =
"1.0",
const std::string& _encoding =
"UTF-8");
329 ElementPtr createRoot(
const std::string& _name);
334 #ifndef MYGUI_DONT_USE_OBSOLETE
336 MYGUI_OBSOLETE(
"use : ElementPtr Document::createDeclaration(const std::string& _version, const std::string& _encoding)")
337 ElementPtr createInfo(const std::
string& _version = "1.0", const std::
string& _encoding = "UTF-8")
339 return createDeclaration(_version, _encoding);
342 #endif // MYGUI_DONT_USE_OBSOLETE
345 void setLastFileError(
const std::string& _filename);
346 void setLastFileError(
const std::wstring& _filename);
348 bool parseTag(
ElementPtr& _currentNode, std::string _content);
350 bool checkPair(std::string& _key, std::string& _value);
352 bool parseLine(std::string& _line,
ElementPtr& _element);
355 size_t find(
const std::string& _text,
char _char,
size_t _start = 0);
357 void clearDeclaration();
364 std::string mLastErrorFile;
381 #endif // __MYGUI_XML_DOCUMENT_H__