本文整理汇总了C++中yarp::os::Bottle::addDict方法的典型用法代码示例。如果您正苦于以下问题:C++ Bottle::addDict方法的具体用法?C++ Bottle::addDict怎么用?C++ Bottle::addDict使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yarp::os::Bottle
的用法示例。
在下文中一共展示了Bottle::addDict方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lock
void
RequestMap::fillInListReply(yarp::os::Bottle & reply)
{
ODL_OBJENTER(); //####
try
{
lock();
if (0 < _handlers.size())
{
for (RequestHandlerMap::const_iterator walker = _handlers.begin();
_handlers.end() != walker; ++walker)
{
yarp::os::Property & aDict = reply.addDict();
BaseRequestHandler * aHandler = walker->second;
aHandler->fillInDescription(walker->first.c_str(), aDict);
}
}
unlock();
}
catch (...)
{
ODL_LOG("Exception caught"); //####
throw;
}
ODL_OBJEXIT(); //####
} // RequestMap::fillInListReply
示例2: asRootedValue
//.........这里部分代码省略.........
{
// Treat as a list
if (topLevel)
{
for (uint32_t ii = 0; arrayLength > ii; ++ii)
{
JS::RootedValue anElement(jct);
if (JS_GetElement(jct, asObject, ii, &anElement))
{
fillBottleFromValue(jct, aBottle, anElement, false);
}
}
}
else
{
yarp::os::Bottle & innerList(aBottle.addList());
for (uint32_t ii = 0; arrayLength > ii; ++ii)
{
JS::RootedValue anElement(jct);
if (JS_GetElement(jct, asObject, ii, &anElement))
{
fillBottleFromValue(jct, innerList, anElement, false);
}
}
}
processed = true;
}
}
if (! processed)
{
// Treat as a dictionary
yarp::os::Property & innerDict(aBottle.addDict());
#if (47 <= MOZJS_MAJOR_VERSION)
JS::Rooted<JS::IdVector> ids(jct, JS::IdVector(jct));
#else // 47 > MOZJS_MAJOR_VERSION
JS::AutoIdArray ids(jct, JS_Enumerate(jct, asObject));
#endif // 47 > MOZJS_MAJOR_VERSION
#if (47 <= MOZJS_MAJOR_VERSION)
if (JS_Enumerate(jct, asObject, &ids))
#else // 47 > MOZJS_MAJOR_VERSION
// Note that only operator! is defined, so we need to do a 'double-negative'.
if (!! ids)
#endif // 47 > MOZJS_MAJOR_VERSION
{
for (size_t ii = 0, len = ids.length(); len > ii; ++ii)
{
JS::RootedValue key(jct);
if (JS_IdToValue(jct, ids[ii], &key))
{
JS::RootedValue key(jct);
JS::RootedValue result(jct);
JS::RootedId aRootedId(jct);
aRootedId = ids[ii];
if (JS_IdToValue(jct, ids[ii], &key) &&
JS_GetPropertyById(jct, asObject, aRootedId, &result))
{
JSString * keyString = key.toString();
char * keyAsChars = JS_EncodeString(jct, keyString);
YarpString keyToUse(keyAsChars);
yarp::os::Bottle convertedResult;
JS_free(jct, keyAsChars);
fillBottleFromValue(jct, convertedResult, result, false);
if (1 == convertedResult.size())
{
yarp::os::Value anElement(convertedResult.get(0));
if (anElement.isInt())
{
innerDict.put(keyToUse, anElement.asInt());
}
else if (anElement.isDouble())
{
innerDict.put(keyToUse, anElement.asDouble());
}
else if (anElement.isString())
{
innerDict.put(keyToUse, anElement.asString());
}
else
{
innerDict.put(keyToUse, anElement);
}
}
}
}
}
}
}
}
}
ODL_EXIT(); //####
} // fillBottleFromValue