Always true.

This commit is contained in:
Steve Checkoway
2006-10-01 13:00:20 +00:00
parent 08155c351a
commit 6651be1203
2 changed files with 15 additions and 30 deletions
+15 -26
View File
@@ -394,8 +394,7 @@ unsigned XNode::Load( const RString &xml, RString &sErrorOut, unsigned iOffset )
bool XNode::GetAttrXML( RageFileBasic &f, DISP_OPT &opt, const RString &sName, const RString &sValue ) const bool XNode::GetAttrXML( RageFileBasic &f, DISP_OPT &opt, const RString &sName, const RString &sValue ) const
{ {
RString s(sValue); RString s(sValue);
if( opt.reference_value ) ReplaceEntityText( s, g_mapCharsToEntities );
ReplaceEntityText( s, g_mapCharsToEntities );
return f.Write(sName + "='" + s + "' ") != -1; return f.Write(sName + "='" + s + "' ") != -1;
} }
@@ -404,15 +403,12 @@ bool XNode::GetAttrXML( RageFileBasic &f, DISP_OPT &opt, const RString &sName, c
bool XNode::GetXML( RageFileBasic &f, DISP_OPT &opt ) const bool XNode::GetXML( RageFileBasic &f, DISP_OPT &opt ) const
{ {
// tab // tab
if( opt.newline ) if( f.Write("\r\n") == -1 )
{ return false;
if( f.Write("\r\n") == -1 ) if( opt.write_tabs )
return false; for( int i = 0 ; i < opt.tab_base ; i++)
if( opt.write_tabs ) if( f.Write("\t") == -1 )
for( int i = 0 ; i < opt.tab_base ; i++) return false;
if( f.Write("\t") == -1 )
return false;
}
// <TAG // <TAG
if( f.Write("<" + m_sName) == -1 ) if( f.Write("<" + m_sName) == -1 )
@@ -438,10 +434,8 @@ bool XNode::GetXML( RageFileBasic &f, DISP_OPT &opt ) const
if( f.Write(">") == -1 ) if( f.Write(">") == -1 )
return false; return false;
if( opt.newline && !m_childs.empty() ) if( !m_childs.empty() )
{
opt.tab_base++; opt.tab_base++;
}
FOREACH_CONST_Child( this, p ) FOREACH_CONST_Child( this, p )
if( !p->GetXML( f, opt ) ) if( !p->GetXML( f, opt ) )
@@ -450,25 +444,23 @@ bool XNode::GetXML( RageFileBasic &f, DISP_OPT &opt ) const
// Text Value // Text Value
if( !m_sValue.empty() ) if( !m_sValue.empty() )
{ {
if( opt.newline && !m_childs.empty() ) if( !m_childs.empty() )
{ {
if( opt.newline ) if( f.Write("\r\n") == -1 )
if( f.Write("\r\n") == -1 ) return false;
return false;
if( opt.write_tabs ) if( opt.write_tabs )
for( int i = 0 ; i < opt.tab_base ; i++) for( int i = 0 ; i < opt.tab_base ; i++)
if( f.Write("\t") == -1 ) if( f.Write("\t") == -1 )
return false; return false;
} }
RString s( m_sValue ); RString s( m_sValue );
if( opt.reference_value ) ReplaceEntityText( s, g_mapCharsToEntities );
ReplaceEntityText( s, g_mapCharsToEntities );
if( f.Write(s) == -1 ) if( f.Write(s) == -1 )
return false; return false;
} }
// </TAG> CloseTag // </TAG> CloseTag
if( opt.newline && !m_childs.empty() ) if( !m_childs.empty() )
{ {
if( f.Write("\r\n") == -1 ) if( f.Write("\r\n") == -1 )
return false; return false;
@@ -480,11 +472,8 @@ bool XNode::GetXML( RageFileBasic &f, DISP_OPT &opt ) const
if( f.Write("</" + m_sName + ">") == -1 ) if( f.Write("</" + m_sName + ">") == -1 )
return false; return false;
if( opt.newline ) if( !m_childs.empty() )
{ opt.tab_base--;
if( !m_childs.empty() )
opt.tab_base--;
}
} }
return true; return true;
} }
-4
View File
@@ -38,16 +38,12 @@ typedef multimap<RString,XNode*> XNodes;
// display optional environment // display optional environment
struct DISP_OPT struct DISP_OPT
{ {
bool newline; // newline when new tag
bool reference_value; // do convert from entity to reference ( < -> &lt; )
RString stylesheet; // empty string = no stylesheet RString stylesheet; // empty string = no stylesheet
bool write_tabs; // if false, don't write tab indent characters bool write_tabs; // if false, don't write tab indent characters
int tab_base; // internal usage int tab_base; // internal usage
DISP_OPT() DISP_OPT()
{ {
newline = true;
reference_value = true;
stylesheet = ""; stylesheet = "";
write_tabs = true; write_tabs = true;
tab_base = 0; tab_base = 0;