allow removing without deleting (detaching)

This commit is contained in:
Glenn Maynard
2006-10-02 06:36:07 +00:00
parent 6db05d676a
commit 30d8823a44
2 changed files with 4 additions and 3 deletions
+2 -1
View File
@@ -103,12 +103,13 @@ XNode *XNode::AppendChild( XNode *node )
} }
// detach node and delete object // detach node and delete object
bool XNode::RemoveChild( XNode *node ) bool XNode::RemoveChild( XNode *node, bool bDelete )
{ {
FOREACHMM( RString, XNode*, m_childs, p ) FOREACHMM( RString, XNode*, m_childs, p )
{ {
if( p->second == node ) if( p->second == node )
{ {
if( bDelete )
SAFE_DELETE( p->second ); SAFE_DELETE( p->second );
m_childs.erase( p ); m_childs.erase( p );
return true; return true;
+1 -1
View File
@@ -81,7 +81,7 @@ public:
XNode *AppendChild( const RString &sName, T value ) { XNode *p=new XNode(sName); p->SetValue(value); return AppendChild(p); } XNode *AppendChild( const RString &sName, T value ) { XNode *p=new XNode(sName); p->SetValue(value); return AppendChild(p); }
XNode *AppendChild( const RString &sName ) { XNode *p=new XNode(sName); return AppendChild(p); } XNode *AppendChild( const RString &sName ) { XNode *p=new XNode(sName); return AppendChild(p); }
XNode *AppendChild( XNode *node ); XNode *AppendChild( XNode *node );
bool RemoveChild( XNode *node ); bool RemoveChild( XNode *node, bool bDelete = true );
void AppendAttr( const RString &sName, const RString &sValue = RString() ); void AppendAttr( const RString &sName, const RString &sValue = RString() );
void AppendAttr( const RString &sName, float value ); void AppendAttr( const RString &sName, float value );