本文整理汇总了C++中MemoryBuffer::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ MemoryBuffer::clear方法的具体用法?C++ MemoryBuffer::clear怎么用?C++ MemoryBuffer::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemoryBuffer
的用法示例。
在下文中一共展示了MemoryBuffer::clear方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: flush
FXbool AacDecoder::flush() {
if (out) {
buffer.clear();
out->clear();
}
return true;
}
示例2: getWUSresult
byte getWUSresult(MemoryBuffer &mb)
{
byte ret = 0;
wusbuf.swapWith(mb);
if (mb.length()==1) {
mb.read(ret);
mb.clear();
}
return ret;
}
示例3: sendProgress
void TransferServer::sendProgress(OutputProgress & curProgress)
{
MemoryBuffer msg;
msg.setEndian(__BIG_ENDIAN);
curProgress.serialize(msg.clear().append(false));
if (!catchWriteBuffer(masterSocket, msg))
throwError(RFSERR_TimeoutWaitMaster);
checkForRemoteAbort(masterSocket);
}
示例4: createMemoryBuffer
AudioBuffer* PatchProcessor::createMemoryBuffer(int channels, int size){
// assert_param(bufferCount < MAX_BUFFERS_PER_PATCH];
float* buffer = extbuffer+extpos;
size = min(size, BUFFER_LENGTH-extpos);
extpos += size;
size /= channels;
MemoryBuffer* buf = new MemoryBuffer(buffer, channels, size);
buffers[bufferCount++] = buf;
buf->clear();
return buf;
}
示例5: getInclude
//IIncludeHandler
bool getInclude(const char* includename, MemoryBuffer& includebuf, bool& pathOnly)
{
if(!includename)
return false;
pathOnly = true;
includebuf.clear();
const char *finger=pastLast(includename, "esp/xslt/");
if (finger)
{
StringBuffer filepath;
if (fileExists(filepath.append(getCFD()).append("smc_xslt/").append(finger)) || fileExists(filepath.clear().append(getCFD()).append("xslt/").append(finger)))
{
includebuf.append(filepath.length(), filepath.str());
return true;
}
}
else
{
// First of all, it's better to use absolute path to specify the include, like /esp/xslt/ui_overrides.xslt.
// When you specify the include as relative path, for example ./ui_overrides.xslt
// the path will be expanded (by xmllib's source resolver) to its full path, beginning with file://
// on windows it looks like: file:///C:/playground/esp_lsb2/xslt/ui_overrides.xslt
// on linux: file:///home/yma/playground/esp_lsb2/xslt/ui_overrides.xslt
// If current path not found, use root
char dir[_MAX_PATH];
if (!GetCurrentDirectory(sizeof(dir), dir)) {
ERRLOG("ESPxsltIncludeHandler::getInclude: Current directory path too big, setting local path to null");
dir[0] = 0;
}
#ifdef _WIN32
for(int i = 0; i < _MAX_PATH; i++)
{
if(dir[i] == '\0')
break;
else if(dir[i] == PATHSEPCHAR)
dir[i] = '/';
}
#endif
finger = strstr(includename, dir);
if(finger)
{
finger += strlen(dir) + 1;
StringBuffer filepath(finger);
if (fileExists(filepath))
{
includebuf.append(filepath.length(), filepath.str());
return true;
}
}
}
return false;
}
示例6: addResult
void addResult(rowcount_t resultCount, MemoryBuffer &resultData, bool complete)
{
Owned<IWorkUnit> wu = &container.queryJob().queryWorkUnit().lock();
Owned<IWUResult> result = updateWorkUnitResult(wu, resultName, resultSeq);
if (appendOutput)
result->addResultRaw(resultData.length(), resultData.toByteArray(), ResultFormatRaw);
else
result->setResultRaw(resultData.length(), resultData.toByteArray(), ResultFormatRaw);
result->setResultRowCount(resultCount);
result->setResultTotalRowCount(resultCount);
resultData.clear();
if (complete)
result->setResultStatus(ResultStatusCalculated);
appendOutput = true;
}
示例7: fileRead
inline bool fileRead(const char *filename, MemoryBuffer &buff)
{
Owned<IFile> fi=createIFile(filename);
if (fi)
{
Owned<IFileIO> fio=fi->open(IFOread);
if (fio)
{
offset_t len=fio->size();
if (fio->read(0, len, buff.reserveTruncate(len))==len)
return true;
}
}
buff.clear();
return false;
}
示例8: run
virtual int run()
{
unsigned start=0;
try {
MemoryBuffer mb;
bool first = true;
loop
{
size32_t sz = sock->receive_block_size();
if (sz==0)
break;
{
//CriticalBlock block(recvsect); // TEST
unsigned start=msTick();
if (!sock->receive_block(mb.clear().reserve(sz),sz)) {
StringBuffer err("Timeout receiving from ");
err.append(src);
ninfo->sendError(err.str());
break;
}
}
#ifdef TRACE
DBGLOG("received %d from %d",sz,src+1);
#endif
unsigned seq;
mb.read(seq);
if (seq!=ninfo->recvseq[src]++) {
StringBuffer msg;
msg.append("Block out of sequence from ").append(src+1).append(", got ").append(seq).append(" expected ").append(ninfo->recvseq[src]-1);
ninfo->sendError(msg.str());
break; // errors fatal otherwise overload q
}
ninfo->recvtime[src] += (msTick()-start);
ninfo->recvbytes[src] += sz;
}
}
catch (IException *e) {
StringBuffer err;
e->errorMessage(err);
ninfo->sendError("Receive exception",err.str());
}
#ifdef TRACE
DBGLOG("receive exit from %d",src+1);
#endif
return 1;
};
示例9: serializeWUInfo
static bool serializeWUInfo(IConstWorkUnitInfo &info,MemoryBuffer &mb)
{
fixedAppend(mb,24,info.queryWuid());
varAppendMax(mb,64,info.queryUser());
varAppendMax(mb,64,info.queryClusterName());
varAppendMax(mb,64,""); // roxiecluster is obsolete
varAppendMax(mb,256,info.queryJobName());
fixedAppend(mb,10,info.queryStateDesc());
fixedAppend(mb,7,info.queryPriorityDesc());
short int prioritylevel = info.getPriorityLevel();
mb.append(prioritylevel);
fixedAppend(mb,20,""); // Created timestamp
fixedAppend(mb,20,""); // Modified timestamp
mb.append(true);
mb.append(info.isProtected());
if (mb.length()>WORKUNIT_SERVICES_BUFFER_MAX) {
mb.clear().append(WUS_STATUS_OVERFLOWED);
return false;
}
return true;
}
示例10: readResults
//.........这里部分代码省略.........
else if (remoteReadRequest)
{
Owned<IPropertyTree> requestTree = createPTreeFromJSONString(queryLen, query);
Owned<IPropertyTree> responseTree; // used if response is xml or json
const char *outputFmtStr = requestTree->queryProp("format");
const char *response = nullptr;
if (!outputFmtStr || strieq("xml", outputFmtStr))
{
response = (const char *)mb.readDirect(len);
responseTree.setown(createPTreeFromXMLString(len, response));
}
else if (strieq("json", outputFmtStr))
{
response = (const char *)mb.readDirect(len);
responseTree.setown(createPTreeFromJSONString(len, response));
}
unsigned cursorHandle;
if (responseTree)
cursorHandle = responseTree->getPropInt("cursor");
else
mb.read(cursorHandle);
bool retrySend = false;
if (cursorHandle)
{
PROGLOG("Got handle back: %u; len=%u", cursorHandle, len);
StringBuffer xml;
if (responseTree)
{
if (echoResults && response)
{
fputs(response, stdout);
fflush(stdout);
}
if (!responseTree->getPropBin("cursorBin", remoteReadCursorMb.clear()))
break;
}
else
{
size32_t dataLen;
mb.read(dataLen);
if (!dataLen)
break;
const void *rowData = mb.readDirect(dataLen);
// JCSMORE - output binary row data?
// cursor
size32_t cursorLen;
mb.read(cursorLen);
if (!cursorLen)
break;
const void *cursor = mb.readDirect(cursorLen);
memcpy(remoteReadCursorMb.clear().reserveTruncate(cursorLen), cursor, cursorLen);
}
if (remoteStreamForceResend)
cursorHandle = NotFound; // fake that it's a handle dafilesrv doesn't know about
Owned<IPropertyTree> requestTree = createPTree();
requestTree->setPropInt("cursor", cursorHandle);
// Only the handle is needed for continuation, but this tests the behaviour of some clients which may send cursor per request (e.g. to refresh)
if (remoteStreamSendCursor)
requestTree->setPropBin("cursorBin", remoteReadCursorMb.length(), remoteReadCursorMb.toByteArray());
requestTree->setProp("format", outputFmtStr);
StringBuffer requestStr;
示例11: generateGlare
void GlareStreaksOperation::generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings)
{
int x, y, n;
unsigned int nump = 0;
float c1[4], c2[4], c3[4], c4[4];
float a, ang = DEG2RADF(360.0f) / (float)settings->streaks;
int size = inputTile->getWidth() * inputTile->getHeight();
int size4 = size * 4;
bool breaked = false;
MemoryBuffer *tsrc = inputTile->duplicate();
MemoryBuffer *tdst = new MemoryBuffer(COM_DT_COLOR, inputTile->getRect());
tdst->clear();
memset(data, 0, size4 * sizeof(float));
for (a = 0.0f; a < DEG2RADF(360.0f) && (!breaked); a += ang) {
const float an = a + settings->angle_ofs;
const float vx = cos((double)an), vy = sin((double)an);
for (n = 0; n < settings->iter && (!breaked); ++n) {
const float p4 = pow(4.0, (double)n);
const float vxp = vx * p4, vyp = vy * p4;
const float wt = pow((double)settings->fade, (double)p4);
const float cmo = 1.0f - (float)pow((double)settings->colmod, (double)n + 1); // colormodulation amount relative to current pass
float *tdstcol = tdst->getBuffer();
for (y = 0; y < tsrc->getHeight() && (!breaked); ++y) {
for (x = 0; x < tsrc->getWidth(); ++x, tdstcol += 4) {
// first pass no offset, always same for every pass, exact copy,
// otherwise results in uneven brightness, only need once
if (n == 0) tsrc->read(c1, x, y); else c1[0] = c1[1] = c1[2] = 0;
tsrc->readBilinear(c2, x + vxp, y + vyp);
tsrc->readBilinear(c3, x + vxp * 2.0f, y + vyp * 2.0f);
tsrc->readBilinear(c4, x + vxp * 3.0f, y + vyp * 3.0f);
// modulate color to look vaguely similar to a color spectrum
c2[1] *= cmo;
c2[2] *= cmo;
c3[0] *= cmo;
c3[1] *= cmo;
c4[0] *= cmo;
c4[2] *= cmo;
tdstcol[0] = 0.5f * (tdstcol[0] + c1[0] + wt * (c2[0] + wt * (c3[0] + wt * c4[0])));
tdstcol[1] = 0.5f * (tdstcol[1] + c1[1] + wt * (c2[1] + wt * (c3[1] + wt * c4[1])));
tdstcol[2] = 0.5f * (tdstcol[2] + c1[2] + wt * (c2[2] + wt * (c3[2] + wt * c4[2])));
tdstcol[3] = 1.0f;
}
if (isBreaked()) {
breaked = true;
}
}
memcpy(tsrc->getBuffer(), tdst->getBuffer(), sizeof(float) * size4);
}
float *sourcebuffer = tsrc->getBuffer();
float factor = 1.0f / (float)(6 - settings->iter);
for (int i = 0; i < size4; i += 4) {
madd_v3_v3fl(&data[i], &sourcebuffer[i], factor);
data[i + 3] = 1.0f;
}
tdst->clear();
memcpy(tsrc->getBuffer(), inputTile->getBuffer(), sizeof(float) * size4);
nump++;
}
delete tsrc;
delete tdst;
}