本文整理汇总了C++中fb::JSObjectPtr::HasProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ JSObjectPtr::HasProperty方法的具体用法?C++ JSObjectPtr::HasProperty怎么用?C++ JSObjectPtr::HasProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fb::JSObjectPtr
的用法示例。
在下文中一共展示了JSObjectPtr::HasProperty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: countArrayLength
long FBTestPluginAPI::countArrayLength(const FB::JSObjectPtr &jso)
{
if (!jso->HasProperty("getArray"))
throw FB::invalid_arguments();
FB::VariantList array = jso->GetProperty("getArray").cast<FB::VariantList>();
long len = array.size();// array->GetProperty("length").convert_cast<long>();
return len;
}
示例2: thread_open
/**
* Asynchronous function to open a new session
*/
void CVMWebAPISession::thread_open( const FB::variant& oConfigHash ){
CRASH_REPORT_BEGIN;
int cpus = this->session->cpus;
int ram = this->session->memory;
int disk = this->session->disk;
int flags = this->session->flags;
std::string ver = this->session->version;
int ans = 0;
// If the user has provided an object, process overridable parameters
if (oConfigHash.is_of_type<FB::JSObjectPtr>()) {
FB::JSObjectPtr o = oConfigHash.cast<FB::JSObjectPtr>();
// Check basic overridable: options
if (o->HasProperty("cpus") && __canOverride("cpus", this->session)) cpus = o->GetProperty("cpus").convert_cast<int>();
if (o->HasProperty("ram") && __canOverride("ram", this->session)) ram = o->GetProperty("ram").convert_cast<int>();
if (o->HasProperty("disk") && __canOverride("disk", this->session)) disk = o->GetProperty("disk").convert_cast<int>();
// Check for overridable: flags
if (o->HasProperty("flags") && __canOverride("flags", this->session)) {
try {
flags = o->GetProperty("flags").convert_cast<int>();
} catch ( const FB::bad_variant_cast &) {
}
}
// Check for overridable: diskURL
if (o->HasProperty("diskURL") && __canOverride("diskURL", this->session)) {
ver = o->GetProperty("diskURL").convert_cast<std::string>();
flags |= HVF_DEPLOYMENT_HDD;
// Check for 64bit image
bool is64bit = false;
if (o->HasProperty("cpu64bit")) {
try {
is64bit = o->GetProperty("cpu64bit").convert_cast<bool>();
} catch ( const FB::bad_variant_cast &) {
is64bit = false;
}
}
if (is64bit)
flags |= HVF_SYSTEM_64BIT;
// Check for overridable: version
} else if (o->HasProperty("version") && __canOverride("version", this->session)) {
ver = o->GetProperty("version").convert_cast<std::string>();
if (!isSanitized(&ver, "01234567890.-")) ver=DEFAULT_CERNVM_VERSION;
flags |= HVF_SYSTEM_64BIT; // Micro is currently only 64-bit
}
}
// Open session with the given flags
ans = this->session->open( cpus, ram, disk, ver, flags );
if (ans == 0) {
WHEN_SAFE this->fire_open();
} else {
// Close session in case of a problem
this->session->close( true );
// Then fire errors
WHEN_SAFE this->fire_openError(hypervisorErrorStr(ans), ans);
WHEN_SAFE this->fire_error(hypervisorErrorStr(ans), ans, "open");
}
// The requirements of having a daemon might have changed
try {
CVMWebPtr p = this->getPlugin();
if (p->hv != NULL) p->hv->checkDaemonNeed();
} catch (...) {
// InvalidPlugin might occur if the user unloads
// the page while downloading the VM.
}
/* Start probing timer */
this->probeTimer->start();
CRASH_REPORT_END;
}