本文整理汇总了C++中MemoryBuffer::append方法的典型用法代码示例。如果您正苦于以下问题:C++ MemoryBuffer::append方法的具体用法?C++ MemoryBuffer::append怎么用?C++ MemoryBuffer::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemoryBuffer
的用法示例。
在下文中一共展示了MemoryBuffer::append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: serialize
void CachedPasswordProvider::serialize(MemoryBuffer & out)
{
unsigned num = passwords.ordinality();
out.append(num);
ForEachItemIn(idx, passwords)
passwords.item(idx).serialize(out);
}
示例2: init
virtual void init()
{
HashDistributeMasterBase::init();
// JCSMORE should common up some with indexread
IHThorKeyedDistributeArg *helper = (IHThorKeyedDistributeArg *)queryHelper();
StringBuffer scoped;
queryThorFileManager().addScope(container.queryJob(), helper->getIndexFileName(), scoped);
Owned<IDistributedFile> f = queryThorFileManager().lookup(container.queryJob(), helper->getIndexFileName());
if (!f)
throw MakeActivityException(this, 0, "KeyedDistribute: Failed to find key: %s", scoped.str());
if (0 == f->numParts())
throw MakeActivityException(this, 0, "KeyedDistribute: Can't distribute based on an empty key: %s", scoped.str());
checkFormatCrc(this, f, helper->getFormatCrc(), true);
Owned<IFileDescriptor> fileDesc = f->getFileDescriptor();
Owned<IPartDescriptor> tlkDesc = fileDesc->getPart(fileDesc->numParts()-1);
if (!tlkDesc->queryProperties().hasProp("@kind") || 0 != stricmp("topLevelKey", tlkDesc->queryProperties().queryProp("@kind")))
throw MakeActivityException(this, 0, "Cannot distribute using a non-distributed key: '%s'", scoped.str());
unsigned location;
OwnedIFile iFile;
StringBuffer filePath;
if (!getBestFilePart(this, *tlkDesc, iFile, location, filePath))
throw MakeThorException(TE_FileNotFound, "Top level key part does not exist, for key: %s", f->queryLogicalName());
OwnedIFileIO iFileIO = iFile->open(IFOread);
assertex(iFileIO);
tlkMb.append(iFileIO->size());
::read(iFileIO, 0, (size32_t)iFileIO->size(), tlkMb);
queryThorFileManager().noteFileRead(container.queryJob(), f);
}
示例3: 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;
}
示例4: serializeStats
virtual void serializeStats(MemoryBuffer &mb)
{
CSlaveActivity::serializeStats(mb);
CriticalBlock b(joinHelperCrit);
rowcount_t p = joinhelper?joinhelper->getLhsProgress():0;
mb.append(p);
}
示例5: getResourceFromFile
extern bool getResourceFromFile(const char *filename, MemoryBuffer &data, const char * type, unsigned id)
{
#ifdef _WIN32
HINSTANCE dllHandle = LoadLibraryEx(filename, NULL, LOAD_LIBRARY_AS_DATAFILE|LOAD_LIBRARY_AS_IMAGE_RESOURCE);
if (dllHandle == NULL)
dllHandle = LoadLibraryEx(filename, NULL, LOAD_LIBRARY_AS_DATAFILE); // the LOAD_LIBRARY_AS_IMAGE_RESOURCE flag is not supported on all versions of Windows
if (dllHandle == NULL)
{
DBGLOG("Failed to load library %s: %d", filename, GetLastError());
return false;
}
HRSRC hrsrc = FindResource(dllHandle, MAKEINTRESOURCE(id), type);
if (!hrsrc)
return false;
size32_t len = SizeofResource(dllHandle, hrsrc);
const void *rdata = (const void *) LoadResource(dllHandle, hrsrc);
data.append(len, rdata);
FreeLibrary(dllHandle);
return true;
#else
bfd_init ();
bfd *file = bfd_openr(filename, NULL);
if (file)
{
StringBuffer sectionName;
sectionName.append(type).append("_").append(id).append(".data");
SecScanParam param(data, sectionName.str());
if (bfd_check_format (file, bfd_object))
bfd_map_over_sections (file, secscan, ¶m);
bfd_close (file);
}
return data.length() != 0;
#endif
}
示例6: serializeSlaveData
virtual void serializeSlaveData(MemoryBuffer &dst, unsigned slave)
{
IHThorSpillArg *helper = (IHThorSpillArg *)queryHelper();
IPartDescriptor *partDesc = fileDesc->queryPart(slave);
partDesc->serialize(dst);
dst.append(helper->getTempUsageCount());
}
示例7: serializeSlaveData
void CDiskReadMasterBase::serializeSlaveData(MemoryBuffer &dst, unsigned slave)
{
IHThorDiskReadBaseArg *helper = (IHThorDiskReadBaseArg *) queryHelper();
OwnedRoxieString fileName(helper->getFileName());
dst.append(fileName);
dst.append(subfileLogicalFilenames.ordinality());
if (subfileLogicalFilenames.ordinality())
{
ForEachItemIn(s, subfileLogicalFilenames)
dst.append(subfileLogicalFilenames.item(s));
}
if (mapping)
mapping->serializeMap(slave, dst);
else
CSlavePartMapping::serializeNullMap(dst);
}
示例8: getResourceFromFile
extern bool getResourceFromFile(const char *filename, MemoryBuffer &data, const char * type, unsigned id)
{
#ifdef _WIN32
HINSTANCE dllHandle = LoadLibraryEx(filename, NULL, LOAD_LIBRARY_AS_DATAFILE|LOAD_LIBRARY_AS_IMAGE_RESOURCE);
if (dllHandle == NULL)
dllHandle = LoadLibraryEx(filename, NULL, LOAD_LIBRARY_AS_DATAFILE); // the LOAD_LIBRARY_AS_IMAGE_RESOURCE flag is not supported on all versions of Windows
if (dllHandle == NULL)
{
DBGLOG("Failed to load library %s: %d", filename, GetLastError());
return false;
}
HRSRC hrsrc = FindResource(dllHandle, MAKEINTRESOURCE(id), type);
if (!hrsrc)
return false;
size32_t len = SizeofResource(dllHandle, hrsrc);
const void *rdata = (const void *) LoadResource(dllHandle, hrsrc);
data.append(len, rdata);
FreeLibrary(dllHandle);
return true;
#elif defined (_USE_BINUTILS)
CriticalBlock block(bfdCs);
bfd_init ();
bfd *file = bfd_openr(filename, NULL);
if (file)
{
StringBuffer sectionName;
sectionName.append(type).append("_").append(id).append(".data");
SecScanParam param(data, sectionName.str());
if (bfd_check_format (file, bfd_object))
bfd_map_over_sections (file, secscan, ¶m);
bfd_close (file);
}
return data.length() != 0;
#else
struct stat stat_buf;
VStringBuffer sectname("%s_%u", type, id);
int fd = open(filename, O_RDONLY);
if (fd == -1 || fstat(fd, &stat_buf) == -1)
{
DBGLOG("Failed to load library %s: %d", filename, errno);
return false;
}
bool ok = false;
__uint64 size = stat_buf.st_size;
const byte *start_addr = (const byte *) mmap(0, size, PROT_READ, MAP_FILE | MAP_PRIVATE, fd, 0);
if (start_addr == MAP_FAILED)
{
DBGLOG("Failed to load library %s: %d", filename, errno);
}
else
{
ok = getResourceFromMappedFile(filename, start_addr, data, type, id);
munmap((void *)start_addr, size);
}
close(fd);
return ok;
#endif
}
示例9: appendResource
extern DLLSERVER_API void appendResource(MemoryBuffer & mb, size32_t len, const void *data, bool compress)
{
mb.append((byte)0x80).append(resourceHeaderVersion);
if (compress)
compressToBuffer(mb, len, data);
else
appendToBuffer(mb, len, data);
}
示例10: serializeSlaveData
void CWriteMasterBase::serializeSlaveData(MemoryBuffer &dst, unsigned slave)
{
dst.append(diskHelperBase->getFileName());
if (diskHelperBase->getFlags() & TDXtemporary)
{
unsigned usageCount = container.queryJob().queryWorkUnit().queryFileUsage(diskHelperBase->getFileName());
if (0 == usageCount) usageCount = diskHelperBase->getTempUsageCount();
dst.append(usageCount);
}
if (dlfn.isExternal())
{
fileDesc->queryPart(0)->serialize(dst);
dst.append(mpTag);
}
else
fileDesc->queryPart(targetOffset+slave)->serialize(dst);
}
示例11: addWUQueryFilter
static bool addWUQueryFilter(WUSortField *filters, unsigned &count, MemoryBuffer &buff, const char *name, WUSortField value)
{
if (!name || !*name)
return false;
filters[count++] = value;
buff.append(name);
return true;
}
示例12: 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);
}
示例13: serializeCreateContext
virtual void serializeCreateContext(MemoryBuffer &mb)
{
// bit of hack, need to tell slave if wuidread converted to diskread (see master activity)
CMasterGraphElement::serializeCreateContext(mb);
if (kind == TAKworkunitread)
{
if (!activity)
doCreateActivity();
IHThorArg *helper = activity->queryHelper();
IHThorDiskReadArg *diskHelper = QUERYINTERFACE(helper, IHThorDiskReadArg);
mb.append(NULL != diskHelper); // flag to slaves that they should create diskread
if (diskHelper)
{
OwnedRoxieString fileName(diskHelper->getFileName());
mb.append(fileName);
}
}
}
示例14: doCmdFetchRaw
void RemoteDataSourceServer::doCmdFetchRaw(bool raw, MemoryBuffer & in, MemoryBuffer & out)
{
Owned<IFvDataSource> ds = readDataSource(in);
if (!ds)
{
out.append(false);
return;
}
__int64 requestedOffset;
in.read(requestedOffset);
MemoryBuffer temp;
bool ok = ds->fetchRawRow(temp, requestedOffset);
out.append(ok); // ok
out.append(temp.length());
out.append(temp.length(), temp.toByteArray());
}
示例15: fetchRowData
bool FullWorkUnitDataSource::fetchRowData(MemoryBuffer & out, __int64 offset)
{
size32_t length;
const void * data = rows->fetchRow(offset, length);
if (!data)
return false;
out.append(length, data);
return true;
}