本文整理汇总了C++中MemoryBuffer::toByteArray方法的典型用法代码示例。如果您正苦于以下问题:C++ MemoryBuffer::toByteArray方法的具体用法?C++ MemoryBuffer::toByteArray怎么用?C++ MemoryBuffer::toByteArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemoryBuffer
的用法示例。
在下文中一共展示了MemoryBuffer::toByteArray方法的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: 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);
}
示例3: 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();
}
示例4: 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);
}
示例5: 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());
}
}
示例6: send
void CThorTransferGroup::send(SocketEndpoint &ep, CThorRowArray & group)
{
ISocket * sendSkt = ISocket::connect_wait(ep, 360*120*1000); // give it plenty of time, sequential in nature *could* be delayed in other side listening
sendSkt->set_block_mode(BF_SYNC_TRANSFER_PULL,0,TRANSFER_TIMEOUT);
MemoryBuffer mb;
group.serialize(serializer,mb,false);
sendSkt->send_block(mb.toByteArray(),mb.length());
sendSkt->close();
sendSkt->Release();
}
示例7: 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++;
}
}
示例8: serializeRecordMeta
extern DEFTYPE_API void serializeRecordMeta(MemoryBuffer & target, IDefRecordMeta * meta, bool compress)
{
if (compress)
{
MemoryBuffer temp;
doSerializeRecordMeta(temp, meta);
compressToBuffer(target, temp.length(), temp.toByteArray());
}
else
doSerializeRecordMeta(target, meta);
}
示例9: sprintf
void LdapUtils::bin2str(MemoryBuffer& from, StringBuffer& to)
{
const char* frombuf = from.toByteArray();
char tmp[3];
for(unsigned i = 0; i < from.length(); i++)
{
unsigned char c = frombuf[i];
sprintf(tmp, "%02X", c);
tmp[2] = 0;
to.append("\\").append(tmp);
}
}
示例10: addManifestFromArchive
void ResourceManager::addManifestFromArchive(IPropertyTree *archive)
{
if (!archive)
return;
if (finalized)
throwError1(HQLERR_ResourceAddAfterFinalManifest, "MANIFEST");
ensureManifestInfo();
Owned<IPropertyTreeIterator> manifests = archive->getElements("AdditionalFiles/Manifest");
ForEach(*manifests)
{
const char *xml = manifests->query().queryProp(NULL);
Owned<IPropertyTree> manifestSrc = createPTreeFromXMLString(xml);
Owned<IAttributeIterator> aiter = manifestSrc->getAttributes();
ForEach (*aiter)
manifest->setProp(aiter->queryName(), aiter->queryValue());
StringBuffer manifestDir;
if (manifestSrc->hasProp("@originalFilename"))
splitDirTail(manifestSrc->queryProp("@originalFilename"), manifestDir);
Owned<IPropertyTreeIterator> iter = manifestSrc->getElements("*");
ForEach(*iter)
{
IPropertyTree &item = iter->query();
if (streq(item.queryName(), "Resource") && item.hasProp("@filename"))
{
if (!item.hasProp("@type"))
item.setProp("@type", "UNKNOWN");
const char *filename;
if (item.hasProp("@originalFilename"))
filename = item.queryProp("@originalFilename");
else
filename = item.queryProp("@filename");
int id;
if (getDuplicateResourceId(item.queryProp("@type"), NULL, filename, id))
{
item.setPropInt("@id", (int)id);
manifest->addPropTree("Resource", LINK(&item));
}
else
{
VStringBuffer xpath("AdditionalFiles/Resource[@originalFilename=\"%s\"]", filename);
MemoryBuffer content;
archive->getPropBin(xpath.str(), content);
addCompress(item.queryProp("@type"), content.length(), content.toByteArray(), &item);
}
}
else
manifest->addPropTree(item.queryName(), LINK(&item));
}
}
}
示例11: addCompress
bool ResourceManager::addCompress(const char * type, unsigned len, const void * data, IPropertyTree *manifestEntry, unsigned id, bool addToManifest)
{
bool isCompressed=false;
if (len>=32) //lzw assert if too small
{
isCompressed = true;
MemoryBuffer compressed;
compressResource(compressed, len, data);
addNamed(type, compressed.length(), compressed.toByteArray(), manifestEntry, id, addToManifest, isCompressed);
}
else
addNamed(type, len, data, manifestEntry, id, addToManifest, isCompressed);
return isCompressed;
}
示例12: LoadMap
void CRecieveLogSerializer::LoadMap(MemoryBuffer& rawdata,GuidMap& GUIDmap, bool printTrace)
{
//buffer chould be in the form of 000000030\t2515777767.12_11_03_08_25_29\r
//we want to extract the GUID only....
StringBuffer line,GUID;
line.append(rawdata.length() -1, rawdata.toByteArray());
const char* strLine = line.str();
while(*strLine && *strLine != '\t' && *strLine != '\0')
{
GUID.append(*strLine);
strLine++;
}
if(printTrace)
DBGLOG("[%s]", GUID.str());
GUIDmap[GUID.str()] = "1";
}
示例13: onFinishUpload
int CFileSpraySoapBindingEx::onFinishUpload(IEspContext &ctx, CHttpRequest* request, CHttpResponse* response, const char *service, const char *method, StringArray& fileNames, StringArray& files, IMultiException *me)
{
if (!me || (me->ordinality()==0))
{
if (ctx.getResponseFormat()==ESPSerializationANY)
{
StringBuffer newUrl, netAddress, path;
request->getParameter("NetAddress", netAddress);
request->getParameter("Path", path);
newUrl.appendf("/FileSpray/DropZoneFiles?NetAddress=%s&Path=%s", netAddress.str(), path.str());
response->redirect(*request, newUrl.str());
}
else
{
IArrayOf<IEspDFUActionResult> results;
Owned<CUploadFilesResponse> esp_response = new CUploadFilesResponse("FileSpray");
ForEachItemIn(i, fileNames)
{
const char* fileName = fileNames.item(i);
Owned<IEspDFUActionResult> res = createDFUActionResult("", "");
res->setID(fileName);
res->setAction("Upload File");
res->setResult("Success");
results.append(*res.getLink());
}
if (!results.length())
{
Owned<IEspDFUActionResult> res = createDFUActionResult("", "");
res->setID("<N/A>");
res->setAction("Upload File");
res->setResult("No file uploaded");
results.append(*res.getLink());
}
esp_response->setUploadFileResults(results);
MemoryBuffer content;
StringBuffer mimetype;
esp_response->appendContent(&ctx,content, mimetype);
response->setContent(content.length(), content.toByteArray());
response->setContentType(mimetype.str());
response->send();
}
}
else
{
示例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: addManifest
void ResourceManager::addManifest(const char *filename)
{
if (finalized)
throwError1(HQLERR_ResourceAddAfterFinalManifest, "MANIFEST");
Owned<IPropertyTree> manifestSrc = createPTreeFromXMLFile(filename);
StringBuffer dir;
splitDirTail(filename, dir);
ensureManifestInfo();
Owned<IAttributeIterator> aiter = manifestSrc->getAttributes();
ForEach (*aiter)
manifest->setProp(aiter->queryName(), aiter->queryValue());
Owned<IPropertyTreeIterator> iter = manifestSrc->getElements("*");
ForEach(*iter)
{
IPropertyTree &item = iter->query();
if (streq(item.queryName(), "Resource") && item.hasProp("@filename"))
{
if (!item.hasProp("@type"))
item.setProp("@type", "UNKNOWN");
const char *filename = item.queryProp("@filename");
int id;
if (getDuplicateResourceId(item.queryProp("@type"), filename, id))
{
item.setPropInt("@id", id);
manifest->addPropTree("Resource", LINK(&item));
}
else
{
StringBuffer fullpath;
if (!isAbsolutePath(filename))
fullpath.append(dir);
fullpath.append(filename);
MemoryBuffer content;
loadResource(fullpath.str(), content);
addCompress(item.queryProp("@type"), content.length(), content.toByteArray(), &item);
}
}
else
manifest->addPropTree(item.queryName(), LINK(&item));
}
}