本文整理汇总了C++中Stream::GetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ Stream::GetSize方法的具体用法?C++ Stream::GetSize怎么用?C++ Stream::GetSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stream
的用法示例。
在下文中一共展示了Stream::GetSize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Parse
XMLNodePtr XMLDoc::Parse( Stream& source )
{
uint32_t size = source.GetSize();
mXMLSrc.resize(size + 1, 0);
source.Read(&mXMLSrc[0], size);
mXMLSrc[size] = '\0';
mDocument.parse<0>(&mXMLSrc[0]);
mRoot = std::make_shared<XMLNode>(mDocument.first_node());
return mRoot;
}
示例2: outs
static int64 sLZ4Compress(Stream& out, Stream& in, int64 size, Gate<int64, int64> progress, bool co)
{
LZ4CompressStream outs(out);
#ifdef _MULTITHREADED
if(co)
outs.Co();
#endif
sCompressStreamCopy_(outs, in, progress, in, size);
outs.Close();
if(!out.IsError() && !outs.IsError())
return out.GetSize();
return -1;
}
示例3: ins
static int64 sZstdDecompress(Stream& out, Stream& in, int64 size, Gate<int64, int64> progress, bool co)
{
ZstdDecompressStream ins(in);
#ifdef _MULTITHREADED
if(co)
ins.Co();
#endif
sCompressStreamCopy_(out, ins, progress, in, size);
ins.Close();
if(!out.IsError() && !ins.IsError())
return out.GetSize();
return -1;
}
示例4: FindSubChunkOffset
int32 Chunk::FindSubChunkOffset(std::string name)
{
// Reverse the name
name = std::string(name.rbegin(), name.rend());
if (name.size() != 4)
return -1;
Stream* stream = GetStream();
uint32 matched = 0;
while (stream->GetPos() < stream->GetSize())
{
char b = stream->Read<char>();
if (b != name[matched])
matched = 0;
else
++matched;
if (matched == 4)
return stream->GetPos() - 4;
}
return -1;
}
示例5: ras_decode
static bool ras_decode(Bitmap& target, Stream& stream)
{
// reset stream
stream.Seek(0,Stream::START);
// streamsize - headersize
int size = stream.GetSize() - 32;
if ( size < 1 )
return false;
// read header
uint32 magic = ReadBigEndian<uint32>(stream);
uint32 width = ReadBigEndian<uint32>(stream);
uint32 height = ReadBigEndian<uint32>(stream);
uint32 bits = ReadBigEndian<uint32>(stream);
/* uint32 length = */ ReadBigEndian<uint32>(stream);
uint32 type = ReadBigEndian<uint32>(stream);
uint32 maptype = ReadBigEndian<uint32>(stream);
uint32 maplength = ReadBigEndian<uint32>(stream);
// verify header
if ( magic != 0x59a66a95 )
return false;
if ( bits != 1 && bits != 8 && bits != 24 && bits != 32 )
return false;
if ( type != 0 && type != 1 && type != 2 && type != 3 )
return false;
// create bitmap
switch ( bits )
{
case 1: target = Bitmap(width,height,PIXELFORMAT_INTENSITY8); break;
case 8: target = Bitmap(width,height,PIXELFORMAT_PALETTE8(NULL)); break;
case 24: target = Bitmap(width,height,PIXELFORMAT_RGB888); break;
case 32: target = Bitmap(width,height,PIXELFORMAT_ARGB8888); break;
default: return false;
}
// read colormap
switch ( maptype )
{
// "none" - no palette
case 0:
{
stream.Seek(maplength,Stream::CURRENT);
break;
}
// "equal rgb" -mode palette
case 1:
{
if ( bits != 8 || maplength > 768 )
return false;
const PixelFormat& pxf = target.GetPixelFormat();
Color32* palette = pxf.GetPalette();
int count = static_cast<int>(maplength / 3);
int i;
for ( i=0; i<count; ++i ) palette[i].r = ReadBigEndian<uint8>(stream);
for ( i=0; i<count; ++i ) palette[i].g = ReadBigEndian<uint8>(stream);
for ( i=0; i<count; ++i ) palette[i].b = ReadBigEndian<uint8>(stream);
for ( i=0; i<count; ++i ) palette[i].a = 0xff;
break;
}
// "raw" -mode palette
// TODO: this code has not been tested
// (couldn't find files to test with or specification)
// this is my best guess how the "raw" mode works!
case 2:
{
if ( bits != 8 || maplength > 768 )
return false;
const PixelFormat& pxf = target.GetPixelFormat();
Color32* palette = pxf.GetPalette();
int count = static_cast<int>(maplength / 3);
for ( int i=0; i<count; ++i )
{
palette[i].r = ReadBigEndian<uint8>(stream);
palette[i].g = ReadBigEndian<uint8>(stream);
palette[i].b = ReadBigEndian<uint8>(stream);
palette[i].a = 0xff;
}
}
// unknown fileformat
default: return false;
}
// decode buffer
int buffersize = stream.GetSize() - stream.GetOffset();
uint8* buffer = new uint8[buffersize];
stream.Read(buffer,buffersize);
//.........这里部分代码省略.........