diff --git a/stepmania/src/XmlFileUtil.cpp b/stepmania/src/XmlFileUtil.cpp index 85d3f5043b..e0e1a7c90a 100644 --- a/stepmania/src/XmlFileUtil.cpp +++ b/stepmania/src/XmlFileUtil.cpp @@ -54,7 +54,6 @@ static const char chXMLDash = '-'; static map g_mapEntitiesToChars; static map g_mapCharsToEntities; -// XXX not called static void InitEntities() { if( !g_mapEntitiesToChars.empty() ) @@ -202,10 +201,6 @@ unsigned LoadAttributes( XNode *pNode, const RString &xml, RString &sErrorOut, u return string::npos; } -} - - - // // // or @@ -215,7 +210,7 @@ unsigned LoadAttributes( XNode *pNode, const RString &xml, RString &sErrorOut, u // Param : pszXml - plain xml text // pi = parser information // Return : advanced string pointer (error return npos) -unsigned XmlFileUtil::Load( XNode *pNode, const RString &xml, RString &sErrorOut, unsigned iOffset ) +unsigned LoadInternal( XNode *pNode, const RString &xml, RString &sErrorOut, unsigned iOffset ) { pNode->Clear(); @@ -246,7 +241,7 @@ unsigned XmlFileUtil::Load( XNode *pNode, const RString &xml, RString &sErrorOut // Skip -->. iOffset = iEnd + 3; - return Load( pNode, xml, sErrorOut, iOffset ); + return LoadInternal( pNode, xml, sErrorOut, iOffset ); } // XML Node Tag Name Open @@ -288,7 +283,7 @@ unsigned XmlFileUtil::Load( XNode *pNode, const RString &xml, RString &sErrorOut // just loaded is a meta tag, then Load ourself again using the rest // of the file until we reach a non-meta tag. if( !pNode->GetName().empty() && (pNode->GetName()[0] == chXMLQuestion || pNode->GetName()[0] == chXMLExclamation) ) - iOffset = Load( pNode, xml, sErrorOut, iOffset ); + iOffset = LoadInternal( pNode, xml, sErrorOut, iOffset ); return iOffset; } @@ -322,7 +317,7 @@ unsigned XmlFileUtil::Load( XNode *pNode, const RString &xml, RString &sErrorOut { XNode *node = new XNode; - iOffset = Load( node, xml, sErrorOut, iOffset ); + iOffset = LoadInternal( node, xml, sErrorOut, iOffset ); if( !node->GetName().empty() ) { DEBUG_ASSERT( node->GetName().size() ); @@ -398,8 +393,6 @@ unsigned XmlFileUtil::Load( XNode *pNode, const RString &xml, RString &sErrorOut return iOffset; } -namespace -{ bool GetAttrXML( RageFileBasic &f, const RString &sName, const RString &sValue ) { RString s(sValue); @@ -487,9 +480,16 @@ bool GetXMLInternal( const XNode *pNode, RageFileBasic &f, bool bWriteTabs, int } } +void XmlFileUtil::Load( XNode *pNode, const RString &sXml, RString &sErrorOut ) +{ + InitEntities(); + LoadInternal( pNode, sXml, sErrorOut, 0 ); +} + bool XmlFileUtil::GetXML( const XNode *pNode, RageFileBasic &f, bool bWriteTabs ) { int iTabBase = 0; + InitEntities(); return GetXMLInternal( pNode, f, bWriteTabs, iTabBase ); } @@ -497,6 +497,7 @@ RString XmlFileUtil::GetXML( const XNode *pNode ) { RageFileObjMem f; int iTabBase = 0; + InitEntities(); GetXMLInternal( pNode, f, true, iTabBase ); return f.GetString(); } @@ -507,6 +508,7 @@ bool XmlFileUtil::SaveToFile( const XNode *pNode, RageFileBasic &f, const RStrin if( !sStylesheet.empty() ) f.PutLine( "" ); int iTabBase = 0; + InitEntities(); if( !GetXMLInternal(pNode, f, bWriteTabs, iTabBase) ) return false; f.PutLine( "" ); diff --git a/stepmania/src/XmlFileUtil.h b/stepmania/src/XmlFileUtil.h index 622b1836fc..3e0d28276a 100644 --- a/stepmania/src/XmlFileUtil.h +++ b/stepmania/src/XmlFileUtil.h @@ -1,7 +1,7 @@ /* XmlFileUtil - A little graphic to the left of the song's text banner in the MusicWheel. */ -#ifndef XmlFileUtil_H -#define XmlFileUtil_H +#ifndef XML_FILE_UTIL_H +#define XML_FILE_UTIL_H class RageFileBasic; class XNode; @@ -12,7 +12,7 @@ namespace XmlFileUtil bool LoadFromFileShowErrors( XNode &xml, RageFileBasic &f ); // Load/Save XML - unsigned Load( XNode *pNode, const RString &sXml, RString &sErrorOut, unsigned iOffset = 0 ); + void Load( XNode *pNode, const RString &sXml, RString &sErrorOut ); bool GetXML( const XNode *pNode, RageFileBasic &f, bool bWriteTabs = true ); RString GetXML( const XNode *pNode ); bool SaveToFile( const XNode *pNode, const RString &sFile, const RString &sStylesheet = "", bool bWriteTabs = true );