Changeset View
Changeset View
Standalone View
Standalone View
source/ps/XML/XMLWriter.h
/* Copyright (C) 2019 Wildfire Games. | /* Copyright (C) 2021 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
* 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" | #include "ps/CStr.h" | ||||
class XMBElement; | class XMBElement; | ||||
class XMBFile; | class XMBData; | ||||
class XMLWriter_Element; | class XMLWriter_Element; | ||||
class XMLWriter_File | class XMLWriter_File | ||||
{ | { | ||||
public: | public: | ||||
XMLWriter_File(); | XMLWriter_File(); | ||||
void SetPrettyPrint(bool enabled) { m_PrettyPrint = enabled; } | void SetPrettyPrint(bool enabled) { m_PrettyPrint = enabled; } | ||||
void Comment(const char* text); | void Comment(const char* text); | ||||
void XMB(const XMBFile& file); | void XMB(const XMBData& file); | ||||
bool StoreVFS(const PIVFS& vfs, const VfsPath& pathname); | bool StoreVFS(const PIVFS& vfs, const VfsPath& pathname); | ||||
const CStr8& GetOutput(); | const CStr8& GetOutput(); | ||||
private: | private: | ||||
friend class XMLWriter_Element; | friend class XMLWriter_Element; | ||||
void ElementXMB(const XMBFile& file, XMBElement el); | void ElementXMB(const XMBData& file, XMBElement el); | ||||
void ElementStart(XMLWriter_Element* element, const char* name); | void ElementStart(XMLWriter_Element* element, const char* name); | ||||
void ElementText(const char* text, bool cdata); | void ElementText(const char* text, bool cdata); | ||||
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(); | ||||
Show All 29 Lines |
Wildfire Games · Phabricator