本文整理汇总了C++中XMLNode::CreateAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLNode::CreateAttribute方法的具体用法?C++ XMLNode::CreateAttribute怎么用?C++ XMLNode::CreateAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLNode
的用法示例。
在下文中一共展示了XMLNode::CreateAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Save
Void Rune::Save( XMLNode * outNode ) const
{
Assert( m_iType != RUNE_TYPE_COUNT );
Assert( outNode != NULL );
Assert( StringFn->Cmp(outNode->GetTagName(), TEXT("Rune")) == 0 );
const GameParameters * pGameParams = GameplayFn->GetGameParameters();
GChar strBuffer[1024];
const GChar * strValue;
strValue = pGameParams->RuneTypeToString( m_iType );
outNode->CreateAttribute( TEXT("Type"), strValue );
StringFn->FromUInt( strBuffer, m_iSlot );
outNode->CreateAttribute( TEXT("Slot"), strBuffer );
StringFn->FromUInt( strBuffer, m_iRank );
outNode->CreateAttribute( TEXT("Rank"), strBuffer );
StringFn->FromUInt( strBuffer, m_iLevel );
outNode->CreateAttribute( TEXT("Level"), strBuffer );
Assert( m_arrBonuses[RUNE_STAT_PRIMARY].iStat != MONSTER_STAT_COUNT );
for( UInt i = 0; i < RUNE_STAT_COUNT; ++i ) {
if ( m_arrBonuses[i].iStat == MONSTER_STAT_COUNT )
continue;
const GChar * strNameI = pGameParams->RuneStatisticToString( (RuneStatistic)i );
XMLNode * pStatBonusNode = XMLDocument::CreateNode( strNameI, true );
strValue = pGameParams->MonsterStatisticToString( m_arrBonuses[i].iStat );
pStatBonusNode->CreateAttribute( TEXT("Stat"), strValue );
StringFn->FromUInt( strBuffer, m_arrBonuses[i].bIsRatio ? 1 : 0 );
pStatBonusNode->CreateAttribute( TEXT("IsRatio"), strBuffer );
outNode->AppendChild( pStatBonusNode );
}
}
示例2: 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 );
}
}
//.........这里部分代码省略.........