本文整理汇总了C++中XNode::GetChild方法的典型用法代码示例。如果您正苦于以下问题:C++ XNode::GetChild方法的具体用法?C++ XNode::GetChild怎么用?C++ XNode::GetChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XNode
的用法示例。
在下文中一共展示了XNode::GetChild方法的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: Load
void TitleSubst::Load(const std::string &filename, const std::string §ion)
{
XNode xml;
if( !XmlFileUtil::LoadFromFileShowErrors(xml,filename) )
{
// LoadFromFile will show its own error
//LOG->Trace("Error opening %s: %s", filename.c_str(), f.GetError().c_str() );
return;
}
XNode *pGroup = xml.GetChild( section );
if( pGroup == nullptr )
{
return;
}
for (auto const *child: *pGroup)
{
if( child == nullptr || child->GetName() != "Translation" )
{
continue;
}
TitleTrans tr;
tr.LoadFromNode( child );
AddTrans(tr);
}
}
示例3: 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;
}
示例4: 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;
}
示例5:
bool
PropertySet::XMLLoad(XNode *pBackupNode)
{
XNode *pPropertiesNode = pBackupNode->GetChild(_T("Properties"));
if (!pPropertiesNode)
return true;
for (int i = 0; i < pPropertiesNode->GetChildCount(); i++)
{
XNode *pPropertyNode = pPropertiesNode->GetChild(i);
String sName = pPropertyNode->name;
String sStringValue = pPropertyNode->GetAttrValue(_T("StringValue"));
int iLongValue = _ttoi(pPropertyNode->GetAttrValue(_T("LongValue")));
std::shared_ptr<Property> pProperty = GetProperty_(sName);
if (pProperty)
{
pProperty->SetStringValue(sStringValue);
pProperty->SetLongValue(iLongValue);
}
}
return true;
}