本文整理汇总了C++中HeapString::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ HeapString::Clear方法的具体用法?C++ HeapString::Clear怎么用?C++ HeapString::Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HeapString
的用法示例。
在下文中一共展示了HeapString::Clear方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadAllLinesTo
size_t IStream::ReadAllLinesTo(List<HeapString>& outLines, size_t maxCount/*=1024*/, bool isTrim/*=true*/, bool ignoreEmptyLine/*=true*/)const
{
size_t count = 0;
HeapString temp;
temp.ReserveLength(maxCount);
while (true)
{
temp.Clear();
size_t readCount = ReadLineToString(temp);
count += readCount;
BREAK_IF_ZERO(readCount);
if (ignoreEmptyLine)
{
CONTINUE_IF_EMPTY(temp);
}
if (isTrim)
{
temp.TrimAll();
}
outLines.Add(temp);
temp.ForceSetLength(0);
}
return count;
}
示例2: CreateAtlasRegion
TextureAtlasRegion* MedusaTextureAtlas::CreateAtlasRegion(const IStream& stream)
{
HeapString outLine;
List<HeapString> outValues;
std::unique_ptr<TextureAtlasRegion> region(new TextureAtlasRegion());
//read source texture rect
Rect2U sourceRect;
Rect2U textureRect;
outLine.Clear();
RETURN_NULL_IF_FALSE(ReadLineToValues(stream, outLine, outValues));
region->SetName(outValues[0]);
region->SetRotate(StringParser::StringTo<bool>(outValues[1]));
sourceRect.Origin.X = StringParser::StringTo<uint>(outValues[2]);
sourceRect.Origin.Y = StringParser::StringTo<uint>(outValues[3]);
sourceRect.Size.Width = StringParser::StringTo<uint>(outValues[4]);
sourceRect.Size.Height = StringParser::StringTo<uint>(outValues[5]);
textureRect.Origin.X = StringParser::StringTo<uint>(outValues[6]);
textureRect.Origin.Y = StringParser::StringTo<uint>(outValues[7]);
textureRect.Size.Width = StringParser::StringTo<uint>(outValues[8]);
textureRect.Size.Height = StringParser::StringTo<uint>(outValues[9]);
region->SetSourceRect(sourceRect);
region->SetTextureRect(textureRect);
return region.release();
}
示例3: OnCreatePage
TextureAtlasPage* MedusaTextureAtlas::OnCreatePage(const FileIdRef& fileId, const IStream& stream)
{
HeapString outLine;
List<HeapString> outValues;
std::unique_ptr<TextureAtlasPage> page(new TextureAtlasPage(0));
page->SetTexcoordUpSide(false);
outLine.Clear();
RETURN_NULL_IF_FALSE(ReadLineToValues(stream, outLine, outValues));
FileId textureFileId = FileId::ParseFrom(outValues[0]);
page->SetTextureFileId(textureFileId);
Size2U pageSize;
pageSize.Width = (uint)outValues[1].ToInt();
pageSize.Height = (uint)outValues[2].ToInt();
page->SetPageSize(pageSize);
//ignore format,use real image format instead
//outValues[3]
//read filter
if (outValues[4] == "NearestNeighbour")
{
page->SetMagFilter(GraphicsTextureMagFilter::Nearest);
page->SetMinFilter(GraphicsTextureMinFilter::Nearest);
}
else// if (outLine == "Linear")
{
page->SetMagFilter(GraphicsTextureMagFilter::Linear);
page->SetMinFilter(GraphicsTextureMinFilter::Linear);
}
page->SetFlipPVR(StringParser::StringTo<bool>(outValues[5]));
page->SetPremultiplyAlpha(StringParser::StringTo<bool>(outValues[6]));
//read regions
TextureAtlasRegion* region = nullptr;
do
{
region = CreateAtlasRegion(stream);
if (region != nullptr)
{
page->AddRegion(region);
}
} while (region != nullptr);
return page.release();
}
示例4: ConvertToBuffer
intp StringParser::ConvertToBuffer(const wchar_t* str, size_t length, HeapString& outBuffer)
{
outBuffer.Clear();
if (length == 0)
{
return 0;
}
constexpr bool isUTF16 = sizeof(wchar_t) == 2;
if (isUTF16)
{
//sizeof(wchar_t)==2
size_t utf8Size = length * 3 + 1;
outBuffer.ReserveSize(utf8Size);
const UTF16* sourceStart = reinterpret_cast<const UTF16*>(str);
const UTF16* sourceEnd = sourceStart + length;
UTF8* targetStart = reinterpret_cast<UTF8*>(outBuffer.MutableBuffer());
UTF8* targetEnd = targetStart + utf8Size;
ConversionResult res = ConvertUTF16toUTF8(&sourceStart, sourceEnd, &targetStart, targetEnd, strictConversion);
*targetStart = 0;
if (res == conversionOK)
{
intp count = targetStart - reinterpret_cast<UTF8*>(outBuffer.MutableBuffer());
outBuffer.ForceSetLength(count);
return count;
}
}
else
{
//sizeof(wchar_t)==4
size_t utf8Size = length * 4 + 1;
outBuffer.ReserveSize(utf8Size);
const UTF32* sourceStart = reinterpret_cast<const UTF32*>(str);
const UTF32* sourceEnd = sourceStart + length;
UTF8* targetStart = reinterpret_cast<UTF8*>(outBuffer.MutableBuffer());
UTF8* targetEnd = targetStart + utf8Size;
ConversionResult res = ConvertUTF32toUTF8(&sourceStart, sourceEnd, &targetStart, targetEnd, strictConversion);
*targetStart = 0;
if (res == conversionOK)
{
intp count = targetStart - reinterpret_cast<UTF8*>(outBuffer.MutableBuffer());
outBuffer.ForceSetLength(count);
return count;
}
}
return 0;
}