本文整理汇总了C++中LLSD::set方法的典型用法代码示例。如果您正苦于以下问题:C++ LLSD::set方法的具体用法?C++ LLSD::set怎么用?C++ LLSD::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLSD
的用法示例。
在下文中一共展示了LLSD::set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get
void SDTestObject::test<11>()
// array operations
{
SDCleanupCheck check;
LLSD v;
ensure_equals("undefined has no size", v.size(), 0);
ensure("undefined get() is undefined", v.get(0).isUndefined());
v = LLSD::emptyArray();
ensure("empty array is an array", v.isArray());
ensure_equals("empty array has no size", v.size(), 0);
ensure("empty map get() is undefined", v.get(0).isUndefined());
v.clear();
v.append(88);
v.append("noodle");
v.append(true);
ensure_equals("appened array size", v.size(), 3);
ensure("append array is an array", v.isArray());
ensureTypeAndValue("append 0", v[0], 88);
ensureTypeAndValue("append 1", v[1], "noodle");
ensureTypeAndValue("append 2", v[2], true);
v.insert(0, 77);
v.insert(2, "soba");
v.insert(4, false);
ensure_equals("inserted array size", v.size(), 6);
ensureTypeAndValue("post insert 0", v[0], 77);
ensureTypeAndValue("post insert 1", v[1], 88);
ensureTypeAndValue("post insert 2", v[2], "soba");
ensureTypeAndValue("post insert 3", v[3], "noodle");
ensureTypeAndValue("post insert 4", v[4], false);
ensureTypeAndValue("post insert 5", v[5], true);
ensureTypeAndValue("get 1", v.get(1), 88);
v.set(1, "hot");
ensureTypeAndValue("set 1", v.get(1), "hot");
v.erase(3);
ensure_equals("post erase array size", v.size(), 5);
ensureTypeAndValue("post erase 0", v[0], 77);
ensureTypeAndValue("post erase 1", v[1], "hot");
ensureTypeAndValue("post erase 2", v[2], "soba");
ensureTypeAndValue("post erase 3", v[3], false);
ensureTypeAndValue("post erase 4", v[4], true);
v.append(34);
ensure_equals("size after append", v.size(), 6);
ensureTypeAndValue("post append 5", v[5], 34);
LLSD w;
w = v;
ensure("copy array type", w.isArray());
ensure_equals("copy array size", w.size(), 6);
ensureTypeAndValue("copy array 0", w[0], 77);
ensureTypeAndValue("copy array 1", w[1], "hot");
ensureTypeAndValue("copy array 2", w[2], "soba");
ensureTypeAndValue("copy array 3", w[3], false);
ensureTypeAndValue("copy array 4", w[4], true);
ensureTypeAndValue("copy array 5", w[5], 34);
}
示例2: setControlValueCB
//----------------------------------------------------------------------------
// LLControlGroupCLP defintions
//----------------------------------------------------------------------------
void setControlValueCB(const LLCommandLineParser::token_vector_t& value,
const std::string& opt_name,
LLControlGroup* ctrlGroup)
{
// *FIX: Do sematic conversion here.
// LLSD (ImplString) Is no good for doing string to type conversion for...
// booleans
// compound types
// ?...
LLControlVariable* ctrl = ctrlGroup->getControl(opt_name);
if(NULL != ctrl)
{
switch(ctrl->type())
{
case TYPE_BOOLEAN:
if(value.size() > 1)
{
llwarns << "Ignoring extra tokens." << llendl;
}
if(value.size() > 0)
{
// There's a token. check the string for true/false/1/0 etc.
BOOL result = false;
BOOL gotSet = LLStringUtil::convertToBOOL(value[0], result);
if(gotSet)
{
ctrl->setValue(LLSD(result), false);
}
}
else
{
ctrl->setValue(LLSD(true), false);
}
break;
default:
{
// For the default types, let llsd do the conversion.
if(value.size() > 1 && ctrl->isType(TYPE_LLSD))
{
// Assume its an array...
LLSD llsdArray;
for(unsigned int i = 0; i < value.size(); ++i)
{
LLSD llsdValue;
llsdValue.assign(LLSD::String(value[i]));
llsdArray.set(i, llsdValue);
}
ctrl->setValue(llsdArray, false);
}
else if(value.size() > 0)
{
if(value.size() > 1)
{
llwarns << "Ignoring extra tokens mapped to the setting: " << opt_name << "." << llendl;
}
LLSD llsdValue;
llsdValue.assign(LLSD::String(value[0]));
ctrl->setValue(llsdValue, false);
}
}
break;
}
}
else
{
llwarns << "Command Line option mapping '"
<< opt_name
<< "' not found! Ignoring."
<< llendl;
}
}