本文整理汇总了C++中Ptr::Bytes方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::Bytes方法的具体用法?C++ Ptr::Bytes怎么用?C++ Ptr::Bytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ptr
的用法示例。
在下文中一共展示了Ptr::Bytes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetMapDefinition
//static method to create the map definition
MdfModel::MapDefinition* MgMapBase::GetMapDefinition(MgResourceService* svcResource, MgResourceIdentifier* resId)
{
// get and parse the map definition
Ptr<MgByteReader> reader = svcResource->GetResourceContent(resId, L"");
Ptr<MgByteSink> sink = new MgByteSink(reader);
Ptr<MgByte> bytes = sink->ToBuffer();
assert(bytes->GetLength() > 0);
MdfParser::SAX2Parser parser;
parser.ParseString((const char*)bytes->Bytes(), bytes->GetLength());
if (!parser.GetSucceeded())
{
STRING errorMsg = parser.GetErrorMessage();
MgStringCollection arguments;
arguments.Add(errorMsg);
throw new MgInvalidMapDefinitionException(L"MgMapBase::GetMapDefinition", __LINE__, __WFILE__, &arguments, L"", NULL);
}
// detach the map definition from the parser - it's
// now the caller's responsibility to delete it
MdfModel::MapDefinition* mdef = parser.DetachMapDefinition();
assert(mdef != NULL);
return mdef;
}
示例2: CollectQueryMapFeaturesResult
MgByteReader* MgHtmlController::CollectQueryMapFeaturesResult(MgResourceService* resourceService,
INT32 requestData,
MgFeatureInformation* featInfo,
MgSelection* selectionSet,
MgBatchPropertyCollection* attributes,
MgByteReader* inlineSelection)
{
STRING xml;
STRING tooltip;
STRING hyperlink;
STRING xmlSelection = selectionSet? selectionSet->ToXml(false): L"";
if (NULL != featInfo)
{
tooltip = featInfo->GetTooltip();
hyperlink = featInfo->GetHyperlink();
}
// TODO: Stil haven't defined a schema for v2.6. Should we?
xml.append(L"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<FeatureInformation>\n");
size_t len = xmlSelection.length();
if(len > 0)
{
xml.reserve(len + 2048);
xml.append(xmlSelection);
}
else
{
xml.reserve(2048);
xml.append(L"<FeatureSet />\n");
}
if (((requestData & REQUEST_TOOLTIP) == REQUEST_TOOLTIP) && !tooltip.empty())
{
xml.append(L"<Tooltip>");
xml.append(MgUtil::ReplaceEscapeCharInXml(tooltip));
xml.append(L"</Tooltip>\n");
}
else
xml.append(L"<Tooltip />\n");
if (((requestData & REQUEST_HYPERLINK) == REQUEST_HYPERLINK) && !hyperlink.empty())
{
xml.append(L"<Hyperlink>");
xml.append(MgUtil::ReplaceEscapeCharInXml(hyperlink));
xml.append(L"</Hyperlink>\n");
}
else
xml.append(L"<Hyperlink />\n");
if (((requestData & REQUEST_INLINE_SELECTION) == REQUEST_INLINE_SELECTION) && NULL != inlineSelection)
{
xml.append(L"<InlineSelectionImage>\n");
xml.append(L"<MimeType>");
xml.append(inlineSelection->GetMimeType());
xml.append(L"</MimeType>\n");
xml.append(L"<Content>");
MgByteSink sink(inlineSelection);
Ptr<MgByte> bytes = sink.ToBuffer();
Ptr<MgMemoryStreamHelper> streamHelper = new MgMemoryStreamHelper((INT8*) bytes->Bytes(), bytes->GetLength(), false);
std::string b64 = streamHelper->ToBase64();
STRING wb64 = MgUtil::MultiByteToWideChar(b64);
xml.append(wb64);
xml.append(L"</Content>\n");
xml.append(L"</InlineSelectionImage>\n");
}
else
xml.append(L"<InlineSelectionImage />\n");
if (((requestData & REQUEST_ATTRIBUTES) == REQUEST_ATTRIBUTES) && NULL != attributes)
{
xml.append(L"<SelectedFeatures>\n");
WriteSelectedFeatureAttributes(resourceService, selectionSet, attributes, xml);
xml.append(L"</SelectedFeatures>\n");
}
else
xml.append(L"<SelectedFeatures />\n");
xml.append(L"</FeatureInformation>\n");
string xmlDoc = MgUtil::WideCharToMultiByte(xml);
STRING mimeType = L"text/xml";
return MgUtil::GetByteReader(xmlDoc, &mimeType);
}