本文整理汇总了C++中JSONArray::Reserve方法的典型用法代码示例。如果您正苦于以下问题:C++ JSONArray::Reserve方法的具体用法?C++ JSONArray::Reserve怎么用?C++ JSONArray::Reserve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONArray
的用法示例。
在下文中一共展示了JSONArray::Reserve方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveJSON
bool ValueAnimation::SaveJSON(JSONValue& dest) const
{
dest.Set("interpolationmethod", interpMethodNames[interpolationMethod_]);
if (interpolationMethod_ == IM_SPLINE)
dest.Set("splinetension", (float) splineTension_);
JSONArray keyFramesArray;
keyFramesArray.Reserve(keyFrames_.Size());
for (unsigned i = 0; i < keyFrames_.Size(); ++i)
{
const VAnimKeyFrame& keyFrame = keyFrames_[i];
JSONValue keyFrameVal;
keyFrameVal.Set("time", keyFrame.time_);
JSONValue valueVal;
valueVal.SetVariant(keyFrame.value_);
keyFrameVal.Set("value", valueVal);
keyFramesArray.Push(keyFrameVal);
}
dest.Set("keyframes", keyFramesArray);
JSONArray eventFramesArray;
eventFramesArray.Reserve(eventFrames_.Size());
for (unsigned i = 0; i < eventFrames_.Size(); ++i)
{
const VAnimEventFrame& eventFrame = eventFrames_[i];
JSONValue eventFrameVal;
eventFrameVal.Set("time", eventFrame.time_);
eventFrameVal.Set("eventtype", eventFrame.eventType_.Value());
JSONValue eventDataVal;
eventDataVal.SetVariantMap(eventFrame.eventData_);
eventFrameVal.Set("eventdata", eventDataVal);
eventFramesArray.Push(eventFrameVal);
}
dest.Set("eventframes", eventFramesArray);
return true;
}
示例2: SaveJSON
bool UnknownComponent::SaveJSON(JSONValue& dest) const
{
if (!useXML_)
ATOMIC_LOGWARNING("UnknownComponent loaded in binary mode, attributes will be empty for JSON save");
// Write type and ID
dest.Set("type", GetTypeName());
dest.Set("id", (int) id_);
JSONArray attributesArray;
attributesArray.Reserve(xmlAttributeInfos_.Size());
for (unsigned i = 0; i < xmlAttributeInfos_.Size(); ++i)
{
JSONValue attrVal;
attrVal.Set("name", xmlAttributeInfos_[i].name_);
attrVal.Set("value", xmlAttributes_[i]);
attributesArray.Push(attrVal);
}
dest.Set("attributes", attributesArray);
return true;
}