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


C++ TiXmlDocument::LoadData方法代码示例

本文整理汇总了C++中TiXmlDocument::LoadData方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlDocument::LoadData方法的具体用法?C++ TiXmlDocument::LoadData怎么用?C++ TiXmlDocument::LoadData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TiXmlDocument的用法示例。


在下文中一共展示了TiXmlDocument::LoadData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LoadShopList

	bool CConfiger::LoadShopList( const char *file )
	{
		CRFile *prfile = rfOpen( file );
		if( prfile == NULL )
		{
			PutoutLog( LOG_FILE, LT_ERROR, "Load file %s failed.", file );
			return false;
		}

		TiXmlDocument doc;
		if( !doc.LoadData( prfile->GetData(), prfile->GetDatalen() ) )
		{
			PutoutLog( LOG_FILE, LT_ERROR, "Parse %s failed, invalid xml format.", file );
			rfClose( prfile );
			return false;
		}
		rfClose( prfile );
		TiXmlElement *root = doc.RootElement();
		{
			// global config
			TiXmlElement *node = root->FirstChildElement( "Global" );
			QUERY_NUM( "goods_update_interval", m_GlobalCfg.uGoodsUpdateInter, node, unsigned long );
			QUERY_NUM( "buy_count", m_GlobalCfg.lBuyCount, node, long );
			QUERY_NUM( "enable", m_GlobalCfg.lEnable, node, long );
			QUERY_NUM( "player_buy_count", m_GlobalCfg.lPlayerBuyCount, node, long );

			char strCoinGoods[64];
			QUERY_STR( "coin_goods", strCoinGoods, node );
			m_GlobalCfg.lCoinGoodsIndex = CGoodsFactory::QueryGoodsIDByOriginalName( strCoinGoods );
		}
		{
			// shop list
			TiXmlElement *shoplist_node = root->FirstChildElement( "ShopList" );
			for( TiXmlElement *shop_node = shoplist_node->FirstChildElement();
				shop_node != NULL; shop_node = shop_node->NextSiblingElement() )
			{
				long id;
				QUERY_NUM( "id", id, shop_node, long );
				if( m_ShopTable.find( id ) != m_ShopTable.end() )
				{
					// more than 1 shop with the same id, ignore it.
					PutoutLog( LOG_FILE, LT_WARNING, "More than 1 shop with the same id [%d].", id );
					continue;
				}
				Shop shop;
				QUERY_STR( "npc_orig_name", shop.npcOrigName, shop_node );
				SellGoodsListT *pSellGoodsList = new SellGoodsListT();
				shop.SellList = pSellGoodsList;
				for( TiXmlElement *goods_node = shop_node->FirstChildElement();
					goods_node != NULL; goods_node = goods_node->NextSiblingElement() )
				{
					SellGoods goods;
					char strOrigName[64];
					QUERY_STR( "orig_name", strOrigName, goods_node );
					goods.lIndex = CGoodsFactory::QueryGoodsIDByOriginalName( strOrigName );
					pSellGoodsList->push_back( goods );
				}
				m_ShopTable.insert( std::make_pair( id, shop ) );
			}
		}
		return true;
	}
开发者ID:ueverything,项目名称:mmo-resourse,代码行数:62,代码来源:Configer.cpp


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