diff --git a/stepmania/src/XmlFile.cpp b/stepmania/src/XmlFile.cpp index a1445ee722..514c3ec192 100644 --- a/stepmania/src/XmlFile.cpp +++ b/stepmania/src/XmlFile.cpp @@ -632,14 +632,6 @@ XAttr *XNode::GetAttr( const CString &attrname ) return NULL; } -// Desc : get attribute with attribute name, return its value -const char* XNode::GetAttrValue( const CString &attrname ) -{ - XAttr *attr = GetAttr( attrname ); - return attr ? (const char*)attr->m_sValue : NULL; -} - - // get child node count int XNode::GetChildCount() const { @@ -648,9 +640,9 @@ int XNode::GetChildCount() const // Desc : Find child with name and return child // Return : NULL return if no child. -XNode *XNode::GetChild( const char* name ) +XNode *XNode::GetChild( const CString &sName ) { - multimap::iterator it = m_childs.find( name ); + multimap::iterator it = m_childs.find( sName ); if( it != m_childs.end() ) { DEBUG_ASSERT( name == it->second->m_sName ); @@ -659,9 +651,9 @@ XNode *XNode::GetChild( const char* name ) return NULL; } -const XNode *XNode::GetChild( const char* name ) const +const XNode *XNode::GetChild( const CString &sName ) const { - multimap::const_iterator it = m_childs.find( name ); + multimap::const_iterator it = m_childs.find( sName ); if( it != m_childs.end() ) { DEBUG_ASSERT( name == it->second->m_sName ); @@ -670,32 +662,17 @@ const XNode *XNode::GetChild( const char* name ) const return NULL; } -// Desc : Find child with name and return child's value -// Return : NULL return if no child. -const char* XNode::GetChildValue( const char* name ) -{ - XNode *node = GetChild( name ); - return (node != NULL)? (const char*)node->m_sValue : NULL; -} - XAttr *XNode::GetChildAttr( const char* name, const char* attrname ) { XNode *node = GetChild(name); return node ? node->GetAttr(attrname) : NULL; } -const char* XNode::GetChildAttrValue( const char* name, const char* attrname ) -{ - XAttr *attr = GetChildAttr( name, attrname ); - return attr ? (const char*)attr->m_sValue : NULL; -} - - -XNode *XNode::AppendChild( const char* name, const char* value ) { XNode *p = new XNode; p->m_sName = name; p->m_sValue = value; return AppendChild( p ); } -XNode *XNode::AppendChild( const char* name, float value ) { XNode *p = new XNode; p->m_sName = name; p->SetValue( value ); return AppendChild( p ); } -XNode *XNode::AppendChild( const char* name, int value ) { XNode *p = new XNode; p->m_sName = name; p->SetValue( value ); return AppendChild( p ); } -XNode *XNode::AppendChild( const char* name, unsigned value ) { XNode *p = new XNode; p->m_sName = name; p->SetValue( value ); return AppendChild( p ); } -XNode *XNode::AppendChild( const char* name, const DateTime &value ) { XNode *p = new XNode; p->m_sName = name; p->SetValue( value ); return AppendChild( p ); } +XNode *XNode::AppendChild( const CString &sName, const char* value ) { XNode *p = new XNode; p->m_sName = sName; p->m_sValue = value; return AppendChild( p ); } +XNode *XNode::AppendChild( const CString &sName, float value ) { XNode *p = new XNode; p->m_sName = sName; p->SetValue( value ); return AppendChild( p ); } +XNode *XNode::AppendChild( const CString &sName, int value ) { XNode *p = new XNode; p->m_sName = sName; p->SetValue( value ); return AppendChild( p ); } +XNode *XNode::AppendChild( const CString &sName, unsigned value ) { XNode *p = new XNode; p->m_sName = sName; p->SetValue( value ); return AppendChild( p ); } +XNode *XNode::AppendChild( const CString &sName, const DateTime &value ) { XNode *p = new XNode; p->m_sName = sName; p->SetValue( value ); return AppendChild( p ); } XNode *XNode::AppendChild( XNode *node ) { @@ -743,26 +720,25 @@ bool XNode::RemoveAttr( XAttr *attr ) return false; } -XAttr *XNode::AppendAttr( const char* name /*= NULL*/, const char* value /*= NULL*/ ) +XAttr *XNode::AppendAttr( const CString &sName, const CString &sValue ) { - XAttr *attr = new XAttr; - attr->m_sName = name; - attr->m_sValue = value; - return AppendAttr( attr ); + XAttr *pAttr = new XAttr; + pAttr->m_sName = sName; + pAttr->m_sValue = sValue; + return AppendAttr( pAttr ); } -XAttr *XNode::AppendAttr( const char* name, float value ){ return AppendAttr(name,ssprintf("%f",value)); } -XAttr *XNode::AppendAttr( const char* name, int value ) { return AppendAttr(name,ssprintf("%d",value)); } -XAttr *XNode::AppendAttr( const char* name, unsigned value ) { return AppendAttr(name,ssprintf("%u",value)); } +XAttr *XNode::AppendAttr( const CString &sName, float value ){ return AppendAttr(sName,ssprintf("%f",value)); } +XAttr *XNode::AppendAttr( const CString &sName, int value ) { return AppendAttr(sName,ssprintf("%d",value)); } +XAttr *XNode::AppendAttr( const CString &sName, unsigned value ) { return AppendAttr(sName,ssprintf("%u",value)); } -// Desc : add attribute -void XNode::SetAttrValue( const char* name, const char* value ) +void XNode::SetAttrValue( const CString &sName, const CString &sValue ) { - XAttr* pAttr = GetAttr( name ); + XAttr* pAttr = GetAttr( sName ); if( pAttr ) - pAttr->m_sValue = value; + pAttr->m_sValue = sValue; else - AppendAttr( name, value ); + AppendAttr( sName, sValue ); } diff --git a/stepmania/src/XmlFile.h b/stepmania/src/XmlFile.h index 0144e0e30b..3ea174b346 100644 --- a/stepmania/src/XmlFile.h +++ b/stepmania/src/XmlFile.h @@ -177,50 +177,47 @@ struct XNode bool SaveToFile( RageFileBasic &f, DISP_OPT *opt ) const; // in own attribute list - const XAttr *GetAttr( const CString &attrname ) const; - XAttr *GetAttr( const CString &attrname ); - const char* GetAttrValue( const CString &attrname ); - bool GetAttrValue( const char* name, CString &out ) const { const XAttr* pAttr=GetAttr(name); if(pAttr==NULL) return false; pAttr->GetValue(out); return true; } - bool GetAttrValue( const char* name, int &out ) const { const XAttr* pAttr=GetAttr(name); if(pAttr==NULL) return false; pAttr->GetValue(out); return true; } - bool GetAttrValue( const char* name, float &out ) const { const XAttr* pAttr=GetAttr(name); if(pAttr==NULL) return false; pAttr->GetValue(out); return true; } - bool GetAttrValue( const char* name, bool &out ) const { const XAttr* pAttr=GetAttr(name); if(pAttr==NULL) return false; pAttr->GetValue(out); return true; } - bool GetAttrValue( const char* name, unsigned &out ) const { const XAttr* pAttr=GetAttr(name); if(pAttr==NULL) return false; pAttr->GetValue(out); return true; } - bool GetAttrValue( const char* name, DateTime &out ) const { const XAttr* pAttr=GetAttr(name); if(pAttr==NULL) return false; pAttr->GetValue(out); return true; } + const XAttr *GetAttr( const CString &sAttrName ) const; + XAttr *GetAttr( const CString &sAttrName ); + bool GetAttrValue( const CString &sName, CString &out ) const { const XAttr* pAttr=GetAttr(sName); if(pAttr==NULL) return false; pAttr->GetValue(out); return true; } + bool GetAttrValue( const CString &sName, int &out ) const { const XAttr* pAttr=GetAttr(sName); if(pAttr==NULL) return false; pAttr->GetValue(out); return true; } + bool GetAttrValue( const CString &sName, float &out ) const { const XAttr* pAttr=GetAttr(sName); if(pAttr==NULL) return false; pAttr->GetValue(out); return true; } + bool GetAttrValue( const CString &sName, bool &out ) const { const XAttr* pAttr=GetAttr(sName); if(pAttr==NULL) return false; pAttr->GetValue(out); return true; } + bool GetAttrValue( const CString &sName, unsigned &out ) const { const XAttr* pAttr=GetAttr(sName); if(pAttr==NULL) return false; pAttr->GetValue(out); return true; } + bool GetAttrValue( const CString &sName, DateTime &out ) const { const XAttr* pAttr=GetAttr(sName); if(pAttr==NULL) return false; pAttr->GetValue(out); return true; } // in one level child nodes - const XNode *GetChild( const char* m_sName ) const; - XNode *GetChild( const char* m_sName ); - const char* GetChildValue( const char* m_sName ); - bool GetChildValue( const char* name, CString &out ) const { const XNode* pChild=GetChild(name); if(pChild==NULL) return false; pChild->GetValue(out); return true; } - bool GetChildValue( const char* name, int &out ) const { const XNode* pChild=GetChild(name); if(pChild==NULL) return false; pChild->GetValue(out); return true; } - bool GetChildValue( const char* name, float &out ) const { const XNode* pChild=GetChild(name); if(pChild==NULL) return false; pChild->GetValue(out); return true; } - bool GetChildValue( const char* name, bool &out ) const { const XNode* pChild=GetChild(name); if(pChild==NULL) return false; pChild->GetValue(out); return true; } - bool GetChildValue( const char* name, unsigned &out ) const { const XNode* pChild=GetChild(name); if(pChild==NULL) return false; pChild->GetValue(out); return true; } - bool GetChildValue( const char* name, DateTime &out ) const { const XNode* pChild=GetChild(name); if(pChild==NULL) return false; pChild->GetValue(out); return true; } + const XNode *GetChild( const CString &sName ) const; + XNode *GetChild( const CString &sName ); + bool GetChildValue( const CString &sName, CString &out ) const { const XNode* pChild=GetChild(sName); if(pChild==NULL) return false; pChild->GetValue(out); return true; } + bool GetChildValue( const CString &sName, int &out ) const { const XNode* pChild=GetChild(sName); if(pChild==NULL) return false; pChild->GetValue(out); return true; } + bool GetChildValue( const CString &sName, float &out ) const { const XNode* pChild=GetChild(sName); if(pChild==NULL) return false; pChild->GetValue(out); return true; } + bool GetChildValue( const CString &sName, bool &out ) const { const XNode* pChild=GetChild(sName); if(pChild==NULL) return false; pChild->GetValue(out); return true; } + bool GetChildValue( const CString &sName, unsigned &out ) const { const XNode* pChild=GetChild(sName); if(pChild==NULL) return false; pChild->GetValue(out); return true; } + bool GetChildValue( const CString &sName, DateTime &out ) const { const XNode* pChild=GetChild(sName); if(pChild==NULL) return false; pChild->GetValue(out); return true; } XAttr *GetChildAttr( const char* name, const char* attrname ); - const char* GetChildAttrValue( const char* name, const char* attrname ); // modify DOM int GetChildCount() const; - XNode *AppendChild( const char* m_sName = NULL, const char* value = NULL ); - XNode *AppendChild( const char* m_sName, float value ); - XNode *AppendChild( const char* m_sName, int value ); - XNode *AppendChild( const char* m_sName, unsigned value ); - XNode *AppendChild( const char* m_sName, const DateTime &value ); + XNode *AppendChild( const CString &sName = "", const char* value = "" ); + XNode *AppendChild( const CString &sName, float value ); + XNode *AppendChild( const CString &sName, int value ); + XNode *AppendChild( const CString &sName, unsigned value ); + XNode *AppendChild( const CString &sName, const DateTime &value ); XNode *AppendChild( XNode *node ); bool RemoveChild( XNode *node ); - XAttr *AppendAttr( const char* m_sName = NULL, const char* value = NULL ); - XAttr *AppendAttr( const char* m_sName, float value ); - XAttr *AppendAttr( const char* m_sName, int value ); - XAttr *AppendAttr( const char* m_sName, unsigned value ); - XAttr *AppendAttr( const char* m_sName, const DateTime &value ); - XAttr *AppendAttr( XAttr *attr ); - bool RemoveAttr( XAttr *attr ); + XAttr *AppendAttr( const CString &sName = "", const CString &sValue = "" ); + XAttr *AppendAttr( const CString &sName, float value ); + XAttr *AppendAttr( const CString &sName, int value ); + XAttr *AppendAttr( const CString &sName, unsigned value ); + XAttr *AppendAttr( const CString &sName, const DateTime &value ); + XAttr *AppendAttr( XAttr *pAttr ); + bool RemoveAttr( XAttr *pAttr ); // creates the attribute if it doesn't already exist - void SetAttrValue( const char* m_sName, const char* value ); + void SetAttrValue( const CString &sName, const CString &sValue ); XNode() { } ~XNode();