本文整理汇总了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;
}