本文整理汇总了C++中ZStreamR类的典型用法代码示例。如果您正苦于以下问题:C++ ZStreamR类的具体用法?C++ ZStreamR怎么用?C++ ZStreamR使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ZStreamR类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sReadCount
static inline uint32 sReadCount(const ZStreamR& iStreamR)
{
uint8 firstByte = iStreamR.ReadUInt8();
if (firstByte < 0xFF)
return firstByte;
return iStreamR.ReadUInt32();
}
示例2: sTryGIF
static bool sTryGIF(const ZStreamR& iStream)
{
if ('G' != iStream.ReadUInt8() || 'I' != iStream.ReadUInt8() || 'F' != iStream.ReadUInt8() || '8' != iStream.ReadUInt8())
{
return false;
}
return true;
}
示例3: sTryBMP
static bool sTryBMP(const ZStreamR& iStream)
{
if (0x42 != iStream.ReadUInt8() || 0x4D != iStream.ReadUInt8())
{
return false;
}
return true;
}
示例4: sReadRLE8
static void sReadRLE8(const ZStreamR& iStream,
ZCoord iWidth, ZCoord iHeight, size_t iRowBytes, bool iFlip, uint8* iBuffer)
{
ZCoord currentRow = 0;
ZCoord currentCol = 0;
bool done = false;
while (!done)
{
uint8 count = iStream.ReadUInt8();
uint8 command = iStream.ReadUInt8();
if (count == 0)
{
switch (command)
{
case 0: // Move to start of next row
{
currentRow += 1;
currentCol = 0;
break;
}
case 1: // All done
{
done = true;
break;
}
case 2: // Offset by some relative amount
{
currentCol += iStream.ReadUInt8();
currentRow += iStream.ReadUInt8();
break;
}
default: // Absolute data follows -- the length is the value of 'command'
{
uint8* destAddress = iBuffer
+ iRowBytes * (iFlip ? iHeight - currentRow - 1 : currentRow)
+ currentCol;
iStream.Read(destAddress, command);
currentCol += command;
// An odd number of bytes is followed by a pad byte.
if ((command & 1) != 0)
iStream.Skip(1);
break;
}
}
}
else
{
// Store a run of bytes. The count is in 'count', the value is in 'command'.
uint8* destAddress = iBuffer
+ iRowBytes * (iFlip ? iHeight - currentRow - 1 : currentRow) + currentCol;
for (int x = 0; x < count; ++x)
*destAddress++ = command;
currentCol += count;
}
}
}
示例5: sTryPNG
static bool sTryPNG(const ZStreamR& iStream)
{
if (0x89 != iStream.ReadUInt8() || 0x50 != iStream.ReadUInt8() || 0x4E != iStream.ReadUInt8() || 0x47 != iStream.ReadUInt8()
|| 0x0D != iStream.ReadUInt8() || 0x0A != iStream.ReadUInt8() || 0x1A != iStream.ReadUInt8() || 0x0A != iStream.ReadUInt8())
{
return false;
}
return true;
}
示例6: sTryKF
static bool sTryKF(const ZStreamR& iStream)
{
iStream.Skip(8);
if ('P' != iStream.ReadUInt8() || 'N' != iStream.ReadUInt8() || 'T' != iStream.ReadUInt8() || 'R' != iStream.ReadUInt8())
{
return false;
}
return true;
}
示例7: pCopyFrom
void ZStreamWPos_Memory::pCopyFrom(const ZStreamR& iStreamR, uint64 iCount,
uint64* oCountRead, uint64* oCountWritten)
{
if (oCountRead)
*oCountRead = 0;
if (oCountWritten)
*oCountWritten = 0;
while (iCount)
{
size_t countToRead = ZStream::sClampedSize(iCount, fCapacity, fPosition);
size_t countRead;
iStreamR.Read(fAddress + fPosition, countToRead, &countRead);
if (countRead == 0)
break;
fPosition += countRead;
if (fSize < fPosition)
fSize = fPosition;
iCount -= countRead;
if (oCountRead)
*oCountRead += countRead;
if (oCountWritten)
*oCountWritten += countRead;
}
}
示例8: locker
bool ZBlackBerryServer::Handler_ManagerChanged::Read(const ZStreamR& r)
{
const bool req = r.ReadBool();
ZGuardRMtxR locker(fMutex);
if (!req)
{
fState = eState_SendClosed;
locker.Release();
//##ZStreamerWriter::Wake();
return false;
}
switch (fState)
{
case eState_Quiet:
{
fState = eState_Waiting;
return true;
}
case eState_Changed:
{
fState = eState_SendChanged;
locker.Release();
//##ZStreamerWriter::Wake();
return true;
}
}
ZUnimplemented();
return false;
}
示例9: sReadString
static void sReadString(const ZStreamR& iStreamR, string& oString)
{
uint32 theCount = sReadCount(iStreamR);
oString.resize(theCount);
if (theCount)
iStreamR.Read(const_cast<char*>(oString.data()), theCount);
}
示例10: spWriteIndent
void ZASParser::ParseHandler_Prettify::ParsedBinary(const ZStreamR& iStream)
{
if (fDumpBinaries)
{
if (fInBlock)
spWriteIndent(fStrimW, fIndent);
// Let's see if we've got more than 16 bytes. We only have a read
// stream, so we can't _ask_ how many bytes would be physically
// readable (CountReadable only provides a lower limit, and
// can return zero even when there's data available). So we
// have to actually suck it and see. We use a ZStreamR_DynamicBuffered,
// which lets us read the stream, then return the read bytes to
// be re-read if it turns out we've got enough to warrant doing
// indentation.
ZStreamRWPos_RAM theStreamRAM;
ZStreamR_DynamicBuffered theStream(iStream, theStreamRAM);
uint64 countSkipped;
theStream.Skip(17, &countSkipped);
theStream.Rewind();
theStream.Commit();
if (countSkipped <= 16)
{
// We've got 16 or fewer bytes, emit them on the same line.
fStrimW.Write("binary { ");
ZStreamW_HexStrim(" ", "", 16, fStrimW).CopyAllFrom(theStream, nullptr, nullptr);
fStrimW.Write(" }\n");
}
else
{
// We've got more than 16 bytes, break them up into nice lines.
fStrimW.Write("binary\n");
spWriteIndent(fStrimW, fIndent + 1);
fStrimW.Write("{");
uint64 size;
string chunkSeparator = "\n" + string(fIndent + 1, '\t');
ZStreamW_HexStrim(" ", chunkSeparator, 16, fStrimW)
.CopyAllFrom(theStream, &size, nullptr);
fStrimW.Write("\n");
spWriteIndent(fStrimW, fIndent + 1);
fStrimW.Writef("} // %lld bytes\n", size);
}
}
else
{
uint64 size;
iStream.SkipAll(&size);
if (fInBlock)
spWriteIndent(fStrimW, fIndent);
fStrimW.Writef("binary { /* content not shown */ } // %d bytes\n", size);
}
}
示例11:
ZTBQueryNode_ID_Constant::ZTBQueryNode_ID_Constant(const ZStreamR& iStreamR)
{
if (uint32 theCount = sReadCount(iStreamR))
{
fIDs.reserve(theCount);
while (theCount--)
fIDs.push_back(iStreamR.ReadUInt64());
}
}
示例12: spReadMore
static bool spReadMore(vector<char>& ioBuf, const ZStreamR& r)
{
const size_t priorSize = ioBuf.size();
const size_t newSize = priorSize + 4096;
ioBuf.resize(newSize);
size_t countRead;
r.Read(&ioBuf[priorSize], newSize - priorSize, &countRead);
ioBuf.resize(priorSize + countRead);
return countRead != 0;
}
示例13: Internal_CopyFrom
void ZStreamW_Null::Internal_CopyFrom(const ZStreamR& iStreamR, uint64 iCount,
uint64* oCountRead, uint64* oCountWritten)
{
uint64 countSkipped;
iStreamR.Skip(iCount, &countSkipped);
if (oCountRead)
*oCountRead = countSkipped;
if (oCountWritten)
*oCountWritten = countSkipped;
}
示例14:
/// \sa ZBlackBerry::Device_Client::Read
bool ZBlackBerryServer::Handler_DeviceFinished::Read(const ZStreamR& r)
{
ZLOGFUNCTION(eDebug + 2);
const bool req = r.ReadBool();
ZAssert(!req);
fOpen = false;
//##ZStreamerWriter::Wake();
return false;
}
示例15: spReadZeroTerminatedString
static string spReadZeroTerminatedString(const ZStreamR& iStream)
{
string theString;
while (true)
{
char theChar = iStream.ReadInt8();
if (theChar == 0)
break;
theString += theChar;
}
return theString;
}