本文整理汇总了C++中STRING::reserve方法的典型用法代码示例。如果您正苦于以下问题:C++ STRING::reserve方法的具体用法?C++ STRING::reserve怎么用?C++ STRING::reserve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类STRING
的用法示例。
在下文中一共展示了STRING::reserve方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ToXml
/////////////////////////////////////////
// Write feature information as XML document.
//
MgByteReader* MgFeatureInformation::ToXml()
{
STRING xml;
STRING xmlSelection = m_selection? m_selection->ToXml(false): L"";
// TODO: define a schema for this XML
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(m_tooltip.length() > 0)
{
xml.append(L"<Tooltip>");
xml.append(MgUtil::ReplaceEscapeCharInXml(m_tooltip));
xml.append(L"</Tooltip>\n");
}
else
xml.append(L"<Tooltip />\n");
if(m_hyperlink.length() > 0)
{
xml.append(L"<Hyperlink>");
xml.append(MgUtil::ReplaceEscapeCharInXml(m_hyperlink));
xml.append(L"</Hyperlink>\n");
}
else
xml.append(L"<Hyperlink />\n");
if(m_properties != NULL)
{
for(int i = 0; i < m_properties->GetCount(); i++)
{
Ptr<MgStringProperty> prop = (MgStringProperty*)m_properties->GetItem(i);
xml.append(L"<Property name=\"");
xml.append(MgUtil::ReplaceEscapeCharInXml(prop->GetName()));
xml.append(L"\" value=\"");
xml.append(MgUtil::ReplaceEscapeCharInXml(prop->GetValue()));
xml.append(L"\" />\n");
}
}
xml.append(L"</FeatureInformation>\n");
string xmlDoc = MgUtil::WideCharToMultiByte(xml);
STRING mimeType = L"text/xml";
return MgUtil::GetByteReader(xmlDoc, &mimeType);
}
示例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);
}