Changeset View
Changeset View
Standalone View
Standalone View
source/ps/XML/XMLWriter.h
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | |||||
* scoping braces are important to indicate where an element ends. If you don't put | * scoping braces are important to indicate where an element ends. If you don't put | ||||
* them the tag won't be closed until the object's destructor is called, usually | * them the tag won't be closed until the object's destructor is called, usually | ||||
* when it goes out of scope. | * when it goes out of scope. | ||||
* xml_element_.Attribute/xml_element_.Setting are templated. To support more types, alter the | * xml_element_.Attribute/xml_element_.Setting are templated. To support more types, alter the | ||||
* end of XMLWriter.cpp. | * end of XMLWriter.cpp. | ||||
*/ | */ | ||||
#include "lib/file/vfs/vfs.h" | #include "lib/file/vfs/vfs.h" | ||||
#include "ps/CStr.h" | |||||
class CStr8; | |||||
class XMBElement; | class XMBElement; | ||||
class XMBFile; | class XMBFile; | ||||
class XMLWriter_Element; | class XMLWriter_Element; | ||||
class XMLWriter_File | class XMLWriter_File | ||||
{ | { | ||||
public: | public: | ||||
XMLWriter_File(); | XMLWriter_File(); | ||||
Show All 18 Lines | private: | ||||
template <typename T> void ElementAttribute(const char* name, const T& value, bool newelement); | template <typename T> void ElementAttribute(const char* name, const T& value, bool newelement); | ||||
void ElementClose(); | void ElementClose(); | ||||
void ElementEnd(const char* name, int type); | void ElementEnd(const char* name, int type); | ||||
CStr8 Indent(); | CStr8 Indent(); | ||||
bool m_PrettyPrint; | bool m_PrettyPrint; | ||||
CStr8 m_Data; | CStr m_Data; | ||||
int m_Indent; | int m_Indent; | ||||
XMLWriter_Element* m_LastElement; | XMLWriter_Element* m_LastElement; | ||||
}; | }; | ||||
class XMLWriter_Element | class XMLWriter_Element | ||||
{ | { | ||||
public: | public: | ||||
XMLWriter_Element(XMLWriter_File& file, const char* name); | XMLWriter_Element(XMLWriter_File& file, const char* name); | ||||
~XMLWriter_Element(); | ~XMLWriter_Element(); | ||||
template <typename constCharPtr> void Text(constCharPtr text, bool cdata); | template <typename constCharPtr> void Text(constCharPtr text, bool cdata); | ||||
template <typename T> void Attribute(const char* name, T value) { m_File->ElementAttribute(name, value, false); } | template <typename T> void Attribute(const char* name, T value) { m_File->ElementAttribute(name, value, false); } | ||||
template <typename T> void Setting(const char* name, T value) { m_File->ElementAttribute(name, value, true); } | template <typename T> void Setting(const char* name, T value) { m_File->ElementAttribute(name, value, true); } | ||||
void Close(int type); | void Close(int type); | ||||
private: | private: | ||||
friend class XMLWriter_File; | friend class XMLWriter_File; | ||||
XMLWriter_File* m_File; | XMLWriter_File* m_File; | ||||
CStr8 m_Name; | CStr m_Name; | ||||
int m_Type; | int m_Type; | ||||
}; | }; | ||||
#endif // INCLUDED_XMLWRITER | #endif // INCLUDED_XMLWRITER |
Wildfire Games · Phabricator