本文整理汇总了C++中Array::GetElementCount方法的典型用法代码示例。如果您正苦于以下问题:C++ Array::GetElementCount方法的具体用法?C++ Array::GetElementCount怎么用?C++ Array::GetElementCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Array
的用法示例。
在下文中一共展示了Array::GetElementCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Save
void Save(SpriteMap *sm, StreamWriter *f) {
// Write TileTypes
f->WriteShort((Short)sm->GetNumTileTypes());
for (Short i = 0; i < (Short)sm->GetNumTileTypes(); i++) {
const SpriteMapTileType &smtt = sm->GetTileType(i);
f->WriteInt(smtt.mEntityTypeName.GetSizeInBytes());
f->WriteString(smtt.mEntityTypeName, false);
f->WriteInt(smtt.mSpriteName.GetSizeInBytes());
f->WriteString(smtt.mSpriteName, false);
}
// Write Layers
f->WriteInt(sm->GetNumLayers());
for (Int i = 0; i < sm->GetNumLayers(); i++) {
SpriteMapLayer *sml = sm->GetLayer(i);
f->WriteInt(sml->GetName().GetSizeInBytes());
f->WriteString(sml->GetName(), false);
f->WriteInt(sml->GetChunkWidth());
f->WriteInt(sml->GetChunkHeight());
f->WriteInt(sml->GetDrawLayer());
f->WriteVector2D(sml->GetCamera()->GetStartingOrigin());
f->WriteFloat(sml->GetCamera()->GetStartingRotationDegrees());
f->WriteFloat(sml->GetCamera()->GetStartingZoom());
f->WriteFloat(sml->GetScrollMultiplier().mX);
f->WriteFloat(sml->GetScrollMultiplier().mY);
f->WriteFloat(sml->GetSpawnBounds().mOrigin.mX);
f->WriteFloat(sml->GetSpawnBounds().mOrigin.mY);
f->WriteFloat(sml->GetSpawnBounds().mSize.mX);
f->WriteFloat(sml->GetSpawnBounds().mSize.mX);
// Write Chunks
f->WriteInt(sml->GetNumChunks());
for (Int j = 0; j < sml->GetNumChunks(); j++) {
const SpriteMapChunk &c = sml->GetChunk(j);
Array<Short> compressedTiles;
f->WriteInt(c.GetTileOffset().mX);
f->WriteInt(c.GetTileOffset().mY);
c.GetCompressedTiles(compressedTiles);
f->WriteInt(compressedTiles.GetElementCount());
f->Write((Byte*)&compressedTiles[0],
compressedTiles.GetElementCount());
}
}
}
示例2: ReadString
void StreamReader::ReadString(String *result, const String &delimiter) {
Array<Char> retString;
Array<Char> delString;
String strDelimiter = delimiter;
Char c;
if (strDelimiter.IsEmpty()) {
strDelimiter.Resize(1);
strDelimiter.Append("\0");
}
while (true) {
c = ReadByte();
if (this->GetError())
break;
if (c == strDelimiter.GetData()[0]) {
delString.Clear();
delString.Append(c);
for (Int i = 1; i < strDelimiter.GetSizeInBytes(); i++) {
c = ReadByte();
if (this->GetError()) {
for (Int j = 0; j < delString.GetElementCount(); j++)
retString.Append(delString[j]);
break;
}
delString.Append(c);
if (c != strDelimiter.GetData()[i])
break;
}
if (strDelimiter.GetSizeInBytes() > delString.GetElementCount())
for (Int i = 0; i < delString.GetElementCount(); i++)
retString.Append(delString[i]);
else {
if (memcmp(strDelimiter.GetData(),
delString.GetData(), delString.GetElementCount()))
{
for (Int i = 0; i < delString.GetElementCount(); i++)
retString.Append(delString[i]);
}
else
break;
}
} else {
retString.Append(c);
}
}
result->Resize(retString.GetElementCount());
memcpy((Char*)result->GetData(),
retString.GetData(), retString.GetElementCount());
}