From eebc1e9f3c2437a3d63e94f28836e7c3ce8d07a8 Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Sun, 4 Feb 2007 10:57:09 +0000 Subject: [PATCH] Simplify. --- stepmania/src/XmlFileUtil.cpp | 47 ++++++++++++++++------------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/stepmania/src/XmlFileUtil.cpp b/stepmania/src/XmlFileUtil.cpp index bcf990b378..e95478a0f5 100644 --- a/stepmania/src/XmlFileUtil.cpp +++ b/stepmania/src/XmlFileUtil.cpp @@ -402,41 +402,39 @@ unsigned LoadInternal( XNode *pNode, const RString &xml, RString &sErrorOut, uns bool GetXMLInternal( const XNode *pNode, RageFileBasic &f, bool bWriteTabs, int &iTabBase ) { +#define WRITE(x) if( f.Write(x) == -1 ) return false // tab - if( f.Write("\r\n") == -1 ) - return false; + WRITE( "\r\n" ); if( bWriteTabs ) for( int i = 0 ; i < iTabBase ; i++) - if( f.Write("\t") == -1 ) - return false; + WRITE( "\t" ); // GetName()) == -1 ) - return false; + WRITE( "<" ); + WRITE( pNode->GetName() ); // m_attrs.empty() ) - if( f.Write(" ") == -1 ) - return false; + WRITE( " " ); FOREACH_CONST_Attr( pNode, p ) { RString attr( p->second->GetValue() ); ReplaceEntityText( attr, g_mapCharsToEntities ); - if( f.Write( p->first ) == -1 || f.Write( "='" ) == -1 || f.Write( attr ) || f.Write( "' " ) == -1 ) - return false; + WRITE( p->first ); + WRITE( "='" ); + WRITE( attr ); + WRITE( "' " ); } if( pNode->m_childs.empty() && pNode->m_pValue->GetValue().empty() ) { // alone tag - if( f.Write("/>") == -1 ) - return false; + WRITE( "/>" ); } else { // and get child - if( f.Write(">") == -1 ) - return false; + WRITE( ">" ); if( !pNode->m_childs.empty() ) iTabBase++; @@ -450,37 +448,34 @@ bool GetXMLInternal( const XNode *pNode, RageFileBasic &f, bool bWriteTabs, int { if( !pNode->m_childs.empty() ) { - if( f.Write("\r\n") == -1 ) - return false; + WRITE( "\r\n" ); if( bWriteTabs ) for( int i = 0 ; i < iTabBase ; i++) - if( f.Write("\t") == -1 ) - return false; + WRITE( "\t" ); } RString s; pNode->m_pValue->GetValue( s ); ReplaceEntityText( s, g_mapCharsToEntities ); - if( f.Write(s) == -1 ) - return false; + WRITE( s ); } // CloseTag if( !pNode->m_childs.empty() ) { - if( f.Write("\r\n") == -1 ) - return false; + WRITE( "\r\n" ); if( bWriteTabs ) for( int i = 0 ; i < iTabBase-1 ; i++) - if( f.Write("\t") == -1 ) - return false; + WRITE( "\t" ); } - if( f.Write("GetName()) == -1 || f.Write(">") == -1 ) - return false; + WRITE( "GetName() ); + WRITE( ">" ); if( !pNode->m_childs.empty() ) iTabBase--; } return true; +#undef WRITE } }