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


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

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


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

示例1: strlen


//.........这里部分代码省略.........
   //    GfxDatas(1) + Nodes(1) + Connections(1) +
   //    GfxDataSingleSmallPoly(1) + GfxDataSingleLine(1) +
   //    GfxDataSinglePoint(1) + GfxDataMultiplePoints(1) +
   //    simpleItems(1) + coordinates + lanes + categories + SignPosts
   m_nbrAllocators = uint16(numberInitialItemTypeAllocators)+12;

   // 256 for the copyright string
   DataBuffer* dataBuffer = new DataBuffer(20 + 4*nbrNativeLanguages + 
                                           4*nbrCurrencies +
                                           variableHeaderSize +
                                           4 + 8*m_nbrAllocators + 256);
   dataBuffer->fillWithZeros();

   dataBuffer->writeNextLong(m_mapID);
   dataBuffer->writeNextLong(0);    // Total size to be filled in later!!!

   // Save the current time
   if ( m_updateCreationTime ) {
      m_creationTime = TimeUtility::getRealTime();
   } else {
      mc2log << info << "[GMH]: Not updating the creation time" << endl;
   }
   dataBuffer->writeNextLong(m_creationTime);

   // Save some data about all the items in this map
   dataBuffer->writeNextLong( (uint32) m_country);

   byte flagByte = 0;
   flagByte = BitUtility::setBit( flagByte, 0, m_driveOnRightSide);
   flagByte = BitUtility::setBit( flagByte, 1, m_groupsInLocationNameOrder);
   
   dataBuffer->writeNextByte(flagByte);

   dataBuffer->writeNextByte(nbrNativeLanguages);
   dataBuffer->writeNextByte(nbrCurrencies);
   dataBuffer->writeNextByte(version);

   dataBuffer->writeNextLong(m_nbrAllocators);

   // The languages
   for ( NativeLanguageIndexes::size_type i = 0;
         i < nbrNativeLanguages; ++i ) {
      dataBuffer->writeNextLong( m_nativeLanguages[ i ] );
   }

   // The currencies
   for (uint32 i=0; i<nbrCurrencies; i++) {
      dataBuffer->writeNextLong(m_currency->getElementAt(i));
   }

   // "Calculate" true creation time,
   // it is set the first time this map is saved.
   if (m_trueCreationTime == MAX_UINT32)
      m_trueCreationTime = TimeUtility::getRealTime();

   // Variable header
   // Currently holds the map name, origin, and 3 times, and ..
   dataBuffer->writeNextLong( variableHeaderSize );
   dataBuffer->writeNextString( m_name );
   dataBuffer->writeNextString( m_origin );  
   dataBuffer->writeNextLong( m_trueCreationTime );
   dataBuffer->writeNextLong( m_waspTime );
   dataBuffer->writeNextLong( m_dynamicExtradataTime );
   // version: 5
#ifdef MC2_UTF8
   m_utf8Strings = true;
#else
   m_utf8Strings = false;
#endif
   dataBuffer->writeNextBool( m_utf8Strings );
   dataBuffer->writeNextBool( m_mapFiltered );
   dataBuffer->writeNextBool( m_mapGfxDataFiltered );
   dataBuffer->writeNextString( m_mapCountryDir );
   // version: 6 (no changes in header, but in allocator handling)


   dataBuffer->alignToLongAndClear();
   // End of variable header.


   // String with copyright-information for images of this map
   
   const char* copyrightStringToSave = m_copyrightString;   
   if ( copyrightStringToSave == NULL ) {
      copyrightStringToSave = "© 2010";
   }
   
   dataBuffer->writeNextString( copyrightStringToSave );
   dataBuffer->alignToLongAndClear();

   mc2dbg << "[GenricMapHeader]: Header saved in "
          << saveClock
          << ", version=" << int(version) << endl;

   DataBufferUtil::saveBuffer( *dataBuffer, outfile );

   delete dataBuffer;
   
   return true;
}
开发者ID:FlavioFalcao,项目名称:Wayfinder-Server,代码行数:101,代码来源:GenericMapHeader.cpp


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