本文整理汇总了C++中MemoryBuffer::rewrite方法的典型用法代码示例。如果您正苦于以下问题:C++ MemoryBuffer::rewrite方法的具体用法?C++ MemoryBuffer::rewrite怎么用?C++ MemoryBuffer::rewrite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemoryBuffer
的用法示例。
在下文中一共展示了MemoryBuffer::rewrite方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doCmdRow
void RemoteDataSourceServer::doCmdRow(bool raw, MemoryBuffer & in, MemoryBuffer & out)
{
Owned<IFvDataSource> ds = readDataSource(in);
if (!ds)
{
out.append(false);
return;
}
__int64 requestedRow;
in.read(requestedRow);
unsigned startPos = out.length();
unsigned numRows = 0;
out.append(true); // ok
out.append(requestedRow); // start
unsigned numRowsPos = out.length();
out.append(numRows); // total number of rows;
loop
{
unsigned lengthPos = out.length();
out.append((unsigned)0); // size of this row.
unsigned startRow = out.length();
if (raw)
{
if (!ds->getRawRow(out, requestedRow+numRows))
break;
}
else
{
if (!ds->getRow(out, requestedRow+numRows))
break;
}
if ((numRows != 0) && (out.length() > REMOTE_DATA_SIZE))
break;
unsigned endRow = out.length();
out.rewrite(lengthPos);
out.append(endRow-startRow);
out.rewrite(endRow);
numRows++;
}
if (numRows == 0)
{
out.rewrite(startPos);
out.append(false);
return;
}
unsigned totalLength = out.length();
out.rewrite(numRowsPos);
out.append(numRows);
out.rewrite(totalLength);
}
示例2: serializeMap
void CSlavePartMapping::serializeMap(unsigned i, MemoryBuffer &mb, IGetSlaveData *extra)
{
if (local)
i = 0;
if (i >= maps.ordinality())
{
mb.append((unsigned)0);
return;
}
CSlaveMap &map = maps.item(i);
unsigned nPos = mb.length();
unsigned n=0;
mb.append(n);
UnsignedArray parts;
ForEachItemIn(m, map)
parts.append(map.item(m).queryPartIndex());
MemoryBuffer extraMb;
if (extra)
{
ForEachItemIn(m2, map)
{
unsigned xtraLen = 0;
unsigned xtraPos = extraMb.length();
extraMb.append(xtraLen);
IPartDescriptor &partDesc = map.item(m2);
if (!extra->getData(m2, partDesc.queryPartIndex(), extraMb))
{
parts.zap(partDesc.queryPartIndex());
extraMb.rewrite(xtraPos);
}
else
{
xtraLen = (extraMb.length()-xtraPos)-sizeof(xtraLen);
extraMb.writeDirect(xtraPos, sizeof(xtraLen), &xtraLen);
}
}
}
示例3: gatherData
void gatherData(HeartBeatPacket &hb)
{
CriticalBlock b(crit);
hb.sender = self;
hb.progressSize = 0;
if (progressEnabled)
{
CriticalBlock b(crit);
MemoryBuffer mb;
mb.setBuffer(DATA_MAX, hb.perfdata);
mb.rewrite();
ForEachItemIn(g, activeGraphs)
{
CGraphBase &graph = activeGraphs.item(g);
graph.serializeStats(mb);
if (mb.length() > (DATA_MAX-30))
{
WARNLOG("Progress packet too big!");
break;
}
}
hb.progressSize = mb.length();
}