本文整理汇总了C++中MemoryBuffer::detach方法的典型用法代码示例。如果您正苦于以下问题:C++ MemoryBuffer::detach方法的具体用法?C++ MemoryBuffer::detach怎么用?C++ MemoryBuffer::detach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemoryBuffer
的用法示例。
在下文中一共展示了MemoryBuffer::detach方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: decompressResource
extern DLLSERVER_API bool decompressResource(size32_t len, const void *data, StringBuffer &result)
{
bool hasVersion = len && (*(const byte *)data == 0x80);
MemoryBuffer src;
src.setBuffer(len, const_cast<void *>(data), false);
byte version = 1;
if (hasVersion)
{
src.skip(1);
src.read(version);
}
MemoryBuffer tgt;
switch (version)
{
case 1:
decompressToBuffer(tgt, src);
break;
default:
throwUnexpected();
}
tgt.append((char)0);
unsigned expandedLen = tgt.length();
result.setBuffer(expandedLen, reinterpret_cast<char *>(tgt.detach()), expandedLen-1);
return true;
}
示例2: decompressResource
extern DLLSERVER_API bool decompressResource(size32_t len, const void *data, StringBuffer &result)
{
MemoryBuffer tgt;
decompressResource(len, data, tgt);
tgt.append((char)0);
unsigned expandedLen = tgt.length();
result.setBuffer(expandedLen, reinterpret_cast<char *>(tgt.detach()), expandedLen-1);
return true;
}
示例3: unpack
//.........这里部分代码省略.........
KEYRECSIZE_T workRecLen;
MemoryBuffer keyBufMb;
const char *source = keys;
char *target;
// do first row
if (handleVariable) {
memcpy(&workRecLen, source, sizeof(workRecLen));
_WINREV(workRecLen);
size32_t tmpSz = sizeof(workRecLen) + sizeof(offset_t);
target = (char *)keyBufMb.reserve(tmpSz+workRecLen);
memcpy(target, source, tmpSz);
source += tmpSz;
target += tmpSz;
}
else {
target = (char *)keyBufMb.reserveTruncate(hdr.numKeys * keyRecLen);
workRecLen = keyRecLen - sizeof(offset_t);
memcpy(target, source, sizeof(offset_t));
source += sizeof(offset_t);
target += sizeof(offset_t);
}
// this is where next row gets data from
const char *prev, *next = NULL;
unsigned prevOffset = 0;
if (handleVariable)
prevOffset = target-((char *)keyBufMb.bufferBase());
else
next = target;
unsigned char pack1 = *source++;
#ifdef _DEBUG
assertex(0==pack1); // 1st time will be always be 0
#endif
KEYRECSIZE_T left = workRecLen;
while (left--) {
*target = *source;
source++;
target++;
}
// do subsequent rows
for (i = 1; i < hdr.numKeys; i++) {
if (handleVariable) {
memcpy(&workRecLen, source, sizeof(workRecLen));
_WINREV(workRecLen);
target = (char *)keyBufMb.reserve(sizeof(workRecLen)+sizeof(offset_t)+workRecLen);
size32_t tmpSz = sizeof(workRecLen)+sizeof(offset_t);
memcpy(target, source, tmpSz);
target += tmpSz;
source += tmpSz;
}
else
{
memcpy(target, source, sizeof(offset_t));
source += sizeof(offset_t);
target += sizeof(offset_t);
}
pack1 = *source++;
#ifdef _DEBUG
assertex(pack1<=workRecLen);
#endif
if (handleVariable) {
prev = ((char *)keyBufMb.bufferBase())+prevOffset;
// for next
prevOffset = target-((char *)keyBufMb.bufferBase());
}
else {
prev = next;
next = target;
}
left = workRecLen - pack1;
while (pack1--) {
*target = *prev;
prev++;
target++;
}
while (left--) {
*target = *source;
source++;
target++;
}
}
expandedSize = keyBufMb.length();
keyBuf = (char *)keyBufMb.detach();
assertex(keyBuf);
}
else {
keyBuf = NULL;
expandedSize = 0;
}
}
else
{
MTIME_SECTION(queryActiveTimer(), "NO compression copy");
expandedSize = hdr.keyBytes + sizeof( __int64 ); // MORE - why is the +sizeof() there?
keyBuf = (char *) allocMem(expandedSize);
memcpy(keyBuf, keys, hdr.keyBytes + sizeof( __int64 ));
}
}
}
示例4: push
//.........这里部分代码省略.........
len = castParam->queryType()->getStringLen();
push(sizeof(unsigned), &len);
}
push(sizeof(char *), &str);
if(numToFree < MAXARGS) {
toFree[numToFree++] = str;
}
}
break;
case type_varunicode:
UNIMPLEMENTED;
case type_real:
#ifdef MAXFPREGS
if (numFpRegs==MAXFPREGS) {
PrintLog("Too many floating point registers needed in FuncCallStack::push");
return -1;
}
char tempbuf[sizeof(double)];
castParam->toMem(tempbuf);
#ifdef FPREG_FIXEDSIZE
if (argType->getSize()<=4)
fpRegs[numFpRegs++] = *(float *)&tempbuf;
else
fpRegs[numFpRegs++] = *(double *)&tempbuf;
#else
// Variable size FP registers as on arm/x64
if (argType->getSize()<=4)
fpRegs[numFpRegs].f = *(float *)&tempbuf;
else
fpRegs[numFpRegs].d = *(double *)&tempbuf;
fpSizes[numFpRegs++] = argType->getSize();
#endif
break;
#else
// fall through if no hw regs used for params
#endif
case type_boolean:
case type_int:
case type_decimal:
case type_date:
case type_char:
case type_enumerated:
case type_swapint:
case type_packedint:
incsize = argType->getSize();
inclen = align(incsize);
assure(inclen);
castParam->toMem(stackbuf+sp);
memset(stackbuf+sp+incsize, 0, inclen - incsize);
sp += inclen;
break;
case type_row:
{
if (hasMeta)
{
try
{
pushMeta(curParam->queryRecordType());
}
catch (IException *E)
{
::Release(E);
return -1;
}
}
if (curParam->getOperator()==no_null)
{
// MORE - check type matches
MemoryBuffer out;
createConstantNullRow(out, curParam->queryRecord());
str = (char *) out.detach();
push(sizeof(char *), &str);
if(numToFree < MAXARGS)
toFree[numToFree++] = str;
}
else
return -1;
break;
}
case type_record:
{
try
{
pushMeta(curParam->queryRecordType());
}
catch (IException *E)
{
::Release(E);
return -1;
}
break;
}
default:
EclIR::dump_ir(curParam);
//code isn't here to pass sets/datasets to external functions....
return -1;
}
return sp;
}