本文整理汇总了C++中ZStreamR类的典型用法代码示例。如果您正苦于以下问题:C++ ZStreamR类的具体用法?C++ ZStreamR怎么用?C++ ZStreamR使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ZStreamR类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: sReadCount
static inline uint32 sReadCount(const ZStreamR& iStreamR)
{
uint8 firstByte = iStreamR.ReadUInt8();
if (firstByte < 0xFF)
return firstByte;
return iStreamR.ReadUInt32();
}
开发者ID:,项目名称:,代码行数:7,代码来源:
示例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;
}
开发者ID:,项目名称:,代码行数:8,代码来源:
示例3: sTryBMP
static bool sTryBMP(const ZStreamR& iStream)
{
if (0x42 != iStream.ReadUInt8() || 0x4D != iStream.ReadUInt8())
{
return false;
}
return true;
}
开发者ID:,项目名称:,代码行数:8,代码来源:
示例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;
}
}
}
开发者ID:,项目名称:,代码行数:58,代码来源:
示例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;
}
开发者ID:,项目名称:,代码行数:9,代码来源:
示例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;
}
开发者ID:,项目名称:,代码行数:9,代码来源:
示例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;
}
}
开发者ID:,项目名称:,代码行数:26,代码来源:
示例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;
}
开发者ID:zoolib,项目名称:zoolib_old,代码行数:32,代码来源:ZBlackBerryServer.cpp
示例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);
}
开发者ID:,项目名称:,代码行数:7,代码来源:
示例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);
}
}
开发者ID:zoolib,项目名称:zoolib_old,代码行数:59,代码来源:ZASParser.cpp
示例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());
}
}
开发者ID:,项目名称:,代码行数:9,代码来源:
示例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;
}
开发者ID:,项目名称:,代码行数:10,代码来源:
示例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;
}
开发者ID:,项目名称:,代码行数:10,代码来源:
示例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;
}
开发者ID:zoolib,项目名称:zoolib_old,代码行数:12,代码来源:ZBlackBerryServer.cpp
示例15: spReadZeroTerminatedString
static string spReadZeroTerminatedString(const ZStreamR& iStream)
{
string theString;
while (true)
{
char theChar = iStream.ReadInt8();
if (theChar == 0)
break;
theString += theChar;
}
return theString;
}
开发者ID:,项目名称:,代码行数:12,代码来源:
示例16: sNodeFromStream
static ZRef<ZTBQueryNode> sNodeFromStream(const ZStreamR& iStreamR)
{
uint8 theType = iStreamR.ReadUInt8();
switch (theType)
{
case 0: return ZRef<ZTBQueryNode>();
case 1: return new ZTBQueryNode_All(iStreamR);
case 2: return new ZTBQueryNode_Combo(iStreamR);
case 3: return new ZTBQueryNode_Difference(iStreamR);
case 4: return new ZTBQueryNode_First(iStreamR);
case 5: return new ZTBQueryNode_ID_Constant(iStreamR);
case 6: return new ZTBQueryNode_ID_FromSource(iStreamR);
case 7: return new ZTBQueryNode_Property(iStreamR);
}
throw runtime_error("ZTBQuery, sNodeFromStream, unknown node type");
}
开发者ID:,项目名称:,代码行数:16,代码来源:
示例17: sReadImageData
static void sReadImageData(const ZStreamR& iStream,
bool iInterlaced, const ZRect& iBounds, ZRef<ZDCPixmapRaster> ioRaster)
{
uint8 initialCodeSize = iStream.ReadUInt8();
StreamR_Chunk theSIC(iStream);
ZStreamR_LZWDecode theSILZW(initialCodeSize, theSIC);
ZDCPixmapNS::PixvalDesc sourcePixvalDesc(8, true);
void* destBaseAddress = ioRaster->GetBaseAddress();
ZDCPixmapNS::RasterDesc destRasterDesc = ioRaster->GetRasterDesc();
vector<uint8> theRowBufferVector(iBounds.Width());
void* theRowBuffer = &theRowBufferVector[0];
if (iInterlaced)
{
for (int pass = 0; pass < 4; ++pass)
{
for (ZCoord currentY = iBounds.top + sInterlaceStart[pass];
currentY < iBounds.bottom; currentY += sInterlaceIncrement[pass])
{
theSILZW.Read(theRowBuffer, iBounds.Width());
void* destRowAddress = destRasterDesc.CalcRowAddress(destBaseAddress, currentY);
ZDCPixmapNS::sBlitRowPixvals(theRowBuffer, sourcePixvalDesc, 0,
destRowAddress, destRasterDesc.fPixvalDesc, iBounds.left,
iBounds.Width());
}
}
}
else
{
for (ZCoord currentY = iBounds.top; currentY < iBounds.bottom; ++currentY)
{
theSILZW.Read(theRowBuffer, iBounds.Width());
void* destRowAddress = destRasterDesc.CalcRowAddress(destBaseAddress, currentY);
ZDCPixmapNS::sBlitRowPixvals(theRowBuffer, sourcePixvalDesc, 0,
destRowAddress, destRasterDesc.fPixvalDesc, iBounds.left,
iBounds.Width());
}
}
}
开发者ID:,项目名称:,代码行数:46,代码来源:
示例18: sReadColorTable
static void sReadColorTable(const ZStreamR& iStream,
size_t iCount, vector<ZRGBColorPOD>& oColorTable)
{
oColorTable.resize(iCount);
vector<uint8> readColorTable(iCount * 3);
iStream.Read(&readColorTable[0], readColorTable.size());
const uint8* readColor = &readColorTable[0];
ZRGBColorPOD* oColor = &oColorTable[0];
for (size_t x = 0; x < iCount; ++x)
{
oColor->red = (*readColor++) * 0x101;
oColor->green = (*readColor++) * 0x101;
oColor->blue = (*readColor++) * 0x101;
oColor->alpha = 0xFFFFU;
++oColor;
}
}
开发者ID:,项目名称:,代码行数:19,代码来源:
示例19: sReadRLE4
static void sReadRLE4(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* rowStart = iBuffer
+ iRowBytes * (iFlip ? iHeight - currentRow - 1 : currentRow);
uint8 hi, lo;
for (int i = 0; i < command; ++i)
{
if ((i & 1) == 0)
{
uint8 data = iStream.ReadUInt8();
hi = data >> 4;
lo = data & 0x0f;
}
if ((currentCol & 1) == 0)
{
if ((i & 1) == 0)
rowStart[currentCol / 2] = hi << 4;
else
rowStart[currentCol / 2] = lo << 4;
}
else
{
if ((i & 1) == 0)
rowStart[currentCol / 2] |= hi;
else
rowStart[currentCol / 2] |= lo;
}
++currentCol;
}
switch (command & 0x03)
{
case 1: case 2:
iStream.Skip(1);
break;
}
break;
}
}
}
else
{
开发者ID:,项目名称:,代码行数:73,代码来源:
示例20: sReadPixmap
static void sReadPixmap(const ZStreamR& inStream, ZDCPixmap& outPixmap)
{
uint16 rowBytes = inStream.ReadUInt16();
if (!(rowBytes & 0x8000))
::sThrowBadFormat();
rowBytes &= 0x7FFF;
ZRect bounds;
bounds.top = inStream.ReadInt16();
bounds.left = inStream.ReadInt16();
bounds.bottom = inStream.ReadInt16();
bounds.right = inStream.ReadInt16();
inStream.ReadInt16(); // version
inStream.ReadInt16(); // packType
inStream.ReadInt32(); // packSize
inStream.ReadInt32(); // hRes
inStream.ReadInt32(); //vRes
short pixelType = inStream.ReadInt16(); // pixelType
short pixelSize = inStream.ReadInt16(); // pixelSize
short cmpCount = inStream.ReadInt16(); // cmpCount
short cmpSize = inStream.ReadInt16(); // cmpSize
inStream.ReadInt32(); // planeBytes
inStream.ReadInt32(); // pmTable
inStream.ReadInt32(); // pmReserved
// We only deal with pixel type of 0 (indexed pixels)
if (pixelType != 0)
::sThrowUnsupportedFormat();
// indexed pixels have a cmpCount of 1
if (cmpCount != 1)
::sThrowBadFormat();
// pixelSize and cmpSize should be equal for indexed pixels
if (pixelSize != cmpSize)
::sThrowBadFormat();
// Next on the stream is the color table
vector<ZRGBColor> theColorTable;
inStream.ReadInt32(); // ctSeed
inStream.ReadInt16(); // ctFlags
short ctSize = inStream.ReadInt16();
for (int i = 0; i <= ctSize; ++i)
{
inStream.ReadInt16(); // colorSpecIndex
ZRGBColor theColor;
theColor.red = inStream.ReadUInt16();
theColor.green = inStream.ReadUInt16();
theColor.blue = inStream.ReadUInt16();
theColorTable.push_back(theColor);
}
// Now we have the source rect
inStream.Skip(8);
// and the destination rect
inStream.Skip(8);
// Penultimately we have the mode
inStream.ReadUInt16();
// The remaining data is the packed pixels. Allocate our ZDCPixmap
// using the size we read in, but with no initialized data.
ZDCPixmap thePixmap(bounds.Size(), ZDCPixmapNS::eFormatEfficient_Color_32);
void* baseAddress = thePixmap.GetBaseAddress();
ZDCPixmapNS::RasterDesc theRasterDesc = thePixmap.GetRasterDesc();
ZDCPixmapNS::PixelDesc thePixelDesc = thePixmap.GetPixelDesc();
::sUnpackFromStream(inStream,
bounds.Width(), bounds.Height(),
rowBytes, pixelSize,
&theColorTable[0], theColorTable.size(),
baseAddress, theRasterDesc, thePixelDesc);
outPixmap = thePixmap;
}
开发者ID:,项目名称:,代码行数:75,代码来源:
注:本文中的ZStreamR类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论