当前位置: 首页>>代码示例>>C++>>正文


C++ XMLNode::CreateAttribute方法代码示例

本文整理汇总了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 );
    }
}
开发者ID:Shikifuyin,项目名称:Scarab-Engine,代码行数:36,代码来源:Rune.cpp

示例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 );
        }
    }
//.........这里部分代码省略.........
开发者ID:Shikifuyin,项目名称:Scarab-Engine,代码行数:101,代码来源:PlayerTown.cpp


注:本文中的XMLNode::CreateAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。