本文整理汇总了C++中CppVariant::toBoolean方法的典型用法代码示例。如果您正苦于以下问题:C++ CppVariant::toBoolean方法的具体用法?C++ CppVariant::toBoolean怎么用?C++ CppVariant::toBoolean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CppVariant
的用法示例。
在下文中一共展示了CppVariant::toBoolean方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cppVariantToBool
// Need these conversions because the format of the value for booleans
// may vary - for example, on mac "1" and "0" are used for boolean.
bool TestRunner::cppVariantToBool(const CppVariant& value)
{
if (value.isBool())
return value.toBoolean();
if (value.isNumber())
return value.toInt32();
if (value.isString()) {
string valueString = value.toString();
if (valueString == "true" || valueString == "1")
return true;
if (valueString == "false" || valueString == "0")
return false;
}
printErrorMessage("Invalid value. Expected boolean value.");
return false;
}
示例2: cppVariantToBool
// Need these conversions because the format of the value for booleans
// may vary - for example, on mac "1" and "0" are used for boolean.
bool LayoutTestController::cppVariantToBool(const CppVariant& value)
{
if (value.isBool())
return value.toBoolean();
if (value.isInt32())
return value.toInt32();
if (value.isString()) {
string valueString = value.toString();
if (valueString == "true" || valueString == "1")
return true;
if (valueString == "false" || valueString == "0")
return false;
}
logErrorToConsole("Invalid value. Expected boolean value.");
return false;
}