From 5772a41b92afdd189417add304ad3ba6c1c5a9d8 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 11 Feb 2007 00:38:27 +0000 Subject: [PATCH] use accessors --- stepmania/src/XmlFileUtil.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/stepmania/src/XmlFileUtil.cpp b/stepmania/src/XmlFileUtil.cpp index 97079ade78..0fd522709b 100644 --- a/stepmania/src/XmlFileUtil.cpp +++ b/stepmania/src/XmlFileUtil.cpp @@ -293,7 +293,7 @@ unsigned LoadInternal( XNode *pNode, const RString &xml, RString &sErrorOut, uns // open/close tag ... // ^- current pointer - if( XIsEmptyString(pNode->m_pValue->GetValue()) ) + if( XIsEmptyString(pNode->GetValue()->GetValue()) ) { // Text Value ++iOffset; @@ -377,7 +377,7 @@ unsigned LoadInternal( XNode *pNode, const RString &xml, RString &sErrorOut, uns } else // Alone child Tag Loaded { - if( XIsEmptyString(pNode->m_pValue->GetValue()) && iOffset < xml.size() && xml[iOffset] != chXMLTagOpen ) + if( XIsEmptyString(pNode->GetValue()->GetValue()) && iOffset < xml.size() && xml[iOffset] != chXMLTagOpen ) { // Text Value unsigned iEnd = xml.find( chXMLTagOpen, iOffset ); @@ -428,7 +428,7 @@ bool GetXMLInternal( const XNode *pNode, RageFileBasic &f, bool bWriteTabs, int WRITE( "' " ); } - if( pNode->m_childs.empty() && pNode->m_pValue->GetValue().empty() ) + if( pNode->m_childs.empty() && pNode->GetValue()->GetValue().empty() ) { // alone tag WRITE( "/>" ); @@ -446,7 +446,7 @@ bool GetXMLInternal( const XNode *pNode, RageFileBasic &f, bool bWriteTabs, int return false; // Text Value - if( !pNode->m_pValue->GetValue().empty() ) + if( !pNode->GetValue()->GetValue().empty() ) { if( !pNode->m_childs.empty() ) { @@ -578,7 +578,7 @@ void XNodeLuaValue::SetValue( unsigned v ) { Lua *L = LUA->Get(); LuaHelpers::Pu namespace { - void CompileXMLNodeValue( Lua *L, const RString &sName, XNodeValue *&pValue, const RString &sFile ) + XNodeValue *CompileXMLNodeValue( Lua *L, const RString &sName, const XNodeValue *pValue, const RString &sFile ) { RString sExpression; pValue->GetValue( sExpression ); @@ -598,9 +598,9 @@ namespace LuaHelpers::RunExpression( L, sExpression, sFile ); } - delete pValue; - pValue = new XNodeLuaValue; - pValue->SetValueFromStack( L ); + XNodeLuaValue *pRet = new XNodeLuaValue; + pRet->SetValueFromStack( L ); + return pRet; } } @@ -617,10 +617,15 @@ void XmlFileUtil::CompileXNodeTree( XNode *pNode, const RString &sFile ) FOREACH_Child( pNode, pChild ) aToCompile.push_back( pChild ); - CompileXMLNodeValue( L, pNode->GetName(), pNode->m_pValue, sFile ); + XNodeValue *pValue = CompileXMLNodeValue( L, pNode->GetName(), pNode->GetValue(), sFile ); + pNode->SetValueFrom( pValue ); FOREACH_Attr( pNode, pAttr ) - CompileXMLNodeValue( L, pAttr->first, pAttr->second, sFile ); + { + pValue = CompileXMLNodeValue( L, pAttr->first, pAttr->second, sFile ); + delete pAttr->second; + pAttr->second = pValue; + } } LUA->Release( L );