diff --git a/stepmania/src/XmlFile.cpp b/stepmania/src/XmlFile.cpp index a3bda8b48e..041a4664ab 100644 --- a/stepmania/src/XmlFile.cpp +++ b/stepmania/src/XmlFile.cpp @@ -650,6 +650,20 @@ CString _tagXMLNode::GetXML( LPDISP_OPT opt /*= &optDefault*/ ) // Coder Date Desc // bro 2002-10-29 //======================================================== +const LPXAttr _tagXMLNode::GetAttr( LPCTSTR attrname ) const +{ + for( unsigned i = 0 ; i < attrs.size(); i++ ) + { + LPXAttr attr = attrs[i]; + if( attr ) + { + if( attr->name == attrname ) + return attr; + } + } + return NULL; +} + LPXAttr _tagXMLNode::GetAttr( LPCTSTR attrname ) { for( unsigned i = 0 ; i < attrs.size(); i++ ) diff --git a/stepmania/src/XmlFile.h b/stepmania/src/XmlFile.h index 8b64478374..abb4d9b48a 100644 --- a/stepmania/src/XmlFile.h +++ b/stepmania/src/XmlFile.h @@ -111,6 +111,10 @@ typedef struct _tagXMLAttr { CString name; CString value; + void GetValue(CString &out) const { out = value; } + void GetValue(int &out) const { out = atoi(value); } + void GetValue(float &out) const { out = (float) atof(value); } + void GetValue(bool &out) const { out = atoi(value) != 0; } _tagXMLNode* parent; @@ -142,8 +146,13 @@ typedef struct _tagXMLNode bool SaveToFile( CString sFile, LPDISP_OPT opt = &optDefault ); // in own attribute list + const LPXAttr GetAttr( LPCTSTR attrname ) const; LPXAttr GetAttr( LPCTSTR attrname ); LPCTSTR GetAttrValue( LPCTSTR attrname ); + bool GetAttrValue(LPCTSTR name,CString &out) const { const XAttr* pAttr=GetAttr(name); if(pAttr==NULL) return false; pAttr->GetValue(out); return true; } + bool GetAttrValue(LPCTSTR name,int &out) const { const XAttr* pAttr=GetAttr(name); if(pAttr==NULL) return false; pAttr->GetValue(out); return true; } + bool GetAttrValue(LPCTSTR name,float &out) const { const XAttr* pAttr=GetAttr(name); if(pAttr==NULL) return false; pAttr->GetValue(out); return true; } + bool GetAttrValue(LPCTSTR name,bool &out) const { const XAttr* pAttr=GetAttr(name); if(pAttr==NULL) return false; pAttr->GetValue(out); return true; } XAttrs GetAttrs( LPCTSTR name ); // in one level child nodes