Simplify.
This commit is contained in:
@@ -392,7 +392,7 @@ void CatalogXml::Save( LoadingWindow *loading_window )
|
|||||||
xml.AppendChild( "FooterText", FOOTER_TEXT );
|
xml.AppendChild( "FooterText", FOOTER_TEXT );
|
||||||
xml.AppendChild( "FooterLink", FOOTER_LINK );
|
xml.AppendChild( "FooterLink", FOOTER_LINK );
|
||||||
|
|
||||||
xml.SaveToFile( fn, XMLDisplayOptions(CATALOG_XSL, false) );
|
xml.SaveToFile( fn, CATALOG_XSL, false );
|
||||||
|
|
||||||
LOG->Trace( "Done." );
|
LOG->Trace( "Done." );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ void ExportStrings::LuaInformation()
|
|||||||
XNode *pDateNode = pNode->AppendChild( "Date" );
|
XNode *pDateNode = pNode->AppendChild( "Date" );
|
||||||
pDateNode->m_sValue = DateTime::GetNowDate().GetString();
|
pDateNode->m_sValue = DateTime::GetNowDate().GetString();
|
||||||
|
|
||||||
pNode->SaveToFile( "Lua.xml", XMLDisplayOptions( "Lua.xsl") );
|
pNode->SaveToFile( "Lua.xml", "Lua.xsl" );
|
||||||
|
|
||||||
delete pNode;
|
delete pNode;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -940,7 +940,7 @@ bool Profile::SaveStatsXmlToDir( RString sDir, bool bSignData ) const
|
|||||||
// Save stats.xml
|
// Save stats.xml
|
||||||
RString fn = sDir + STATS_XML;
|
RString fn = sDir + STATS_XML;
|
||||||
|
|
||||||
bool bSaved = xml->SaveToFile( fn, XMLDisplayOptions(STATS_XSL, false) );
|
bool bSaved = xml->SaveToFile( fn, STATS_XSL, false );
|
||||||
|
|
||||||
SAFE_DELETE( xml );
|
SAFE_DELETE( xml );
|
||||||
|
|
||||||
|
|||||||
@@ -602,20 +602,20 @@ void XNode::AppendAttr( const RString &sName, float value ){ AppendAttr(sName,ss
|
|||||||
void XNode::AppendAttr( const RString &sName, int value ) { AppendAttr(sName,ssprintf("%d",value)); }
|
void XNode::AppendAttr( const RString &sName, int value ) { AppendAttr(sName,ssprintf("%d",value)); }
|
||||||
void XNode::AppendAttr( const RString &sName, unsigned value ) { AppendAttr(sName,ssprintf("%u",value)); }
|
void XNode::AppendAttr( const RString &sName, unsigned value ) { AppendAttr(sName,ssprintf("%u",value)); }
|
||||||
|
|
||||||
bool XNode::SaveToFile( RageFileBasic &f, const XMLDisplayOptions &opt ) const
|
bool XNode::SaveToFile( RageFileBasic &f, const RString &sStylesheet, bool bWriteTabs ) const
|
||||||
{
|
{
|
||||||
f.PutLine( "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" );
|
f.PutLine( "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" );
|
||||||
if( !opt.m_sStylesheet.empty() )
|
if( !sStylesheet.empty() )
|
||||||
f.PutLine( "<?xml-stylesheet type=\"text/xsl\" href=\"" + opt.m_sStylesheet + "\"?>" );
|
f.PutLine( "<?xml-stylesheet type=\"text/xsl\" href=\"" + sStylesheet + "\"?>" );
|
||||||
int iTabBase = 0;
|
int iTabBase = 0;
|
||||||
if( !this->GetXMLInternal(f, opt.m_bWriteTabs, iTabBase) )
|
if( !this->GetXMLInternal(f, bWriteTabs, iTabBase) )
|
||||||
return false;
|
return false;
|
||||||
if( f.Flush() == -1 )
|
if( f.Flush() == -1 )
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XNode::SaveToFile( const RString &sFile, const XMLDisplayOptions &opt ) const
|
bool XNode::SaveToFile( const RString &sFile, const RString &sStylesheet, bool bWriteTabs ) const
|
||||||
{
|
{
|
||||||
RageFile f;
|
RageFile f;
|
||||||
if( !f.Open(sFile, RageFile::WRITE) )
|
if( !f.Open(sFile, RageFile::WRITE) )
|
||||||
@@ -624,5 +624,5 @@ bool XNode::SaveToFile( const RString &sFile, const XMLDisplayOptions &opt ) con
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SaveToFile( f, opt );
|
return SaveToFile( f, sStylesheet, bWriteTabs );
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-15
@@ -35,19 +35,6 @@ typedef multimap<RString,XNode*> XNodes;
|
|||||||
Var##Iter != (pNode)->m_childs.end(); \
|
Var##Iter != (pNode)->m_childs.end(); \
|
||||||
++Var##Iter )
|
++Var##Iter )
|
||||||
|
|
||||||
// display optional environment
|
|
||||||
struct XMLDisplayOptions
|
|
||||||
{
|
|
||||||
XMLDisplayOptions( const RString &sStylesheet = "", bool bWriteTabs = true )
|
|
||||||
{
|
|
||||||
m_sStylesheet = sStylesheet;
|
|
||||||
m_bWriteTabs = bWriteTabs;
|
|
||||||
}
|
|
||||||
|
|
||||||
RString m_sStylesheet; // empty string = no stylesheet
|
|
||||||
bool m_bWriteTabs; // if false, don't write tab indent characters
|
|
||||||
};
|
|
||||||
|
|
||||||
// XMLNode structure
|
// XMLNode structure
|
||||||
class XNode
|
class XNode
|
||||||
{
|
{
|
||||||
@@ -76,8 +63,8 @@ public:
|
|||||||
bool GetXML( RageFileBasic &f, bool bWriteTabs = true ) const;
|
bool GetXML( RageFileBasic &f, bool bWriteTabs = true ) const;
|
||||||
RString GetXML() const;
|
RString GetXML() const;
|
||||||
|
|
||||||
bool SaveToFile( const RString &sFile, const XMLDisplayOptions &opt = XMLDisplayOptions() ) const;
|
bool SaveToFile( const RString &sFile, const RString &sStylesheet = "", bool bWriteTabs = true ) const;
|
||||||
bool SaveToFile( RageFileBasic &f, const XMLDisplayOptions &opt = XMLDisplayOptions() ) const;
|
bool SaveToFile( RageFileBasic &f, const RString &sStylesheet = "", bool bWriteTabs = true ) const;
|
||||||
|
|
||||||
// in own attribute list
|
// in own attribute list
|
||||||
const RString *GetAttr( const RString &sAttrName ) const;
|
const RString *GetAttr( const RString &sAttrName ) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user