本文整理汇总了C++中ZStreamW类的典型用法代码示例。如果您正苦于以下问题:C++ ZStreamW类的具体用法?C++ ZStreamW怎么用?C++ ZStreamW使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ZStreamW类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: spWriteFreeFlush
static void spWriteFreeFlush(SecBuffer& sb, const ZStreamW& w)
{
if (not sb.pvBuffer)
return;
if (not sb.cbBuffer)
{
spPSFT->FreeContextBuffer(sb.pvBuffer);
sb.pvBuffer = nullptr;
}
else
{
size_t countWritten = 0;
w.Write(sb.pvBuffer, sb.cbBuffer, &countWritten);
const bool shortWrite = (countWritten != sb.cbBuffer);
sb.cbBuffer = 0;
spPSFT->FreeContextBuffer(sb.pvBuffer);
sb.pvBuffer = nullptr;
if (shortWrite)
ZStreamW::sThrowEndOfStream();
w.Flush();
}
}
开发者ID:,项目名称:,代码行数:26,代码来源:
示例2: ToStream
void ZTBQueryNode_ID_Constant::ToStream(const ZStreamW& iStreamW)
{
iStreamW.WriteUInt8(5);
sWriteCount(iStreamW, fIDs.size());
for (vector<uint64>::iterator i = fIDs.begin(), theEnd = fIDs.end();
i != theEnd; ++i)
{
iStreamW.WriteUInt64(*i);
}
}
开发者ID:,项目名称:,代码行数:10,代码来源:
示例3: sWriteCount
static inline void sWriteCount(const ZStreamW& iStreamW, uint32 iCount)
{
if (iCount < 0xFF)
{
iStreamW.WriteUInt8(iCount);
}
else
{
iStreamW.WriteUInt8(0xFF);
iStreamW.WriteUInt32(iCount);
}
}
开发者ID:,项目名称:,代码行数:12,代码来源:
示例4: sWriteString
static void sWriteString(const ZStreamW& iStreamW, const string& iString)
{
size_t theSize = iString.size();
sWriteCount(iStreamW, theSize);
if (theSize)
iStreamW.Write(iString.data(), theSize);
}
开发者ID:,项目名称:,代码行数:7,代码来源:
示例5: sNodeToStream
static void sNodeToStream(const ZStreamW& iStreamW, const ZRef<ZTBQueryNode>& iNode)
{
if (iNode)
iNode->ToStream(iStreamW);
else
iStreamW.WriteUInt8(0);
}
开发者ID:,项目名称:,代码行数:7,代码来源:
示例6: sWriteColorTable
static void sWriteColorTable(const ZStreamW& iStream,
const ZRGBColorPOD* iColors, size_t iCountAvailable, size_t iCountNeeded)
{
iCountAvailable = min(iCountAvailable, iCountNeeded);
vector<uint8> tempColorsVector(iCountNeeded * 3);
uint8* currentDest = &tempColorsVector[0];
for (size_t x = 0; x < iCountAvailable; ++x)
{
*currentDest++ = iColors->red >> 8;
*currentDest++ = iColors->green >> 8;
*currentDest++ = iColors->blue >> 8;
++iColors;
}
for (size_t x = iCountAvailable; x < iCountNeeded; ++x)
{
*currentDest++ = 0;
*currentDest++ = 0;
*currentDest++ = 0;
}
iStream.Write(&tempColorsVector[0], tempColorsVector.size());
}
开发者ID:,项目名称:,代码行数:25,代码来源:
示例7: locker
bool ZBlackBerryServer::Handler_ManagerChanged::Write(const ZStreamW& w)
{
ZGuardRMtxR locker(fMutex);
if (fState == eState_SendChanged)
{
fState = eState_Quiet;
locker.Release();
w.WriteBool(true);
return true;
}
else if (fState == eState_SendClosed)
{
locker.Release();
w.WriteBool(false);
return false;
}
return true;
}
开发者ID:zoolib,项目名称:zoolib_old,代码行数:20,代码来源:ZBlackBerryServer.cpp
示例8:
/// \sa ZBlackBerry::Device_Client::Write
bool ZBlackBerryServer::Handler_DeviceFinished::Write(const ZStreamW& w)
{
if (!fOpen)
{
if (ZLOG(s, eDebug + 2, "ZBlackBerryServer::Handler_DeviceFinished"))
s << "Write false, return false";
w.WriteBool(false);
return false;
}
if (ZLOG(s, eDebug + 2, "ZBlackBerryServer::Handler_DeviceFinished"))
s << "Write nothing, return true";
return true;
}
开发者ID:zoolib,项目名称:zoolib_old,代码行数:17,代码来源:ZBlackBerryServer.cpp
示例9: pCopyTo
void ZStreamR_Memory::pCopyTo(const ZStreamW& iStreamW, uint64 iCount,
uint64* oCountRead, uint64* oCountWritten)
{
if (oCountRead)
*oCountRead = 0;
if (oCountWritten)
*oCountWritten = 0;
while (iCount)
{
size_t countWritten;
iStreamW.Write(fAddress, iCount, &countWritten);
if (countWritten == 0)
break;
fAddress += countWritten;
iCount -= countWritten;
if (oCountRead)
*oCountRead += countWritten;
if (oCountWritten)
*oCountWritten += countWritten;
}
}
开发者ID:,项目名称:,代码行数:21,代码来源:
示例10: sCopyReadToWrite
/**
Copy data from \a iStreamR to \a iStreamW by reading it into a buffer and writing
from that buffer. If more than 8K is to be copied we try to allocate an 8K buffer
in the heap. If less than 8K is to be copied, or the heap buffer could not be allocated,
we use a 1K buffer on the stack.
*/
void sCopyReadToWrite(const ZStreamR& iStreamR, const ZStreamW& iStreamW, uint64 iCount,
uint64* oCountRead, uint64* oCountWritten)
{
if (oCountRead)
*oCountRead = 0;
if (oCountWritten)
*oCountWritten = 0;
if (iCount == 0)
return;
if (iCount > 8192)
{
// Try to allocate and use an 8K heap-based buffer.
if (uint8* heapBuffer = new(nothrow) uint8[8192])
{
try
{
uint64 countRemaining = iCount;
while (countRemaining > 0)
{
size_t countRead;
iStreamR.Read(heapBuffer, min(countRemaining, uint64(8192)), &countRead);
if (countRead == 0)
break;
if (oCountRead)
*oCountRead += countRead;
countRemaining -= countRead;
uint8* tempSource = heapBuffer;
while (countRead > 0)
{
size_t countWritten;
iStreamW.Write(tempSource, countRead, &countWritten);
if (countWritten == 0)
{
countRemaining = 0;
break;
}
tempSource += countWritten;
countRead -= countWritten;
if (oCountWritten)
*oCountWritten += countWritten;
}
}
}
catch (...)
{
delete[] heapBuffer;
throw;
}
delete[] heapBuffer;
return;
}
}
// We'll get to here if we need to move 8192 bytes or less, or if
// allocation of the heap buffer failed.
// Use a stack-based 1024 byte buffer if we're moving less than 8K and thus will iterate
// fewer than 8 times. Previously we'd unconditionally used one of size 4096, but that's
// fairly large and can contribute to blowing the stack on MacOS.
uint8 localBuffer[1024];
uint64 countRemaining = iCount;
while (countRemaining > 0)
{
size_t countRead;
iStreamR.Read(localBuffer, min(countRemaining, uint64(sizeof(localBuffer))), &countRead);
if (countRead == 0)
break;
if (oCountRead)
*oCountRead += countRead;
countRemaining -= countRead;
uint8* tempSource = localBuffer;
while (countRead > 0)
{
size_t countWritten;
iStreamW.Write(tempSource, countRead, &countWritten);
if (countWritten == 0)
{
countRemaining = 0;
break;
}
tempSource += countWritten;
countRead -= countWritten;
if (oCountWritten)
*oCountWritten += countWritten;
}
}
}
开发者ID:,项目名称:,代码行数:95,代码来源:
示例11:
void ZTBSpec::Comparator::ToStream(const ZStreamW& iStreamW) const
{
iStreamW.WriteUInt8(fRel);
iStreamW.WriteUInt8(fStrength);
}
开发者ID:,项目名称:,代码行数:5,代码来源:
示例12: spWriteFully
static bool spWriteFully(const SecBuffer& sb, const ZStreamW& w)
{
size_t countWritten;
w.Write(sb.pvBuffer, sb.cbBuffer, &countWritten);
return countWritten == sb.cbBuffer;
}
开发者ID:,项目名称:,代码行数:6,代码来源:
示例13: ZAssertStop
void ZDCPixmapEncoder_GIF::Imp_Write(const ZStreamW& iStream,
const void* iBaseAddress,
const ZDCPixmapNS::RasterDesc& iRasterDesc,
const ZDCPixmapNS::PixelDesc& iPixelDesc,
const ZRect& iBounds)
{
ZRef<ZDCPixmapNS::PixelDescRep_Indexed> thePixelDescRep_Indexed
= ZRefDynamicCast<ZDCPixmapNS::PixelDescRep_Indexed>(iPixelDesc.GetRep());
ZAssertStop(2, thePixelDescRep_Indexed);
if (fTransparent)
iStream.WriteString("GIF89a");
else
iStream.WriteString("GIF87a");
iStream.WriteUInt16LE(iBounds.Width());
iStream.WriteUInt16LE(iBounds.Height());
uint8 globalStrmFlags = 0;
globalStrmFlags |= 0x80; // hasGlobalColorTable
globalStrmFlags |= 0x70; // colorResolution (8 bits per component)
// globalStrmFlags |= 0x08; // set this if the color table is sorted in priority order
ZAssertStop(2, iRasterDesc.fPixvalDesc.fDepth > 0 && iRasterDesc.fPixvalDesc.fDepth <= 8);
globalStrmFlags |= iRasterDesc.fPixvalDesc.fDepth - 1; // globalColorTableSize & depth
iStream.WriteUInt8(globalStrmFlags);
iStream.WriteUInt8(0); // backgroundColorIndex
iStream.WriteUInt8(0); // Pixel aspect ratio -- 0 == none specified.
const ZRGBColorPOD* theColors;
size_t theColorsCount;
thePixelDescRep_Indexed->GetColors(theColors, theColorsCount);
sWriteColorTable(iStream, theColors, theColorsCount, 1 << iRasterDesc.fPixvalDesc.fDepth);
if (fTransparent)
{
iStream.WriteUInt8('!'); // Extension block
iStream.WriteUInt8(0xF9); // Graphic Control Extension
iStream.WriteUInt8(4); // Block size
// The next byte encodes four fields:
// 3 bits, Reserved == 0
// 3 bits, Disposal Method == none (0),
// 1 bit, User Input Flag == none (0)
// 1 bit, Transparent Color Flag = yes (1)
iStream.WriteUInt8(1);
iStream.WriteUInt16LE(0); // Delay time
iStream.WriteUInt8(fTransparentPixval);
iStream.WriteUInt8(0); // Block terminator
}
iStream.WriteUInt8(','); // Start of image
iStream.WriteUInt16LE(0); // Origin h
iStream.WriteUInt16LE(0); // Origin v
iStream.WriteUInt16LE(iBounds.Width());
iStream.WriteUInt16LE(iBounds.Height());
uint8 localStrmFlags = 0;
// localStrmFlags |= 0x80; // hasLocalColorTable
if (fInterlace)
localStrmFlags |= 0x40; // interlaced
// localStrmFlags |= 0x20; // sorted
// localStrmFlags |= 0x70; // localColorTableSize
iStream.WriteUInt8(localStrmFlags);
iStream.WriteUInt8(iRasterDesc.fPixvalDesc.fDepth); // Initial code size.
{ // Scope theSC.
StreamW_Chunk theSC(iStream);
ZStreamW_LZWEncode* theSLZW = nil;
ZStreamW_LZWEncodeNoPatent* theSLZWNP = nil;
ZStreamW* theStream;
if (fNoPatent)
{
theSLZWNP = new ZStreamW_LZWEncodeNoPatent(iRasterDesc.fPixvalDesc.fDepth, theSC);
theStream = theSLZWNP;
}
else
{
theSLZW = new ZStreamW_LZWEncode(iRasterDesc.fPixvalDesc.fDepth, theSC);
theStream = theSLZW;
}
ZDCPixmapNS::PixvalDesc destPixvalDesc(8, true);
vector<uint8> theRowBufferVector(iBounds.Width());
void* theRowBuffer = &theRowBufferVector[0];
try
{
if (fInterlace)
{
for (int pass = 0; pass < 4; ++pass)
{
for (ZCoord currentY = iBounds.top + sInterlaceStart[pass];
currentY < iBounds.bottom; currentY += sInterlaceIncrement[pass])
{
const void* sourceRowAddress
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:
示例14: sHandle_GET
bool ZWebDAV::sHandle_GET(const ZTrail& iPrefix, ZNode iRoot, const ZStreamR&, const ZStreamW& iStreamW, const ZTuple& iHeader, const ZTrail& iTrail, const ZTuple& iParam)
{
ZNode theNode = iRoot.Trail(iTrail);
ZHTTP::Response r;
r.Set("date", sAsString_WebDAV(ZTime::sNow()));
if (iHeader.Has("range"))
{
if (const ZLog::S& s = ZLog::S(ZLog::eInfo, "ZWebDAV"))
s << "GET with range:\n" << iHeader;
}
if (theNode.Exists())
{
r.SetResult(200);
if (theNode.CanHaveChildren())
{
r.Set("Content-Type", "text/html; charset=\"utf-8\"");
r.Set("Transfer-Encoding", "chunked");
r.Send(iStreamW);
ZHTTP::StreamW_Chunked chunkedStream(iStreamW);
ZStrimW_StreamUTF8 theStrimW(chunkedStream);
ZStrimW_ML s(false, theStrimW);
s.Begin("html");
s.Begin("title");
s << theNode.Name();
s.End("title");
s.Begin("body");
for (ZNodeIter i = theNode; i; i.Advance())
{
s.Begin("p");
s.Begin("a");
if (i.Current().CanHaveChildren())
{
s.Attr("href", ZHTTP::sEncodeComponent(i.Current().Name()) + "/");
s << i.Current().Name() << "/";
}
else
{
s.Attr("href", ZHTTP::sEncodeComponent(i.Current().Name()));
s << i.Current().Name();
}
s.End("a");
s.End("p");
}
s.End("body");
s.End("html");
}
else if (ZRef<ZStreamerRPos> theStreamer = theNode.OpenRPos())
{
const ZStreamRPos& theStreamRPos = theStreamer->GetStreamRPos();
uint64 sentSize = theStreamRPos.GetSize();
if (ZTupleValue rangeParam = iHeader.GetValue("range"))
{
vector<pair<size_t, size_t> > ranges;
if (!ZHTTP::sOrganizeRanges(sentSize, rangeParam, ranges))
{
iStreamW.WriteString("HTTP/1.1 406 Unsatisfiable range\r\n\r\n");
return false;
}
r.SetResult(206, "Partial Content");
r.Set("Content-Range", ZString::sFormat("bytes %d-%d/%d", ranges.front().first, ranges.front().second - 1, sentSize));
theStreamRPos.SetPosition(ranges.front().first);
sentSize = ranges.front().second - ranges.front().first;
}
else
{
r.SetResult(200);
}
string theMIMEType = "application/octet-stream";
ZTupleValue theMIMEValue;
if (theNode.GetProp("MIMEType", theMIMEValue))
{
string asString;
if (theMIMEValue.GetString(asString))
theMIMEType = asString;
}
r.Set("Content-Type", theMIMEType);
ZTupleValue theValue;
if (theNode.GetProp("lastModified", theValue))
{
if (ZTime theTime = theValue.GetTime())
r.Set("Last-Modified", sAsString_WebDAV(theTime));
}
r.Set("Content-Transfer-Encoding", "binary");
r.Set("Content-Length", ZString::sFromUInt64(sentSize));
r.Send(iStreamW);
iStreamW.CopyFrom(theStreamRPos, sentSize);
}
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:
示例15: Write
bool ZTSWatcherServerAsync::Write(const ZStreamW& iStreamW)
{
bool wroteAnything = false;
ZMutexLocker locker(fMutex);
if (fSendClose)
{
iStreamW.WriteUInt8(eResp_Close);
return false;
}
else if (fIDsNeeded)
{
if (ZLOG(s, eDebug, "ZTSWatcherServerAsync"))
s << "Write, sending IDs";
const size_t countNeeded = fIDsNeeded;
fIDsNeeded = 0;
locker.Release();
uint64 theBaseID;
size_t countIssued;
bool success = fTSWatcher->AllocateIDs(countNeeded, theBaseID, countIssued);
if (!success)
{
iStreamW.WriteUInt8(eResp_Close);
return false;
}
iStreamW.WriteUInt8(eResp_IDs);
iStreamW.WriteUInt64(theBaseID);
iStreamW.WriteCount(countIssued);
wroteAnything = true;
if (ZLOG(s, eDebug, "ZTSWatcherServerAsync"))
s << "Write, sent IDs";
}
else if (fSyncNeeded)
{
if (ZLOG(s, eDebug, "ZTSWatcherServerAsync"))
s << "Write, sync";
fSyncNeeded = false;
vector<uint64> removedIDs;
vector<uint64> addedIDs;
vector<int64> removedQueries;
vector<ZTSWatcher::AddedQueryCombo> addedQueries;
vector<uint64> writtenTupleIDs;
vector<ZTuple> writtenTuples;
fRemovedIDs.swap(removedIDs);
fAddedIDs.swap(addedIDs);
fRemovedQueries.swap(removedQueries);
fAddedQueries.swap(addedQueries);
fWrittenTupleIDs.swap(writtenTupleIDs);
fWrittenTuples.swap(writtenTuples);
locker.Release();
vector<uint64> watcherAddedIDs;
vector<uint64> changedTupleIDs;
vector<ZTuple> changedTuples;
map<int64, vector<uint64> > changedQueries;
using ZUtil_STL::sFirstOrNil;
bool success = fTSWatcher->Sync(
sFirstOrNil(removedIDs), removedIDs.size(),
sFirstOrNil(addedIDs), addedIDs.size(),
sFirstOrNil(removedQueries), removedQueries.size(),
sFirstOrNil(addedQueries), addedQueries.size(),
watcherAddedIDs,
changedTupleIDs, changedTuples,
sFirstOrNil(writtenTupleIDs), sFirstOrNil(writtenTuples), writtenTupleIDs.size(),
changedQueries);
if (!success)
{
iStreamW.WriteUInt8(eResp_Close);
return false;
}
iStreamW.WriteUInt8(eResp_SyncResults);
iStreamW.WriteCount(watcherAddedIDs.size());
for (vector<uint64>::const_iterator
i = watcherAddedIDs.begin(), theEnd = watcherAddedIDs.end();
i != theEnd; ++i)
{
iStreamW.WriteUInt64(*i);
}
iStreamW.WriteCount(changedTupleIDs.size());
vector<ZTuple>::const_iterator iterCT = changedTuples.begin();
for (vector<uint64>::const_iterator
i = changedTupleIDs.begin(), theEnd = changedTupleIDs.end();
i != theEnd; ++i, ++iterCT)
{
iStreamW.WriteUInt64(*i);
(*iterCT).ToStream(iStreamW);
//.........这里部分代码省略.........
开发者ID:zoolib,项目名称:zoolib_old,代码行数:101,代码来源:ZTSWatcherServerAsync.cpp
注:本文中的ZStreamW类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论