当前位置: 首页>>代码示例>>C++>>正文


C++ CppVariant::toString方法代码示例

本文整理汇总了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());
}
开发者ID:,项目名称:,代码行数:8,代码来源:

示例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());
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:8,代码来源:LayoutTestController.cpp

示例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;
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:12,代码来源:LayoutTestController.cpp

示例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;
}
开发者ID:,项目名称:,代码行数:15,代码来源:

示例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;
}
开发者ID:,项目名称:,代码行数:18,代码来源:

示例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;
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:18,代码来源:LayoutTestController.cpp


注:本文中的CppVariant::toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。