vivienneanthony

Untitled

Nov 19th, 2015
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.10 KB | None | 0 0
  1. // set package
  2.     File * m_PackageData = new File(context_, m_pPackageFile, String("GameAssetsData.xml"));
  3.  
  4.     // Read content to memory
  5.     char* retrievedsource=new char[m_GameAssetsDataEntry->size_];
  6.  
  7.     m_PackageData->Read (retrievedsource, m_GameAssetsDataEntry->size_);
  8.  
  9.     // Create new xml document
  10.     pugi::xml_document doc;
  11.  
  12.     // You can use load_buffer_inplace to load document from mutable memory block; the block's lifetime must exceed that of document
  13.     char* buffer = new char(m_GameAssetsDataEntry->size_);
  14.     memcpy(buffer, retrievedsource, m_GameAssetsDataEntry->size_);
  15.  
  16.     // The block can be allocated by any method; the block is modified during parsing
  17.     pugi::xml_parse_result result = doc.load_buffer_inplace(buffer,m_GameAssetsDataEntry->size_);
  18.  
  19.     // Exit if error
  20.     if (result.status!=pugi::status_ok)
  21.     {
  22.         URHO3D_LOGERROR ("Something wrong with file");
  23.  
  24.         return false;
  25.     }
  26.  
  27.     // Get XML root if it exist, if not exit
  28.     pugi::xml_node GameAssetRoot=doc.first_child();
  29.  
  30.     if(!GameAssetRoot)
  31.     {
  32.         return false;
  33.     }
Advertisement
Add Comment
Please, Sign In to add comment