7#ifndef MYGUI_XML_DOCUMENT_H_
8#define MYGUI_XML_DOCUMENT_H_
43 return a.mValue ==
b.mValue;
47 return a.mValue !=
b.mValue;
83 return getValueName(mValue);
87 std::string_view getValueName(
int _index)
const
91 static const std::string_view
values[
MAX] = {
92 "Failed to open XML file",
93 "Failed to create XML file",
94 "XML file contain incorrect content",
95 "XML file contain not closed elements",
96 "XML file without declaration",
97 "XML file contain closed but not opened element",
98 "XML file contain inconsistent elements",
99 "XML file contain more than one declaration",
100 "XML file contain more than one root element",
101 "XML file contain incorrect attribute"};
102 return values[_index];
129 bool next(std::string_view
_name);
135#ifndef MYGUI_DONT_USE_OBSOLETE
142 MYGUI_OBSOLETE(
"use : bool ElementEnumerator::next(std::string_view _name)")
157 VectorElement::iterator m_current, m_end;
170 std::string_view
_name,
181 std::string_view
_name,
186 template<
typename T,
typename = std::enable_if_t<!std::is_convertible_v<T, std::
string_view>>>
192 void addAttribute(std::string_view
_key, std::string_view
_value);
194 void removeAttribute(std::string_view
_key);
196 void setAttribute(std::string_view
_key, std::string_view
_value);
198 template<
typename T,
typename = std::enable_if_t<!std::is_convertible_v<T, std::
string_view>>>
204 void addContent(std::string_view
_content);
206 template<
typename T,
typename = std::enable_if_t<!std::is_convertible_v<T, std::
string_view>>>
212 void setContent(std::string_view
_content);
216 bool findAttribute(std::string_view
_name, std::string&
_value);
217 std::string_view findAttribute(std::string_view
_name);
219 const std::string& getName()
const;
221 const std::string& getContent()
const;
231 std::unique_ptr<Element> createCopy();
234#ifndef MYGUI_DONT_USE_OBSOLETE
238 "use : template <typename T> void Element::addAttribute(const std::string &_key, const T& _value)")
243 MYGUI_OBSOLETE(
"use : void Element::addAttribute(std::string_view _key, std::string_view _value)")
250 MYGUI_OBSOLETE(
"use : template <typename T> void Element::addContent(const T& _content)")
255 MYGUI_OBSOLETE(
"use : void Element::addContent(std::string_view _content)")
261 MYGUI_OBSOLETE(
"use : template <typename T> void Element::setContent(const T& _content)")
266 MYGUI_OBSOLETE(
"use : void Element::setContent(std::string_view _content)")
277 MYGUI_OBSOLETE(
"use : ElementEnumerator Element::getElementEnumerator()")
280 return getElementEnumerator();
287 std::string mContent;
304 bool open(
const std::wstring&
_filename);
307 bool open(std::istream&
_stream);
317 bool save(
const std::wstring&
_filename);
319 bool save(std::ostream&
_stream);
325 std::string getLastError()
const;
327 void clearLastError();
335#ifndef MYGUI_DONT_USE_OBSOLETE
338 "use : ElementPtr Document::createDeclaration(std::string_view _version, std::string_view _encoding)")
347 void setLastFileError(std::string_view
_filename);
348 void setLastFileError(
const std::wstring&
_filename);
352 bool checkPair(std::string&
_key, std::string&
_value);
359 void clearDeclaration();
363 std::unique_ptr<Element> mRoot;
364 std::unique_ptr<Element> mDeclaration;
366 std::string mLastErrorFile;
372 using xmlNodeIterator
MYGUI_OBSOLETE(
"use : class MyGUI::xml::ElementEnumerator") = ElementEnumerator;
374 using xmlDocument
MYGUI_OBSOLETE(
"use : class MyGUI::xml::Document") = Document;
#define MYGUI_OBSOLETE(text)
A UTF-16 string with implicit conversion to/from std::string and std::wstring.
Element(Element &&)=default
void addAttribute(std::string_view _key, const T &_value)
void setContent(const T &_content)
void addContent(const T &_content)
std::string toString(T _value)
std::pair< std::string, std::string > PairAttribute
std::vector< PairAttribute > VectorAttributes
std::vector< std::unique_ptr< Element > > VectorElement
friend bool operator==(ElementType const &a, ElementType const &b)
friend bool operator!=(ElementType const &a, ElementType const &b)
ElementType(Enum _value=MAX)
std::string_view print() const
@ MoreThanOneXMLDeclaration
@ InconsistentOpenCloseElements
ErrorType(Enum _value=MAX)