本文整理汇总了C++中MemoryBuffer::length方法的典型用法代码示例。如果您正苦于以下问题:C++ MemoryBuffer::length方法的具体用法?C++ MemoryBuffer::length怎么用?C++ MemoryBuffer::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemoryBuffer
的用法示例。
在下文中一共展示了MemoryBuffer::length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: slaveDone
void slaveDone(size32_t slaveIdx, MemoryBuffer &mb)
{
if (mb.length()) // if 0 implies aborted out from this slave.
{
rowcount_t slaveProcessed;
mb.read(slaveProcessed);
recordsProcessed += slaveProcessed;
offset_t size, physicalSize;
mb.read(size);
mb.read(physicalSize);
unsigned fileCrc;
mb.read(fileCrc);
CDateTime modifiedTime(mb);
StringBuffer timeStr;
modifiedTime.getString(timeStr);
IPartDescriptor *partDesc = fileDesc->queryPart(slaveIdx);
IPropertyTree &props = partDesc->queryProperties();
props.setPropInt64("@size", size);
if (fileDesc->isCompressed())
props.setPropInt64("@compressedSize", physicalSize);
props.setPropInt("@fileCrc", fileCrc);
props.setProp("@modified", timeStr.str());
}
}
示例3: notify
void notify(MemoryBuffer &returndata) // if returns false should unsubscribe
{
if (hasaborted) {
throw MakeStringException(-1,"Subscription notification aborted");
return;
}
size32_t dlen = returndata.length();
CMessageBuffer mb;
mb.append(tag).append(sid).append(dlen).append(returndata);
try {
if (!queryWorldCommunicator().send(mb,dst,MPTAG_DALI_SUBSCRIPTION_FULFILL,1000*60*3)) {
// Must reply in 3 Minutes
// Kludge to avoid locking SDS on blocked client
hasaborted = true;
StringBuffer tmp;
throw MakeStringException(-1,"Subscription notification to %s timed out",dst->endpoint().getUrlStr(tmp).str());
return;
}
}
catch (IMP_Exception *e) {
PrintExceptionLog(e,"Dali CSubscriptionStub");
hasaborted = true;
throw;
}
}
示例4: decompressResource
extern DLLSERVER_API bool getResourceXMLFromFile(const char *filename, const char *type, unsigned id, StringBuffer &xml)
{
MemoryBuffer data;
if (!getResourceFromFile(filename, data, type, id))
return false;
return decompressResource(data.length(), data.toByteArray(), xml);
}
示例5: 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;
}
示例6: 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
}
示例7: done
virtual void done()
{
Owned<IWorkUnit> wu = &container.queryJob().queryWorkUnit().lock();
Owned<IWUResult> r = wu->updateResultBySequence(helper->getSequence());
r->setResultStatus(ResultStatusCalculated);
r->setResultLogicalName(outputName);
r.clear();
wu.clear();
IPropertyTree &props = newIndexDesc->queryProperties();
props.setProp("@kind", "key");
if (0 != (helper->getFlags() & KDPexpires))
setExpiryTime(props, helper->getExpiryDays());
// Fill in some logical file properties here
IPropertyTree &originalProps = originalDesc->queryProperties();;
if (originalProps.queryProp("ECL"))
props.setProp("ECL", originalProps.queryProp("ECL"));
MemoryBuffer rLMB;
if (originalProps.getPropBin("_record_layout", rLMB))
props.setPropBin("_record_layout", rLMB.length(), rLMB.toByteArray());
props.setPropInt("@formatCrc", originalProps.getPropInt("@formatCrc"));
if (originalProps.getPropBool("@local"))
props.setPropBool("@local", true);
container.queryTempHandler()->registerFile(outputName, container.queryOwner().queryGraphId(), 0, false, WUFileStandard, &clusters);
queryThorFileManager().publish(container.queryJob(), outputName, *newIndexDesc);
CMasterActivity::done();
}
示例8: slaveDone
virtual void slaveDone(size32_t slaveIdx, MemoryBuffer &mb)
{
if (mb.length()) // if 0 implies aborted out from this slave.
{
offset_t size;
mb.read(size);
CDateTime modifiedTime(mb);
IPartDescriptor *partDesc = newIndexDesc->queryPart(slaveIdx);
IPropertyTree &props = partDesc->queryProperties();
props.setPropInt64("@size", size);
StringBuffer timeStr;
modifiedTime.getString(timeStr);
props.setProp("@modified", timeStr.str());
if (!local && 0 == slaveIdx)
{
mb.read(size);
CDateTime modifiedTime(mb);
IPartDescriptor *partDesc = newIndexDesc->queryPart(newIndexDesc->numParts()-1);
IPropertyTree &props = partDesc->queryProperties();
props.setPropInt64("@size", size);
StringBuffer timeStr;
modifiedTime.getString(timeStr);
props.setProp("@modified", timeStr.str());
}
}
}
示例9: 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
}
示例10: sendFileChunk
void sendFileChunk(const char * filename, offset_t offset, ISocket * socket)
{
FILE *in = fopen(filename, "rb");
unsigned size = 0;
void * buff = NULL;
if (in)
{
fseek(in, 0, SEEK_END);
offset_t endOffset = ftell(in);
fseek(in, offset, SEEK_SET);
if (endOffset < offset)
size = 0;
else
size = (unsigned)(endOffset - offset);
if (size > CHUNK_SIZE)
size = CHUNK_SIZE;
buff = malloc(size);
size_t numRead = fread(buff, 1, size, in);
fclose(in);
if (numRead != size)
{
printf("read from file %s failed (%u/%u)\n", filename, (unsigned)numRead, size);
size = 0;
}
}
else
printf("read from file %s failed\n", filename);
if (size > 0)
{
MemoryBuffer sendBuffer;
unsigned rev = size + strlen(filename) + 10;
rev |= 0x80000000;
_WINREV(rev);
sendBuffer.append(rev);
sendBuffer.append('R');
rev = 0; // should put the sequence number here
_WINREV(rev);
sendBuffer.append(rev);
rev = 0; // should put the # of recs in msg here
_WINREV(rev);
sendBuffer.append(rev);
sendBuffer.append(strlen(filename)+1, filename);
sendBuffer.append(size, buff);
socket->write(sendBuffer.toByteArray(), sendBuffer.length());
}
else
{
unsigned zeroLen = 0;
socket->write(&zeroLen, sizeof(zeroLen));
}
free(buff);
}
示例11: slaveDone
virtual void slaveDone(size32_t slaveIdx, MemoryBuffer &mb)
{
if (mb.length()) // if 0 implies aborted out from this slave.
{
rowcount_t rc;
mb.read(rc);
recordsProcessed += rc;
}
}
示例12: fetchRowData
bool PagedWorkUnitDataSource::fetchRowData(MemoryBuffer & out, __int64 offset)
{
MemoryBuffer temp;
MemoryBuffer2IDataVal wrapper(out);
wuResult->getResultRaw(wrapper, offset, returnedMeta->getMaxRecordSize(), NULL, NULL);
if (temp.length() == 0)
return false;
return true;
}
示例13: ThorCompress
size32_t ThorCompress(const void * src, size32_t srcSz, MemoryBuffer & dest, size32_t threshold)
{
size32_t prev = dest.length();
size32_t dSz = srcSz + sizeof(size32_t);
void * d = dest.reserve(dSz);
size32_t ret = ThorCompress(src, srcSz, d, dSz, threshold);
dest.setLength(prev+ret);
return ret;
}
示例14: setRtlFormat
void setRtlFormat(IPropertyTree & properties, IOutputMetaData * meta)
{
if (meta && meta->queryTypeInfo())
{
MemoryBuffer out;
if (dumpTypeInfo(out, meta->querySerializedDiskMeta()->queryTypeInfo()))
properties.setPropBin("_rtlType", out.length(), out.toByteArray());
}
}
示例15: LoadMap
void CSendLogSerializer::LoadMap(MemoryBuffer& rawdata,StringBuffer& GUID, StringBuffer& line)
{
line.append(rawdata.length() -1, rawdata.toByteArray());
const char* strLine = line.str();
while(*strLine && *strLine != '\t' && *strLine != '\0')
{
GUID.append(*strLine);
strLine++;
}
}