本文整理汇总了C++中KeyValue::value方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyValue::value方法的具体用法?C++ KeyValue::value怎么用?C++ KeyValue::value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyValue
的用法示例。
在下文中一共展示了KeyValue::value方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
void Config::init ()
{
if (Path::is_file (MRTRIX_SYS_CONFIG_FILE)) {
INFO ("reading config file \"" MRTRIX_SYS_CONFIG_FILE "\"...");
try {
KeyValue kv (MRTRIX_SYS_CONFIG_FILE);
while (kv.next()) {
config[kv.key()] = kv.value();
}
}
catch (...) { }
}
std::string path = Path::join (Path::home(), MRTRIX_USER_CONFIG_FILE);
if (Path::is_file (path)) {
INFO ("reading config file \"" + path + "\"...");
try {
KeyValue kv (path);
while (kv.next()) {
config[kv.key()] = kv.value();
}
}
catch (...) { }
}
}
示例2: ida
bool
JetpackActorCommon::jsval_to_CompVariant(JSContext* cx, JSType type, jsval from,
CompVariant* to, OpaqueSeenType* seen)
{
if (type != JSTYPE_OBJECT)
return false;
js::LazilyConstructed<OpaqueSeenType> lost;
if (!seen) {
lost.construct();
seen = lost.addr();
if (!seen->ok())
return false;
}
OpaqueSeenType::KeyType obj = JSVAL_TO_OBJECT(from);
OpaqueSeenType::IdType id;
if (!seen->add(obj, &id)) {
if (OpaqueSeenType::kInvalidId == id)
return false;
*to = CompVariant(id);
return true;
}
if (JS_IsArrayObject(cx, obj)) {
nsTArray<Variant> elems;
jsuint len;
if (!JS_GetArrayLength(cx, obj, &len) ||
!elems.SetCapacity(len))
return false;
for (jsuint i = 0; i < len; ++i) {
jsval val;
Variant* vp = elems.AppendElement();
if (!JS_GetElement(cx, obj, i, &val) ||
!jsval_to_Variant(cx, val, vp, seen))
*vp = void_t();
}
*to = elems;
return true;
}
js::AutoIdArray ida(cx, JS_Enumerate(cx, obj));
if (!ida)
return false;
nsTArray<KeyValue> kvs;
for (size_t i = 0; i < ida.length(); ++i) {
jsval val; // reused for both key and value
if (!JS_IdToValue(cx, ida[i], &val))
return false;
JSString* idStr = JS_ValueToString(cx, val);
if (!idStr)
return false;
if (!JS_GetPropertyById(cx, obj, ida[i], &val))
return false;
KeyValue kv;
// Silently drop properties that can't be converted.
if (jsval_to_Variant(cx, val, &kv.value(), seen)) {
kv.key() = nsDependentString((PRUnichar*)JS_GetStringChars(idStr),
JS_GetStringLength(idStr));
// If AppendElement fails, we lose this property, no big deal.
kvs.AppendElement(kv);
}
}
*to = kvs;
return true;
}