7 #ifndef __MYGUI_XML_DOCUMENT_H__
8 #define __MYGUI_XML_DOCUMENT_H__
40 return a.mValue == b.mValue;
44 return a.mValue != b.mValue;
77 return getValueName(mValue);
81 const char* getValueName(
int _index)
const
83 static const char* values[
MAX + 1] =
85 "Failed to open XML file",
86 "Failed to ceate XML file",
87 "XML file contain incorrect content",
88 "XML file contain not closed elements",
89 "XML file without declaration",
90 "XML file contain closed but not opened element",
91 "XML file contain inconsistent elements",
92 "XML file contain more than one declaration",
93 "XML file contain more than one root element",
94 "XML file contain incorrect attribute",
97 return values[(_index < MAX && _index >= 0) ? _index :
MAX];
123 bool next(
const std::string& _name);
129 #ifndef MYGUI_DONT_USE_OBSOLETE
136 MYGUI_OBSOLETE(
"use : bool ElementEnumerator::next(const std::string& _name)")
137 bool nextNode(const std::
string& _name)
147 #endif // MYGUI_DONT_USE_OBSOLETE
151 VectorElement::iterator m_current, m_end;
167 void save(std::ostream& _stream,
size_t _level);
173 template <
typename T>
174 void addAttribute(
const std::string& _key,
const T& _value)
179 void addAttribute(
const std::string& _key,
const std::string& _value);
181 void removeAttribute(
const std::string& _key);
183 void setAttribute(
const std::string& _key,
const std::string& _value);
185 template <
typename T>
186 void addContent(
const T& _content)
191 void addContent(
const std::string& _content);
193 template <
typename T>
194 void setContent(
const T& _content)
199 void setContent(
const std::string& _content);
203 bool findAttribute(
const std::string& _name, std::string& _value);
204 std::string findAttribute(
const std::string& _name);
206 const std::string& getName()
const;
208 const std::string& getContent()
const;
221 #ifndef MYGUI_DONT_USE_OBSOLETE
223 template <
typename T>
224 MYGUI_OBSOLETE(
"use : template <typename T> void Element::addAttribute(const std::string &_key, const T& _value)")
225 void addAttributes(const std::
string& _key, const T& _value)
227 addAttribute<T>(_key, _value);
229 MYGUI_OBSOLETE(
"use : void Element::addAttribute(const std::string& _key, const std::string& _value)")
230 void addAttributes(const std::
string& _key, const std::
string& _value)
232 addAttribute(_key, _value);
235 template <
typename T>
236 MYGUI_OBSOLETE(
"use : template <typename T> void Element::addContent(const T& _content)")
237 void addBody(const T& _content)
239 addContent<T>(_content);
241 MYGUI_OBSOLETE(
"use : void Element::addContent(const std::string& _content)")
242 void addBody(const std::
string& _content)
244 addContent(_content);
246 template <
typename T>
247 MYGUI_OBSOLETE(
"use : template <typename T> void Element::setContent(const T& _content)")
248 void setBody(const T& _content)
250 setContent<T>(_content);
252 MYGUI_OBSOLETE(
"use : void Element::setContent(const std::string& _content)")
253 void setBody(const std::
string& _content)
255 setContent(_content);
259 const std::
string& getBody()
const
263 MYGUI_OBSOLETE(
"use : ElementEnumerator Element::getElementEnumerator()")
266 return getElementEnumerator();
269 #endif // MYGUI_DONT_USE_OBSOLETE
273 std::string mContent;
290 bool open(
const std::string& _filename);
293 bool open(
const std::wstring& _filename);
296 bool open(std::istream& _stream);
298 bool open(
const UString& _filename);
303 bool save(
const std::string& _filename);
306 bool save(
const std::wstring& _filename);
308 bool save(std::ostream& _stream);
310 bool save(
const UString& _filename);
314 std::string getLastError();
316 void clearLastError();
318 ElementPtr createDeclaration(
const std::string& _version =
"1.0",
const std::string& _encoding =
"UTF-8");
319 ElementPtr createRoot(
const std::string& _name);
324 #ifndef MYGUI_DONT_USE_OBSOLETE
326 MYGUI_OBSOLETE(
"use : ElementPtr Document::createDeclaration(const std::string& _version, const std::string& _encoding)")
327 ElementPtr createInfo(const std::
string& _version = "1.0", const std::
string& _encoding = "UTF-8")
329 return createDeclaration(_version, _encoding);
332 #endif // MYGUI_DONT_USE_OBSOLETE
335 void setLastFileError(
const std::string& _filename);
336 void setLastFileError(
const std::wstring& _filename);
338 bool parseTag(
ElementPtr& _currentNode, std::string _content);
340 bool checkPair(std::string& _key, std::string& _value);
342 bool parseLine(std::string& _line,
ElementPtr& _element);
345 size_t find(
const std::string& _text,
char _char,
size_t _start = 0);
347 void clearDeclaration();
354 std::string mLastErrorFile;
371 #endif // __MYGUI_XML_DOCUMENT_H__