本文整理汇总了C++中DataBuffer::fillWithZeros方法的典型用法代码示例。如果您正苦于以下问题:C++ DataBuffer::fillWithZeros方法的具体用法?C++ DataBuffer::fillWithZeros怎么用?C++ DataBuffer::fillWithZeros使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataBuffer
的用法示例。
在下文中一共展示了DataBuffer::fillWithZeros方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: strlen
bool
GenericMapHeader::internalSave(int outfile)
{
DebugClock saveClock;
// ***************************************************************
// Save the general map information
// ***************************************************************
byte nbrNativeLanguages = m_nativeLanguages.size();
byte nbrCurrencies = 0;
if (m_currency != NULL)
nbrCurrencies = (byte) m_currency->getSize();
// version: 7
byte version = 7;
// Calculate variable header size.
uint32 nameAndOrigLen = ( strlen(m_name)+1 + strlen(m_origin)+1 );
AlignUtility::alignLong( nameAndOrigLen ); // Align because followed by long
uint32 variableHeaderSize =
4 + // varSize
nameAndOrigLen +
4 + 4 + 4 + // (trueCreation + wasp + ed)
1 + // utf8 strings bool
1 + // map filtered bool
1 + // map gfx data filtered bool
strlen( m_mapCountryDir ) + 1;
AlignUtility::alignLong( variableHeaderSize );
// The number of allocators, all itemTypes, GfxDatas, Nodes and
// Connections etc:
// numberInitialItemTypeAllocators(26) +
// 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;
//.........这里部分代码省略.........