本文整理汇总了C++中fb::VariantList::end方法的典型用法代码示例。如果您正苦于以下问题:C++ VariantList::end方法的具体用法?C++ VariantList::end怎么用?C++ VariantList::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fb::VariantList
的用法示例。
在下文中一共展示了VariantList::end方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exec
FB::variant FB::JSFunction::call( const std::vector<variant>& args )
{
FB::VariantList list;
if (args.size() >= 1) {
list.insert(list.end(), args.begin()+1, args.end());
}
return exec(list);
}
示例2: push
FB::JSArray::JSArray(BrowserHostPtr host, const FB::VariantList& values)
{
m_obj = host->getDOMWindow()->createArray();
for (FB::VariantList::const_iterator it = values.begin(); it != values.end(); ++it)
{
push(*it);
}
RegisterMethods();
}
示例3: variantToJsonValue
Json::Value variantToJsonValue(const FB::variant &val)
{
if (val.is_of_type<std::string>()) {
return Json::Value(val.convert_cast<std::string>());
} else if (val.is_of_type<FB::VariantMap>()) {
Json::Value retVal(Json::objectValue);
FB::VariantMap map = val.cast<FB::VariantMap>();
for (FB::VariantMap::iterator it = map.begin(); it != map.end(); ++it) {
retVal[it->first] = variantToJsonValue(it->second);
}
return retVal;
} else if (val.is_of_type<FB::VariantList>()) {
Json::Value retVal(Json::arrayValue);
FB::VariantList list = val.cast<FB::VariantList>();
for (FB::VariantList::iterator it = list.begin(); it != list.end(); ++it) {
retVal.append(variantToJsonValue(*it));
}
return retVal;
} else if (val.is_of_type<int>()
|| val.is_of_type<char>()
|| val.is_of_type<short>()
|| val.is_of_type<long>()) {
return Json::Value((Json::Int)val.convert_cast<long>());
} else if (val.is_of_type<unsigned int>()
|| val.is_of_type<unsigned short>()
|| val.is_of_type<unsigned char>()
|| val.is_of_type<unsigned long>()) {
return Json::Value((Json::UInt) val.convert_cast<unsigned long>());
} else if (val.is_of_type<double>() || val.is_of_type<float>()) {
return Json::Value(val.convert_cast<double>());
} else if (val.is_of_type<bool>()) {
return Json::Value(val.convert_cast<bool>());
} else {
return Json::Value(Json::nullValue);
}
}
示例4: getNPVariant
void NpapiBrowserHost::getNPVariant(NPVariant *dst, const FB::variant &var)
{
if (var.get_type() == typeid(FB::Npapi::NpapiNull)) {
dst->type = NPVariantType_Null;
} else if (var.get_type() == typeid(int)
|| var.get_type() == typeid(long)
|| var.get_type() == typeid(short)
|| var.get_type() == typeid(char)
|| var.get_type() == typeid(unsigned int)
|| var.get_type() == typeid(unsigned short)
|| var.get_type() == typeid(unsigned char)) {
// Integer type
dst->type = NPVariantType_Int32;
dst->value.intValue = var.convert_cast<long>();
} else if (var.get_type() == typeid(double)
|| var.get_type() == typeid(float)) {
dst->type = NPVariantType_Double;
dst->value.doubleValue = var.convert_cast<double>();
} else if (var.get_type() == typeid(bool)) {
dst->type = NPVariantType_Bool;
dst->value.boolValue = var.convert_cast<bool>();
} else if (var.get_type() == typeid(std::string)) {
std::string str = var.convert_cast<std::string>();
char *outStr = (char*)this->MemAlloc(str.size() + 1);
memcpy(outStr, str.c_str(), str.size() + 1);
dst->type = NPVariantType_String;
dst->value.stringValue.UTF8Characters = outStr;
dst->value.stringValue.UTF8Length = str.size();
} else if (var.get_type() == typeid(FB::VariantList)) {
JSAPI_DOMNode outArr = this->getDOMWindow().createArray();
FB::VariantList inArr = var.cast<FB::VariantList>();
for (FB::VariantList::iterator it = inArr.begin(); it != inArr.end(); it++) {
outArr.callMethod<void>("push", variant_list_of(*it));
}
FB::AutoPtr<NPObjectAPI> api = dynamic_cast<NPObjectAPI*>(outArr.getJSObject().ptr());
if (api.ptr() != NULL) {
dst->type = NPVariantType_Object;
dst->value.objectValue = api->getNPObject();
this->RetainObject(dst->value.objectValue);
}
} else if (var.get_type() == typeid(FB::VariantMap)) {
JSAPI_DOMNode out = this->getDOMWindow().createMap();
FB::VariantMap inMap = var.cast<FB::VariantMap>();
for (FB::VariantMap::iterator it = inMap.begin(); it != inMap.end(); it++) {
out.setProperty(it->first, it->second);
}
FB::AutoPtr<NPObjectAPI> api = dynamic_cast<NPObjectAPI*>(out.getJSObject().ptr());
if (api.ptr() != NULL) {
dst->type = NPVariantType_Object;
dst->value.objectValue = api->getNPObject();
this->RetainObject(dst->value.objectValue);
}
} else if (var.get_type() == typeid(FB::JSOutObject)) {
NPObject *outObj = NULL;
FB::JSOutObject obj = var.cast<FB::JSOutObject>();
NPObjectAPI *tmpObj = dynamic_cast<NPObjectAPI *>(obj.ptr());
if (tmpObj == NULL) {
outObj = NPJavascriptObject::NewObject(this, obj);
} else {
outObj = tmpObj->getNPObject();
this->RetainObject(outObj);
}
dst->type = NPVariantType_Object;
dst->value.objectValue = outObj;
} else if (var.get_type() == typeid(FB::JSObject)) {
NPObject *outObj = NULL;
FB::JSObject obj = var.cast<JSObject>();
NPObjectAPI *tmpObj = dynamic_cast<NPObjectAPI *>(obj.ptr());
if (tmpObj == NULL) {
outObj = NPJavascriptObject::NewObject(this, obj);
} else {
outObj = tmpObj->getNPObject();
this->RetainObject(outObj);
}
dst->type = NPVariantType_Object;
dst->value.objectValue = outObj;
}
// TODO: implement object types
}