18 #include "precompiled.h"
43 ret.Replace(
"&",
"&");
44 ret.Replace(
"<",
"<");
45 ret.Replace(
"\"",
""");
54 ret.Replace(
"&",
"&");
55 ret.Replace(
"<",
"<");
56 ret.Replace(
"]]>",
"]]>");
63 ret.Replace(
"]]>",
"]]>]]><![CDATA[");
74 ret.Replace(
"--",
"\xE2\x80\x90\xE2\x80\x90");
85 : m_Indent(0), m_LastElement(NULL),
91 m_Data =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
98 const size_t size =
m_Data.length();
101 memcpy(data.get(),
m_Data.data(), size);
102 Status ret = vfs->CreateFile(pathname, data, size);
105 LOGERROR(L
"Error saving XML data through VFS: %lld '%ls'", (
long long)ret, pathname.
string().c_str());
213 : m_File(&file), m_Name(name), m_Type(
EL_ATTR)
237 template <>
void XMLWriter_Element::Text<const char*>(
const char* text,
bool cdata)
240 m_File->ElementText(text, cdata);
243 template <>
void XMLWriter_Element::Text<const wchar_t*>(
const wchar_t* text,
bool cdata)
245 Text( CStrW(text).ToUTF8().c_str(), cdata );
250 template <>
void XMLWriter_File::ElementAttribute<const char*>(
const char* name,
const char*
const& value,
bool newelement)
254 ElementStart(NULL, name);
256 ElementText(value,
false);
276 template <>
void XMLWriter_File::ElementAttribute<CStr>(
const char* name,
const CStr& value,
bool newelement)
278 ElementAttribute(name, value.c_str(), newelement);
280 template <>
void XMLWriter_File::ElementAttribute<std::string>(
const char* name,
const std::string& value,
bool newelement)
282 ElementAttribute(name, value.c_str(), newelement);
285 template <>
void XMLWriter_File::ElementAttribute<CStrW>(
const char* name,
const CStrW& value,
bool newelement)
287 ElementAttribute(name, value.ToUTF8(), newelement);
289 template <>
void XMLWriter_File::ElementAttribute<std::wstring>(
const char* name,
const std::wstring& value,
bool newelement)
294 template <>
void XMLWriter_File::ElementAttribute<fixed>(
const char* name,
const fixed& value,
bool newelement)
296 ElementAttribute(name, value.ToString().c_str(), newelement);
299 template <>
void XMLWriter_File::ElementAttribute<int>(
const char* name,
const int& value,
bool newelement)
301 std::stringstream ss;
303 ElementAttribute(name, ss.str().c_str(), newelement);
306 template <>
void XMLWriter_File::ElementAttribute<unsigned int>(
const char* name,
const unsigned int& value,
bool newelement)
308 std::stringstream ss;
310 ElementAttribute(name, ss.str().c_str(), newelement);
313 template <>
void XMLWriter_File::ElementAttribute<float>(
const char* name,
const float& value,
bool newelement)
315 std::stringstream ss;
317 ElementAttribute(name, ss.str().c_str(), newelement);
320 template <>
void XMLWriter_File::ElementAttribute<double>(
const char* name,
const double& value,
bool newelement)
322 std::stringstream ss;
324 ElementAttribute(name, ss.str().c_str(), newelement);
A simple fixed-point number class.
CStr escapeCharacterData(const char *input)
CStr escapeCDATA(const char *input)
#define XERO_ITER_ATTR(parent_element, attribute)
std::string utf8_from_wstring(const std::wstring &src, Status *err)
opposite of wstring_from_utf8
static const uintptr_t maxSectorSize
void XMB(const XMBFile &file)
void ElementStart(XMLWriter_Element *element, const char *name)
#define XERO_ITER_EL(parent_element, child_element)
CStr escapeComment(const char *input)
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
XMLWriter_Element * m_LastElement
const String & string() const
i64 Status
Error handling system.
void Comment(const char *text)
CStr escapeAttributeValue(const char *input)
std::string GetElementString(const int ID) const
#define DEBUG_WARN_ERR(status)
display the error dialog with text corresponding to the given error code.
void ElementEnd(const char *name, int type)
static Status AllocateAligned(shared_ptr< T > &p, size_t size, size_t alignment=cacheLineSize)
XMBElement GetRoot() const
#define debug_warn(expr)
display the error dialog with the given text.
XMLWriter_Element(XMLWriter_File &file, const char *name)
std::string GetAttributeString(const int ID) const
void ElementText(const char *text, bool cdata)
void ElementXMB(const XMBFile &file, XMBElement el)
bool StoreVFS(const PIVFS &vfs, const VfsPath &pathname)