本文整理汇总了C++中XNode::LoadFromFile方法的典型用法代码示例。如果您正苦于以下问题:C++ XNode::LoadFromFile方法的具体用法?C++ XNode::LoadFromFile怎么用?C++ XNode::LoadFromFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XNode
的用法示例。
在下文中一共展示了XNode::LoadFromFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetXMLData
bool ScreenArcadePatch::GetXMLData( RageFileDriverZip *fZip, CString &sGame, CString &sMessage, int &iRevision )
{
int iError;
RageFileBasic *fXML = fZip->Open( "patch.xml", RageFile::READ, iError );
if( fXML == NULL )
{
STATE_TEXT( "Patch information check failed: could not open patch.xml." );
return false;
}
/* check the actual XML data now */
XNode *pNode = new XNode;
pNode->m_sName = "Patch";
pNode->LoadFromFile( *fXML );
if( !pNode->GetChild("Game") || !pNode->GetChild("Revision") || !pNode->GetChild("Message") )
{
STATE_TEXT( "Patch information check failed: patch.xml is corrupt." );
SAFE_DELETE( pNode );
SAFE_DELETE( fXML );
return false;
}
/* save the patch data */
pNode->GetChild("Revision")->GetValue(iRevision);
sGame = pNode->GetChildValue("Game");
sMessage = pNode->GetChildValue("Message");
SAFE_DELETE( pNode );
SAFE_DELETE( fXML );
return true;
}
示例2: GetNumMachineScores
int DiagnosticsUtil::GetNumMachineScores()
{
// Create the XML Handler and clear it, for practice
XNode *xml = new XNode;
xml->Clear();
// Check for the file existing
if( !IsAFile(STATS_XML_PATH) )
{
LOG->Warn( "There is no Stats.xml file!" );
SAFE_DELETE( xml );
return 0;
}
// Make sure you can read it
if( !xml->LoadFromFile(STATS_XML_PATH) )
{
LOG->Trace( "Stats.xml unloadable!" );
SAFE_DELETE( xml );
return 0;
}
const XNode *pData = xml->GetChild( "SongScores" );
if( pData == NULL )
{
LOG->Warn( "Error loading scores: <SongScores> node missing" );
SAFE_DELETE( xml );
return 0;
}
unsigned int iScoreCount = 0;
// Named here, for LoadFromFile() renames it to "Stats"
xml->m_sName = "SongScores";
// For each pData Child, or the Child in SongScores...
FOREACH_CONST_Child( pData , p )
iScoreCount++;
SAFE_DELETE( xml );
return iScoreCount;
}
示例3: Load
void Transition::Load( CString sBGAniDir )
{
if( IsADirectory(sBGAniDir) && sBGAniDir.Right(1) != "/" )
sBGAniDir += "/";
this->RemoveAllChildren();
m_sprTransition.Load( sBGAniDir );
m_sprTransition->PlayCommand( "On" );
this->AddChild( m_sprTransition );
m_fLengthSeconds = m_sprTransition->GetTweenTimeLeft();
m_State = waiting;
// load sound from file specified by ini, or use the first sound in the directory
if( IsADirectory(sBGAniDir) )
{
IniFile ini;
ini.ReadFile( sBGAniDir+"/BGAnimation.ini" );
CString sSoundFileName;
if( ini.GetValue("BGAnimation","Sound", sSoundFileName) )
{
FixSlashesInPlace( sSoundFileName );
CString sPath = sBGAniDir+sSoundFileName;
CollapsePath( sPath );
m_sound.Load( sPath );
}
else
{
m_sound.Load( sBGAniDir );
}
}
else if( GetExtension(sBGAniDir).CompareNoCase("xml") == 0 )
{
CString sSoundFile;
XNode xml;
xml.LoadFromFile( sBGAniDir );
if( xml.GetAttrValue( "Sound", sSoundFile ) )
m_sound.Load( Dirname(sBGAniDir) + sSoundFile );
}
}
示例4: GetRevision
int DiagnosticsUtil::GetRevision()
{
// default value if a patch value can't be found/loaded
int iRevision = 1;
// Create the XML Handler, and clear it, for practice.
XNode *xml = new XNode;
xml->Clear();
xml->m_sName = "patch";
// if the file is readable and has the proper node, save its value
if( !IsAFile(PATCH_XML_PATH) )
LOG->Warn( "GetRevision(): There is no patch file (patch.xml)" );
else if( !xml->LoadFromFile(PATCH_XML_PATH) )
LOG->Warn( "GetRevision(): Could not load from patch.xml" );
else if( !xml->GetChild("Revision") )
LOG->Warn( "GetRevision(): Revision node missing! (patch.xml)" );
else
iRevision = atoi( xml->GetChild("Revision")->m_sValue );
SAFE_DELETE( xml );
return iRevision;
}
示例5: LoadAllFromDir
bool Profile::LoadAllFromDir( CString sDir, bool bRequireSignature )
{
CHECKPOINT;
LOG->Trace( "Profile::LoadAllFromDir( %s )", sDir.c_str() );
InitAll();
LoadEditableDataFromDir( sDir );
// Read stats.xml
FOR_ONCE
{
CString fn = sDir + STATS_XML;
if( !IsAFile(fn) )
break;
//
// Don't unreasonably large stats.xml files.
//
if( !IsMachine() ) // only check stats coming from the player
{
int iBytes = FILEMAN->GetFileSizeInBytes( fn );
if( iBytes > MAX_PLAYER_STATS_XML_SIZE_BYTES )
{
LOG->Warn( "The file '%s' is unreasonably large. It won't be loaded.", fn.c_str() );
break;
}
}
if( bRequireSignature )
{
CString sStatsXmlSigFile = fn+SIGNATURE_APPEND;
CString sDontShareFile = sDir + DONT_SHARE_SIG;
LOG->Trace( "Verifying don't share signature" );
// verify the stats.xml signature with the "don't share" file
if( !CryptManager::VerifyFileWithFile(sStatsXmlSigFile, sDontShareFile) )
{
LOG->Warn( "The don't share check for '%s' failed. Data will be ignored.", sStatsXmlSigFile.c_str() );
break;
}
LOG->Trace( "Done." );
// verify stats.xml
LOG->Trace( "Verifying stats.xml signature" );
if( !CryptManager::VerifyFileWithFile(fn, sStatsXmlSigFile) )
{
LOG->Warn( "The signature check for '%s' failed. Data will be ignored.", fn.c_str() );
break;
}
LOG->Trace( "Done." );
}
LOG->Trace( "Loading %s", fn.c_str() );
XNode xml;
if( !xml.LoadFromFile( fn ) )
{
LOG->Warn( "Couldn't open file '%s' for reading.", fn.c_str() );
break;
}
LOG->Trace( "Done." );
/* The placeholder stats.xml file has an <html> tag. Don't load it, but don't
* warn about it. */
if( xml.name == "html" )
break;
if( xml.name != "Stats" )
WARN_AND_BREAK_M( xml.name );
LOAD_NODE( GeneralData );
LOAD_NODE( SongScores );
LOAD_NODE( CourseScores );
LOAD_NODE( CategoryScores );
LOAD_NODE( ScreenshotData );
LOAD_NODE( CalorieData );
LOAD_NODE( RecentSongScores );
LOAD_NODE( RecentCourseScores );
}
return true; // FIXME? Investigate what happens if we always return true.
}