mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
Support startup scripts in map files, for testing.
Support CDATA sections when writing XML. This was SVN commit r7483.
This commit is contained in:
@@ -56,6 +56,13 @@ namespace
|
||||
return ret;
|
||||
}
|
||||
|
||||
CStr escapeCDATA(const char* input)
|
||||
{
|
||||
CStr ret = input;
|
||||
ret.Replace("]]>", "]]>]]><![CDATA[");
|
||||
return ret;
|
||||
}
|
||||
|
||||
CStr escapeComment(const char* input)
|
||||
{
|
||||
// Comment ::= '<!--' ((Char - '-') | ('-' (Char - '-')))* '-->'
|
||||
@@ -169,9 +176,18 @@ void XMLWriter_File::ElementEnd(const char* name, int type)
|
||||
}
|
||||
}
|
||||
|
||||
void XMLWriter_File::ElementText(const char* text)
|
||||
void XMLWriter_File::ElementText(const char* text, bool cdata)
|
||||
{
|
||||
m_Data += escapeCharacterData(text);
|
||||
if (cdata)
|
||||
{
|
||||
m_Data += "<![CDATA[";
|
||||
m_Data += escapeCDATA(text);
|
||||
m_Data += "]]>";
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Data += escapeCharacterData(text);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -200,15 +216,15 @@ void XMLWriter_Element::Close(int type)
|
||||
|
||||
// Template specialisations for various string types:
|
||||
|
||||
template <> void XMLWriter_Element::Text<const char*>(const char* text)
|
||||
template <> void XMLWriter_Element::Text<const char*>(const char* text, bool cdata)
|
||||
{
|
||||
Close(EL_TEXT);
|
||||
m_File->ElementText(text);
|
||||
m_File->ElementText(text, cdata);
|
||||
}
|
||||
|
||||
template <> void XMLWriter_Element::Text<const wchar_t*>(const wchar_t* text)
|
||||
template <> void XMLWriter_Element::Text<const wchar_t*>(const wchar_t* text, bool cdata)
|
||||
{
|
||||
Text( CStrW(text).ToUTF8().c_str() );
|
||||
Text( CStrW(text).ToUTF8().c_str(), cdata );
|
||||
}
|
||||
|
||||
//
|
||||
@@ -219,7 +235,7 @@ template <> void XMLWriter_File::ElementAttribute<const char*>(const char* name,
|
||||
{
|
||||
ElementStart(NULL, name);
|
||||
m_Data += ">";
|
||||
ElementText(value);
|
||||
ElementText(value, false);
|
||||
ElementEnd(name, EL_TEXT);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user