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


C++ DataBuffer::getNbrBytesLeft方法代码示例

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


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

示例1: MapModuleNotice

bool
MapModuleNoticeContainer::load( DataBuffer& dataBuf, uint32 mapSet )
{
   dataBuf.readNextLong(); // old totalLength
   dataBuf.readNextLong(); // nbrMaps

   mc2dbg << "[MMNC]: Using new kind of index.db" << endl;
   // Format on disk begins with two 32-bit words with zeroes.
   // They should already have been read by load.
   // We should really implement version 0 here as well so that
   // we can remove the MapModuleObjVector.
   // Then comes length and version

   uint32 totalLength = dataBuf.readNextLong(); // length
   uint32 version  = dataBuf.readNextLong();
   uint32 nbrItems = dataBuf.readNextLong();

   if (dataBuf.getNbrBytesLeft() == 0) {
      // we must have some bytes left
      // TODO: check if nbr bytes left is at least 
      // = length * something...
      return false;
   }

   // Reset the internal structs.
   deleteAllObjs();
   
   // Version should only be 1 now.
   for ( uint32 i = 0; i < nbrItems; ++i ) {
      MapModuleNotice* notice = 
         new MapModuleNotice( &dataBuf, version, mapSet );
      // Add the notice to the appropriate vectors and maps.
      addNotice( notice );
      mc2dbg << "[MMNC]: Added MapModuleNotice for "
             << notice->getMapName() << endl;
   }

   // Read the map hierarchy
   m_mapTree.load( &dataBuf, mapSet );

   // Read the regions
   int nbrRegions = dataBuf.readNextLong();
   m_regions.clear();

   mc2dbg << "[MMNC]: Number of top regions:" << nbrRegions << endl;

   for ( int i = 0; i < nbrRegions; ++i ) {

      MapTopRegion* region = new MapTopRegion();
      region->load( &dataBuf, mapSet );

      m_regions[ region->getID() ] = region;
      const char* name = region->getName( LangTypes::english );

      if ( name == NULL ) {
         name = "NULL";
      }

      mc2dbg << "[MMNC]: Added Top Region ID:" << region->getID()
             << " name: " << name << endl;
   }
   
   // Read the region hierarchy
   m_regionTree.load( &dataBuf );

   // Read map supplier coverage data.
   mc2dbg8 << "Curr offset: " << dataBuf.getCurrentOffset()
           << " total length " << totalLength << endl;
   if (dataBuf.getCurrentOffset() < totalLength+12 ){
      mc2dbg << "[MMNC]: Loading map supplier coverage." << endl;
      loadMapSupCoverage( &dataBuf );
      mc2dbg << "[MMNC]: Done loading map supplier coverage." << endl;
   }
   else {
      mc2dbg << "[MMNC]: Not loading map supplier coverage." << endl;
   }

#ifdef DEBUG_LEVEL_1
   //
   // debug
   //
   for(uint32 i = 0; i < m_allNotices.size(); ++i ) {
      mc2dbg << "Overview maps for " << m_allNotices[i]->getMapID()
             << endl;
      vector<uint32> overviewIDs;
      m_mapTree.getOverviewMapsFor(m_allNotices[i]->getMapID(),
                                   overviewIDs);
      for(uint32 j = 0; j < overviewIDs.size(); ++j ) {
         mc2dbg << "    " << j << "=" << overviewIDs[j] << endl;
      }
   }

   {
      // Print stuff
      mc2dbg << "MAP_HIERARCHY" << endl;
      set<uint32> mapIDs;
      m_mapTree.getTopLevelMapIDs(mapIDs);
      for(set<uint32>::const_iterator it = mapIDs.begin();
          it != mapIDs.end();
          ++it) {
//.........这里部分代码省略.........
开发者ID:FlavioFalcao,项目名称:Wayfinder-Server,代码行数:101,代码来源:MapModuleNoticeContainer.cpp


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