本文整理汇总了C++中CppVariant::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ CppVariant::toString方法的具体用法?C++ CppVariant::toString怎么用?C++ CppVariant::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CppVariant
的用法示例。
在下文中一共展示了CppVariant::toString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cppVariantToWebString
WebString TestRunner::cppVariantToWebString(const CppVariant& value)
{
if (!value.isString()) {
printErrorMessage("Invalid value for preference. Expected string value.");
return WebString();
}
return WebString::fromUTF8(value.toString());
}
示例2: cppVariantToWebString
WebString LayoutTestController::cppVariantToWebString(const CppVariant& value)
{
if (!value.isString()) {
logErrorToConsole("Invalid value for preference. Expected string value.");
return WebString();
}
return WebString::fromUTF8(value.toString());
}
示例3: logErrorToConsole
int32_t LayoutTestController::cppVariantToInt32(const CppVariant& value)
{
if (value.isInt32())
return value.toInt32();
if (value.isString()) {
int number;
if (StringToInt(value.toString(), &number))
return number;
}
logErrorToConsole("Invalid value for preference. Expected integer value.");
return 0;
}
示例4: strtol
int32_t TestRunner::cppVariantToInt32(const CppVariant& value)
{
if (value.isNumber())
return value.toInt32();
if (value.isString()) {
string stringSource = value.toString();
const char* source = stringSource.data();
char* end;
long number = strtol(source, &end, 10);
if (end == source + stringSource.length() && number >= numeric_limits<int32_t>::min() && number <= numeric_limits<int32_t>::max())
return static_cast<int32_t>(number);
}
printErrorMessage("Invalid value for preference. Expected integer value.");
return 0;
}
示例5: 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;
}
示例6: 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;
}