This commit is contained in:
Chris Danford
2005-01-07 02:07:10 +00:00
parent 9b4bb706e6
commit 31ea9c7bc4
4 changed files with 45 additions and 50 deletions
+1 -1
View File
@@ -168,7 +168,7 @@ void HighScoreList::LoadFromNode( const XNode* pNode )
Init();
ASSERT( pNode->name == "HighScoreList" );
for( XNodes::const_iterator child = pNode->childs.begin();
for( vector<XNode*>::const_iterator child = pNode->childs.begin();
child != pNode->childs.end();
child++)
{
+18 -18
View File
@@ -46,7 +46,7 @@ const CString COMMON_XSL = "Common.xsl";
#endif
#define FOREACH_Node( Node, Var ) \
XNodes::const_iterator Var##Iter; \
vector<XNode*>::const_iterator Var##Iter; \
const XNode *Var = NULL; \
for( Var##Iter = Node->childs.begin(); \
(Var##Iter != Node->childs.end() && (Var = *Var##Iter) ), Var##Iter != Node->childs.end(); \
@@ -231,7 +231,7 @@ float Profile::GetSongsActual( StepsType st, Difficulty dc ) const
float fTotalPercents = 0;
// add steps high scores
for( std::map<SongID,HighScoresForASong>::const_iterator i = m_SongHighScores.begin();
for( map<SongID,HighScoresForASong>::const_iterator i = m_SongHighScores.begin();
i != m_SongHighScores.end();
++i )
{
@@ -251,7 +251,7 @@ float Profile::GetSongsActual( StepsType st, Difficulty dc ) const
CHECKPOINT_M( ssprintf("Profile::GetSongsActual: song %s", pSong->GetSongDir().c_str()) );
const HighScoresForASong &hsfas = i->second;
for( std::map<StepsID,HighScoresForASteps>::const_iterator j = hsfas.m_StepsHighScores.begin();
for( map<StepsID,HighScoresForASteps>::const_iterator j = hsfas.m_StepsHighScores.begin();
j != hsfas.m_StepsHighScores.end();
++j )
{
@@ -318,7 +318,7 @@ float Profile::GetCoursesActual( StepsType st, CourseDifficulty cd ) const
float fTotalPercents = 0;
// add course high scores
for( std::map<CourseID,HighScoresForACourse>::const_iterator i = m_CourseHighScores.begin();
for( map<CourseID,HighScoresForACourse>::const_iterator i = m_CourseHighScores.begin();
i != m_CourseHighScores.end();
i++ )
{
@@ -336,7 +336,7 @@ float Profile::GetCoursesActual( StepsType st, CourseDifficulty cd ) const
const HighScoresForACourse &hsfac = i->second;
for( std::map<TrailID,HighScoresForATrail>::const_iterator j = hsfac.m_TrailHighScores.begin();
for( map<TrailID,HighScoresForATrail>::const_iterator j = hsfac.m_TrailHighScores.begin();
j != hsfac.m_TrailHighScores.end();
++j )
{
@@ -390,7 +390,7 @@ int Profile::GetSongNumTimesPlayed( const SongID& songID ) const
return 0;
int iTotalNumTimesPlayed = 0;
for( std::map<StepsID,HighScoresForASteps>::const_iterator j = hsSong->m_StepsHighScores.begin();
for( map<StepsID,HighScoresForASteps>::const_iterator j = hsSong->m_StepsHighScores.begin();
j != hsSong->m_StepsHighScores.end();
j++ )
{
@@ -478,7 +478,7 @@ void Profile::GetGrades( const Song* pSong, StepsType st, int iCounts[NUM_GRADES
FOREACH_Grade(g)
{
std::map<StepsID,HighScoresForASteps>::const_iterator it;
map<StepsID,HighScoresForASteps>::const_iterator it;
for( it = hsSong->m_StepsHighScores.begin(); it != hsSong->m_StepsHighScores.end(); ++it )
{
const StepsID &id = it->first;
@@ -534,7 +534,7 @@ int Profile::GetCourseNumTimesPlayed( const CourseID &courseID ) const
return 0;
int iTotalNumTimesPlayed = 0;
for( std::map<TrailID,HighScoresForATrail>::const_iterator j = hsCourse->m_TrailHighScores.begin();
for( map<TrailID,HighScoresForATrail>::const_iterator j = hsCourse->m_TrailHighScores.begin();
j != hsCourse->m_TrailHighScores.end();
j++ )
{
@@ -1064,7 +1064,7 @@ XNode* Profile::SaveSongScoresCreateNode() const
XNode* pNode = new XNode;
pNode->name = "SongScores";
for( std::map<SongID,HighScoresForASong>::const_iterator i = m_SongHighScores.begin();
for( map<SongID,HighScoresForASong>::const_iterator i = m_SongHighScores.begin();
i != m_SongHighScores.end();
i++ )
{
@@ -1077,7 +1077,7 @@ XNode* Profile::SaveSongScoresCreateNode() const
XNode* pSongNode = pNode->AppendChild( songID.CreateNode() );
for( std::map<StepsID,HighScoresForASteps>::const_iterator j = hsSong.m_StepsHighScores.begin();
for( map<StepsID,HighScoresForASteps>::const_iterator j = hsSong.m_StepsHighScores.begin();
j != hsSong.m_StepsHighScores.end();
j++ )
{
@@ -1147,7 +1147,7 @@ XNode* Profile::SaveCourseScoresCreateNode() const
pNode->name = "CourseScores";
for( std::map<CourseID,HighScoresForACourse>::const_iterator i = m_CourseHighScores.begin();
for( map<CourseID,HighScoresForACourse>::const_iterator i = m_CourseHighScores.begin();
i != m_CourseHighScores.end();
i++ )
{
@@ -1160,7 +1160,7 @@ XNode* Profile::SaveCourseScoresCreateNode() const
XNode* pCourseNode = pNode->AppendChild( courseID.CreateNode() );
for( std::map<TrailID,HighScoresForATrail>::const_iterator j = hsCourse.m_TrailHighScores.begin();
for( map<TrailID,HighScoresForATrail>::const_iterator j = hsCourse.m_TrailHighScores.begin();
j != hsCourse.m_TrailHighScores.end();
j++ )
{
@@ -1261,7 +1261,7 @@ void Profile::LoadCategoryScoresFromNode( const XNode* pNode )
ASSERT( pNode->name == "CategoryScores" );
for( XNodes::const_iterator stepsType = pNode->childs.begin();
for( vector<XNode*>::const_iterator stepsType = pNode->childs.begin();
stepsType != pNode->childs.end();
stepsType++ )
{
@@ -1275,7 +1275,7 @@ void Profile::LoadCategoryScoresFromNode( const XNode* pNode )
if( st == STEPS_TYPE_INVALID )
WARN_AND_CONTINUE_M( str );
for( XNodes::iterator radarCategory = (*stepsType)->childs.begin();
for( vector<XNode*>::iterator radarCategory = (*stepsType)->childs.begin();
radarCategory != (*stepsType)->childs.end();
radarCategory++ )
{
@@ -1442,7 +1442,7 @@ void Profile::LoadRecentSongScoresFromNode( const XNode* pNode )
CHECKPOINT;
ASSERT( pNode->name == "RecentSongScores" );
for( XNodes::const_iterator p = pNode->childs.begin();
for( vector<XNode*>::const_iterator p = pNode->childs.begin();
p != pNode->childs.end();
p++ )
{
@@ -1519,7 +1519,7 @@ void Profile::LoadRecentCourseScoresFromNode( const XNode* pNode )
CHECKPOINT;
ASSERT( pNode->name == "RecentCourseScores" );
for( XNodes::const_iterator p = pNode->childs.begin();
for( vector<XNode*>::const_iterator p = pNode->childs.begin();
p != pNode->childs.end();
p++ )
{
@@ -1566,7 +1566,7 @@ void Profile::AddCourseRecentScore( const Course* pCourse, const Trail* pTrail,
const Profile::HighScoresForASong *Profile::GetHighScoresForASong( const SongID& songID ) const
{
std::map<SongID,HighScoresForASong>::const_iterator it;
map<SongID,HighScoresForASong>::const_iterator it;
it = m_SongHighScores.find( songID );
if( it == m_SongHighScores.end() )
return NULL;
@@ -1575,7 +1575,7 @@ const Profile::HighScoresForASong *Profile::GetHighScoresForASong( const SongID&
const Profile::HighScoresForACourse *Profile::GetHighScoresForACourse( const CourseID& courseID ) const
{
std::map<CourseID,HighScoresForACourse>::const_iterator it;
map<CourseID,HighScoresForACourse>::const_iterator it;
it = m_CourseHighScores.find( courseID );
if( it == m_CourseHighScores.end() )
return NULL;
+16 -16
View File
@@ -661,9 +661,9 @@ XAttr *XNode::GetAttr( const char* attrname )
// Coder Date Desc
// bro 2002-10-29
//========================================================
XAttrs XNode::GetAttrs( const char* name )
vector<XAttr*> XNode::GetAttrs( const char* name )
{
XAttrs attrs;
vector<XAttr*> attrs;
for( unsigned i = 0 ; i < attrs.size(); i++ )
{
XAttr *attr = attrs[i];
@@ -691,7 +691,7 @@ const char* XNode::GetAttrValue( const char* attrname )
return attr ? (const char*)attr->value : NULL;
}
XNodes XNode::GetChilds()
vector<XNode*> XNode::GetChilds()
{
return childs;
}
@@ -705,9 +705,9 @@ XNodes XNode::GetChilds()
// Coder Date Desc
// bro 2002-10-29
//========================================================
XNodes XNode::GetChilds( const char* name )
vector<XNode*> XNode::GetChilds( const char* name )
{
XNodes nodes;
vector<XNode*> nodes;
for( unsigned i = 0 ; i < childs.size(); i++ )
{
XNode *node = childs[i];
@@ -824,9 +824,9 @@ const char* XNode::GetChildAttrValue( const char* name, const char* attrname )
// Coder Date Desc
// bro 2002-10-29
//========================================================
XNodes::iterator XNode::GetChildIterator( XNode *node )
vector<XNode*>::iterator XNode::GetChildIterator( XNode *node )
{
XNodes::iterator it = childs.begin();
vector<XNode*>::iterator it = childs.begin();
for( ; it != childs.end() ; ++(it) )
{
if( *it == node )
@@ -877,7 +877,7 @@ XNode *XNode::AppendChild( XNode *node )
//========================================================
bool XNode::RemoveChild( XNode *node )
{
XNodes::iterator it = GetChildIterator( node );
vector<XNode*>::iterator it = GetChildIterator( node );
if( it != childs.end() )
{
delete *it;
@@ -907,14 +907,14 @@ XAttr *XNode::GetAttr( int i )
// Name : GetAttrIterator
// Desc : get attribute iterator
// Param :
// Return : std::vector<XAttr*>::iterator
// Return : vector<XAttr*>::iterator
//--------------------------------------------------------
// Coder Date Desc
// bro 2002-10-29
//========================================================
XAttrs::iterator XNode::GetAttrIterator( XAttr *attr )
vector<XAttr*>::iterator XNode::GetAttrIterator( XAttr *attr )
{
XAttrs::iterator it = attrs.begin();
vector<XAttr*>::iterator it = attrs.begin();
for( ; it != attrs.end() ; ++(it) )
{
if( *it == attr )
@@ -950,7 +950,7 @@ XAttr *XNode::AppendAttr( XAttr *attr )
//========================================================
bool XNode::RemoveAttr( XAttr *attr )
{
XAttrs::iterator it = GetAttrIterator( attr );
vector<XAttr*>::iterator it = GetAttrIterator( attr );
if( it != attrs.end() )
{
delete *it;
@@ -1023,7 +1023,7 @@ XAttr *XNode::AppendAttr( const char* name, unsigned value ) { return AppendAttr
//========================================================
XNode *XNode::DetachChild( XNode *node )
{
XNodes::iterator it = GetChildIterator( node );
vector<XNode*>::iterator it = GetChildIterator( node );
if( it != childs.end() )
{
childs.erase( it );
@@ -1043,7 +1043,7 @@ XNode *XNode::DetachChild( XNode *node )
//========================================================
XAttr *XNode::DetachAttr( XAttr *attr )
{
XAttrs::iterator it = GetAttrIterator( attr );
vector<XAttr*>::iterator it = GetAttrIterator( attr );
if( it != attrs.end() )
{
attrs.erase( it );
@@ -1186,7 +1186,7 @@ CString XEntity2Ref( const char* str )
return entityDefault.Entity2Ref( str );
}
bool XNode::LoadFromFile( CString sFile, PARSEINFO *pi )
bool XNode::LoadFromFile( const CString &sFile, PARSEINFO *pi )
{
RageFile f;
if( !f.Open(sFile, RageFile::READ) )
@@ -1223,7 +1223,7 @@ bool XNode::SaveToFile( RageFileBasic &f, DISP_OPT *opt )
return true;
}
bool XNode::SaveToFile( CString sFile, DISP_OPT *opt )
bool XNode::SaveToFile( const CString &sFile, DISP_OPT *opt )
{
RageFile f;
if( !f.Open(sFile, RageFile::WRITE) )
+10 -15
View File
@@ -24,9 +24,7 @@ struct DateTime;
class RageFileBasic;
struct XAttr;
typedef std::vector<XAttr*> XAttrs;
struct XNode;
typedef std::vector<XNode*> XNodes;
// Entity Encode/Decode Support
struct XENTITY
@@ -36,7 +34,7 @@ struct XENTITY
int ref_len; // entity reference length
};
struct XENTITYS : public std::vector<XENTITY>
struct XENTITYS : public vector<XENTITY>
{
XENTITY *GetEntity( int entity );
XENTITY *GetEntity( char* entity );
@@ -140,16 +138,16 @@ struct XNode
// internal variables
XNode *parent; // parent node
XNodes childs; // child node
XAttrs attrs; // attributes
vector<XNode*> childs; // child node
vector<XAttr*> attrs; // attributes
// Load/Save XML
char* Load( const char* pszXml, PARSEINFO *pi = &piDefault );
char* LoadAttributes( const char* pszAttrs, PARSEINFO *pi = &piDefault );
bool GetXML( RageFileBasic &f, DISP_OPT *opt = &optDefault );
bool LoadFromFile( CString sFile, PARSEINFO *pi = &piDefault );
bool SaveToFile( CString sFile, DISP_OPT *opt = &optDefault );
bool LoadFromFile( const CString &sFile, PARSEINFO *pi = &piDefault );
bool SaveToFile( const CString &sFile, DISP_OPT *opt = &optDefault );
bool SaveToFile( RageFileBasic &f, DISP_OPT *opt = &optDefault );
// in own attribute list
@@ -162,7 +160,7 @@ struct XNode
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; }
XAttrs GetAttrs( const char* name );
vector<XAttr*> GetAttrs( const char* name );
// in one level child nodes
const XNode *GetChild( const char* name ) const;
@@ -174,8 +172,8 @@ struct XNode
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; }
XNodes GetChilds( const char* name );
XNodes GetChilds();
vector<XNode*> GetChilds( const char* name );
vector<XNode*> GetChilds();
XAttr *GetChildAttr( const char* name, const char* attrname );
const char* GetChildAttrValue( const char* name, const char* attrname );
@@ -183,7 +181,7 @@ struct XNode
// modify DOM
int GetChildCount();
XNode *GetChild( int i );
XNodes::iterator GetChildIterator( XNode *node );
vector<XNode*>::iterator GetChildIterator( XNode *node );
XNode *CreateNode( const char* name = NULL, const char* value = NULL );
XNode *AppendChild( const char* name = NULL, const char* value = NULL );
XNode *AppendChild( const char* name, float value );
@@ -196,7 +194,7 @@ struct XNode
XAttr *GetAttr( int i );
XAttrs::iterator GetAttrIterator( XAttr *node );
vector<XAttr*>::iterator GetAttrIterator( XAttr *node );
XAttr *CreateAttr( const char* anem = NULL, const char* value = NULL );
XAttr *AppendAttr( const char* name = NULL, const char* value = NULL );
XAttr *AppendAttr( const char* name, float value );
@@ -207,9 +205,6 @@ struct XNode
bool RemoveAttr( XAttr *attr );
XAttr *DetachAttr( XAttr *attr );
// operator overloads
XNode* operator [] ( int i ) { return GetChild(i); }
XNode() { parent = NULL; }
~XNode();