本文整理汇总了C++中XMLNode::AppendChild方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLNode::AppendChild方法的具体用法?C++ XMLNode::AppendChild怎么用?C++ XMLNode::AppendChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLNode
的用法示例。
在下文中一共展示了XMLNode::AppendChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Save
Void PlayerTown::Save( XMLNode * outNode ) const
{
Assert( outNode != NULL );
Assert( StringFn->Cmp(outNode->GetTagName(), TEXT("PlayerTown")) == 0 );
const GameParameters * pGameParams = GameplayFn->GetGameParameters();
GChar strBuffer[1024];
// Currencies, scrolls & essences
XMLNode * pCurrenciesNode = XMLDocument::CreateNode( TEXT("Currencies"), true );
XMLNode * pScrollsNode = XMLDocument::CreateNode( TEXT("Scrolls"), true );
XMLNode * pEssencesNode = XMLDocument::CreateNode( TEXT("Essences"), false );
for( UInt i = 0; i < CURRENCY_COUNT; ++i ) {
const GChar * strNameI = pGameParams->CurrencyTypeToString( (CurrencyType)i );
StringFn->FromUInt( strBuffer, m_arrCurrencies[i] );
pCurrenciesNode->CreateAttribute( strNameI, strBuffer );
}
for( UInt i = 0; i < SCROLL_TYPE_COUNT; ++i ) {
const GChar * strNameI = pGameParams->ScrollTypeToString( (ScrollType)i );
StringFn->FromUInt( strBuffer, m_arrScrolls[i] );
pScrollsNode->CreateAttribute( strNameI, strBuffer );
}
for( UInt i = 0; i < MONSTER_ELEMENT_COUNT; ++i ) {
const GChar * strNameI = pGameParams->MonsterElementToString( (MonsterElement)i );
XMLNode * pElementNode = XMLDocument::CreateNode( strNameI, true );
for( UInt j = 0; j < ESSENCE_TYPE_COUNT; ++j ) {
const GChar * strNameJ = pGameParams->EssenceTypeToString( (EssenceType)j );
StringFn->FromUInt( strBuffer, m_arrEssences[i][j] );
pElementNode->CreateAttribute( strNameJ, strBuffer );
}
pEssencesNode->AppendChild( pElementNode );
}
outNode->AppendChild( pCurrenciesNode );
outNode->AppendChild( pScrollsNode );
outNode->AppendChild( pEssencesNode );
// Monster collection & storage
XMLNode * pMonsterCollectionNode = XMLDocument::CreateNode( TEXT("MonsterCollection"), false );
XMLNode * pMonsterStorageNode = XMLDocument::CreateNode( TEXT("MonsterStorage"), false );
StringFn->FromUInt( strBuffer, m_iMonsterCollectionLevel );
pMonsterCollectionNode->CreateAttribute( TEXT("Level"), strBuffer );
StringFn->FromUInt( strBuffer, m_iMonsterStorageLevel );
pMonsterStorageNode->CreateAttribute( TEXT("Level"), strBuffer );
UInt iMonsterCount = m_arrMonsterCollection.Count();
for( UInt i = 0; i < iMonsterCount; ++i ) {
XMLNode * pMonsterInstanceNode = XMLDocument::CreateNode( TEXT("MonsterInstance"), false );
m_arrMonsterCollection[i].Save( pMonsterInstanceNode );
pMonsterCollectionNode->AppendChild( pMonsterInstanceNode );
}
iMonsterCount = m_arrMonsterStorage.Count();
for( UInt i = 0; i < iMonsterCount; ++i ) {
XMLNode * pMonsterInstanceNode = XMLDocument::CreateNode( TEXT("MonsterInstance"), false );
m_arrMonsterStorage[i].Save( pMonsterInstanceNode );
pMonsterStorageNode->AppendChild( pMonsterInstanceNode );
}
outNode->AppendChild( pMonsterCollectionNode );
outNode->AppendChild( pMonsterStorageNode );
// Rune collection & storage
XMLNode * pRuneCollectionNode = XMLDocument::CreateNode( TEXT("RuneCollection"), false );
XMLNode * pRuneStorageNode = XMLDocument::CreateNode( TEXT("RuneStorage"), false );
StringFn->FromUInt( strBuffer, m_iRuneCollectionLevel );
pRuneCollectionNode->CreateAttribute( TEXT("Level"), strBuffer );
StringFn->FromUInt( strBuffer, m_iRuneStorageLevel );
pRuneStorageNode->CreateAttribute( TEXT("Level"), strBuffer );
for( UInt i = 0; i < RUNE_TYPE_COUNT; ++i ) {
UInt iRuneCount = m_arrRuneCollection[i].Count();
for( UInt j = 0; j < iRuneCount; ++j ) {
XMLNode * pRuneNode = XMLDocument::CreateNode( TEXT("Rune"), false );
(m_arrRuneCollection[i])[j].Save( pRuneNode );
pRuneCollectionNode->AppendChild( pRuneNode );
}
iRuneCount = m_arrRuneStorage[i].Count();
for( UInt j = 0; j < iRuneCount; ++j ) {
XMLNode * pRuneNode = XMLDocument::CreateNode( TEXT("Rune"), false );
(m_arrRuneStorage[i])[j].Save( pRuneNode );
pRuneStorageNode->AppendChild( pRuneNode );
}
}
//.........这里部分代码省略.........