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


C++ SkString::equals方法代码示例

本文整理汇总了C++中SkString::equals方法的典型用法代码示例。如果您正苦于以下问题:C++ SkString::equals方法的具体用法?C++ SkString::equals怎么用?C++ SkString::equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SkString的用法示例。


在下文中一共展示了SkString::equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: test_get_basename

static void test_get_basename(skiatest::Reporter* reporter) {
    SkString result;
    SkString path("/path/basename");
    sk_tools::get_basename(&result, path);
    REPORTER_ASSERT(reporter, result.equals("basename"));

    result.reset();
    path.set("/path/dir/");
    sk_tools::get_basename(&result, path);
    REPORTER_ASSERT(reporter, result.equals("dir"));

    result.reset();
    path.set("path");
    sk_tools::get_basename(&result, path);
    REPORTER_ASSERT(reporter, result.equals("path"));

#if defined(SK_BUILD_FOR_WIN)
    result.reset();
    path.set("path\\winbasename");
    sk_tools::get_basename(&result, path);
    REPORTER_ASSERT(reporter, result.equals("winbasename"));

    result.reset();
    path.set("path\\windir\\");
    sk_tools::get_basename(&result, path);
    REPORTER_ASSERT(reporter, result.equals("windir"));
#endif
}
开发者ID:Cue,项目名称:skia,代码行数:28,代码来源:PictureUtilsTest.cpp

示例2: parse_option_bool

static bool parse_option_bool(const SkString& value, bool* outBool) {
    if (value.equals("true")) {
        *outBool = true;
        return true;
    }
    if (value.equals("false")) {
        *outBool = false;
        return true;
    }
    return false;
}
开发者ID:03050903,项目名称:skia,代码行数:11,代码来源:SkCommonFlagsConfig.cpp

示例3: parse_option_gpu_api

static bool parse_option_gpu_api(const SkString& value,
                                 SkCommandLineConfigGpu::ContextType* outContextType) {
    if (value.equals("native")) {
        *outContextType = GrContextFactory::kNative_GLContextType;
        return true;
    }
    if (value.equals("gl")) {
        *outContextType = GrContextFactory::kGL_GLContextType;
        return true;
    }
    if (value.equals("gles")) {
        *outContextType = GrContextFactory::kGLES_GLContextType;
        return true;
    }
    if (value.equals("debug")) {
        *outContextType = GrContextFactory::kDebug_GLContextType;
        return true;
    }
    if (value.equals("null")) {
        *outContextType = GrContextFactory::kNull_GLContextType;
        return true;
    }
#if SK_ANGLE
#ifdef SK_BUILD_FOR_WIN
    if (value.equals("angle")) {
        *outContextType = GrContextFactory::kANGLE_GLContextType;
        return true;
    }
#endif
    if (value.equals("angle-gl")) {
        *outContextType = GrContextFactory::kANGLE_GL_GLContextType;
        return true;
    }
#endif
#if SK_COMMAND_BUFFER
    if (value.equals("commandbuffer")) {
        *outContextType = GrContextFactory::kCommandBufferES2_GLContextType;
        return true;
    }
    if (value.equals("commandbuffer3")) {
        *outContextType = GrContextFactory::kCommandBufferES3_GLContextType;
        return true;
    }
#endif
#if SK_MESA
    if (value.equals("mesa")) {
        *outContextType = GrContextFactory::kMESA_GLContextType;
        return true;
    }
#endif
    return false;
}
开发者ID:YangchenVR,项目名称:skia,代码行数:52,代码来源:SkCommonFlagsConfig.cpp

示例4: onUIStateChanged

void Viewer::onUIStateChanged(const SkString& stateName, const SkString& stateValue) {
    // For those who will add more features to handle the state change in this function:
    // After the change, please call updateUIState no notify the frontend (e.g., Android app).
    // For example, after slide change, updateUIState is called inside setupCurrentSlide;
    // after backend change, updateUIState is called in this function.
    if (stateName.equals(kSlideStateName)) {
        int previousSlide = fCurrentSlide;
        fCurrentSlide = 0;
        for(auto slide : fSlides) {
            if (slide->getName().equals(stateValue)) {
                setupCurrentSlide(previousSlide);
                break;
            }
            fCurrentSlide++;
        }
        if (fCurrentSlide >= fSlides.count()) {
            fCurrentSlide = previousSlide;
            SkDebugf("Slide not found: %s", stateValue.c_str());
        }
    } else if (stateName.equals(kBackendStateName)) {
        for (int i = 0; i < sk_app::Window::kBackendTypeCount; i++) {
            if (stateValue.equals(kBackendTypeStrings[i])) {
                if (fBackendType != i) {
                    fBackendType = (sk_app::Window::BackendType)i;
                    fWindow->detach();
                    fWindow->attach(fBackendType, DisplayParams());
                    fWindow->inval();
                    updateTitle();
                    updateUIState();
                }
                break;
            }
        }
    } else if (stateName.equals(kSoftkeyStateName)) {
        if (!stateValue.equals(kSoftkeyHint)) {
            fCommands.onSoftkey(stateValue);
            updateUIState(); // This is still needed to reset the value to kSoftkeyHint
        }
    } else if (stateName.equals(kSplitScreenStateName)) {
        bool newSplitScreen = stateValue.equals(kON);
        if (newSplitScreen != fSplitScreen) {
            fSplitScreen = newSplitScreen;
            fWindow->inval();
            updateUIState();
        }
    } else if (stateName.equals(kRefreshStateName)) {
        // This state is actually NOT in the UI state.
        // We use this to allow Android to quickly set bool fRefresh.
        fRefresh = stateValue.equals(kON);
    } else {
        SkDebugf("Unknown stateName: %s", stateName.c_str());
    }
}
开发者ID:HansMuller,项目名称:skia,代码行数:53,代码来源:Viewer.cpp

示例5: test_filepath_creation

static void test_filepath_creation(skiatest::Reporter* reporter) {
    SkString result;
    SkString filename("test");
    SkString dir("test/path");
    sk_tools::make_filepath(&result, dir, filename);
    REPORTER_ASSERT(reporter, result.equals("test/path/test"));
}
开发者ID:Cue,项目名称:skia,代码行数:7,代码来源:PictureUtilsTest.cpp

示例6: SetMetadataByKey

void SkPDFMetadata::SetMetadataByKey(const SkString& key,
                                     const SkString& value,
                                     SkDocument::PDFMetadata* metadata) {
    for (const auto keyValuePtr : gMetadataKeys) {
        if (key.equals(keyValuePtr.key)) {
            metadata->*(keyValuePtr.valuePtr) = value;
        }
    }
}
开发者ID:sylvestre,项目名称:skia,代码行数:9,代码来源:SkPDFMetadata.cpp

示例7: runTest

    void runTest(skiatest::Reporter* reporter) {
        SkAutoTDelete<SkAdvancedTypefaceMetrics::AdvanceMetric<int16_t> > result;
        result.reset(getAdvanceData((void*)this, fAdvancesLen, fSubset, fSubsetLen, getAdvance));

        SkString stringResult = stringify_advance_data(result);
        if (!stringResult.equals(fExpected)) {
            ERRORF(reporter, "Expected: %s\n  Result: %s\n", fExpected, stringResult.c_str());
        }
    }
开发者ID:BertiKarsunke,项目名称:skia,代码行数:9,代码来源:WArrayTest.cpp

示例8: match

 bool match(const SkString& filename, SkFILEWStream* stream, TestResult* result) {
     if (fIndex < fResults.count()) {
         *result = fResults[fIndex++];
         SkASSERT(filename.equals(result->fFilename));
         SkString outStr(result->status());
         stream->write(outStr.c_str(), outStr.size());
         stream->flush();
         return true;
     }
     return false;
 }
开发者ID:MIPS,项目名称:external-skia,代码行数:11,代码来源:SkpSkGrTest.cpp

示例9: parse_option_gpu_color

static bool parse_option_gpu_color(const SkString& value,
                                   SkColorType* outColorType,
                                   sk_sp<SkColorSpace>* outColorSpace) {
    if (value.equals("8888")) {
        *outColorType = kN32_SkColorType;
        *outColorSpace = nullptr;
        return true;
    }
    if (value.equals("f16")) {
        *outColorType = kRGBA_F16_SkColorType;
        *outColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
        return true;
    }
    if (value.equals("srgb")) {
        *outColorType = kN32_SkColorType;
        *outColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
        return true;
    }
    return false;
}
开发者ID:03050903,项目名称:skia,代码行数:20,代码来源:SkCommonFlagsConfig.cpp

示例10: platform_font_name

const char* platform_font_name(const char* name) {
    SkString platform = major_platform_os_name();
    int index;
    if (!strcmp(name, "serif")) {
        index = 0;
    } else if (!strcmp(name, "san-serif")) {
        index = 1;
    } else if (!strcmp(name, "monospace")) {
        index = 2;
    } else {
        return name;
    }
    if (platform.equals("Mac")) {
        return gStandardFontNames[0][index];
    }
    if (platform.equals("iOS")) {
        return gStandardFontNames[1][index];
    }
    if (platform.equals("Win")) {
        return gStandardFontNames[2][index];
    }
    if (platform.equals("Ubuntu")) {
        return gStandardFontNames[3][index];
    }
    if (platform.equals("Android")) {
        return gStandardFontNames[4][index];
    }
    if (platform.equals("ChromeOS")) {
        return gStandardFontNames[5][index];
    }
    return name;
}
开发者ID:aseprite,项目名称:skia,代码行数:32,代码来源:sk_tool_utils.cpp

示例11: runTest

    void runTest(skiatest::Reporter* reporter) {
        SkAdvancedTypefaceMetrics metrics;
        metrics.setGlyphWidths(
                fAdvancesLen, fSubset, fSubsetLen,
                std::function<bool(int, int16_t*)>([this](int gId, int16_t* advance) {
                            if (gId >= 0 && gId < fAdvancesLen) {
                                *advance = fAdvances[gId];
                                return true;
                            }
                            return false;
                        }));

        SkString stringResult = stringify_advance_data(metrics.fGlyphWidths);
        if (!stringResult.equals(fExpected)) {
            ERRORF(reporter, "Expected: %s\n  Result: %s\n", fExpected, stringResult.c_str());
        }
    }
开发者ID:03050903,项目名称:skia,代码行数:17,代码来源:WArrayTest.cpp

示例12: onUIStateChanged

void Viewer::onUIStateChanged(const SkString& stateName, const SkString& stateValue) {
    // Currently, we only recognize the Slide state
    if (stateName.equals(kSlideStateName)) {
        int previousSlide = fCurrentSlide;
        fCurrentSlide = 0;
        for(auto slide : fSlides) {
            if (slide->getName().equals(stateValue)) {
                setupCurrentSlide(previousSlide);
                break;
            }
            fCurrentSlide++;
        }
        if (fCurrentSlide >= fSlides.count()) {
            fCurrentSlide = previousSlide;
            SkDebugf("Slide not found: %s", stateValue.c_str());
        }
    } else {
        SkDebugf("Unknown stateName: %s", stateName.c_str());
    }
}
开发者ID:romaerzhang,项目名称:skia,代码行数:20,代码来源:Viewer.cpp

示例13: whitelist_name_index

static int whitelist_name_index(const SkTypeface* tf) {

    SkString fontNameStr;
    SkAutoTUnref<SkTypeface::LocalizedStrings> nameIter(
        SkOTUtils::LocalizedStrings_NameTable::CreateForFamilyNames(*tf));
    SkTypeface::LocalizedString familyNameLocalized;
    while (nameIter->next(&familyNameLocalized)) {
        fontNameStr = familyNameLocalized.fString;
        // check against permissible list of names
        for (int i = 0; i < whitelistCount; ++i) {
            if (fontNameStr.equals(whitelist[i].fFontName)) {
                return i;
            }
        }
    }
#if WHITELIST_DEBUG
    SkAutoTUnref<SkTypeface::LocalizedStrings> debugIter(
        SkOTUtils::LocalizedStrings_NameTable::CreateForFamilyNames(*tf));
    while (debugIter->next(&familyNameLocalized)) {
        SkDebugf("no match fontName=\"%s\"\n", familyNameLocalized.fString.c_str());
    }
#endif
    return -1;
}
开发者ID:C-Tillion,项目名称:skia,代码行数:24,代码来源:SkWhitelistTypefaces.cpp

示例14: TestString

static void TestString(skiatest::Reporter* reporter) {
    SkString    a;
    SkString    b((size_t)0);
    SkString    c("");
    SkString    d(NULL, 0);

    REPORTER_ASSERT(reporter, a.isEmpty());
    REPORTER_ASSERT(reporter, a == b && a == c && a == d);

    a.set("hello");
    b.set("hellox", 5);
    c.set(a);
    d.resize(5);
    memcpy(d.writable_str(), "helloz", 5);

    REPORTER_ASSERT(reporter, !a.isEmpty());
    REPORTER_ASSERT(reporter, a.size() == 5);
    REPORTER_ASSERT(reporter, a == b && a == c && a == d);
    REPORTER_ASSERT(reporter, a.equals("hello", 5));
    REPORTER_ASSERT(reporter, a.equals("hello"));
    REPORTER_ASSERT(reporter, !a.equals("help"));

    SkString    e(a);
    SkString    f("hello");
    SkString    g("helloz", 5);

    REPORTER_ASSERT(reporter, a == e && a == f && a == g);

    b.set("world");
    c = b;
    REPORTER_ASSERT(reporter, a != b && a != c && b == c);

    a.append(" world");
    e.append("worldz", 5);
    e.insert(5, " ");
    f.set("world");
    f.prepend("hello ");
    REPORTER_ASSERT(reporter, a.equals("hello world") && a == e && a == f);

    a.reset();
    b.resize(0);
    REPORTER_ASSERT(reporter, a.isEmpty() && b.isEmpty() && a == b);

    a.set("a");
    a.set("ab");
    a.set("abc");
    a.set("abcd");

    a.set("");
    a.appendS64(72036854775808LL, 0);
    REPORTER_ASSERT(reporter, a.equals("72036854775808"));

    a.set("");
    a.appendS64(-1844674407370LL, 0);
    REPORTER_ASSERT(reporter, a.equals("-1844674407370"));

    a.set("");
    a.appendS64(73709551616LL, 15);
    REPORTER_ASSERT(reporter, a.equals("000073709551616"));

    a.set("");
    a.appendS64(-429496729612LL, 15);
    REPORTER_ASSERT(reporter, a.equals("-000429496729612"));
}
开发者ID:rburchell,项目名称:skia,代码行数:64,代码来源:StringTest.cpp

示例15: TestString

static void TestString(skiatest::Reporter* reporter) {
    SkString    a;
    SkString    b((size_t)0);
    SkString    c("");
    SkString    d(NULL, 0);

    REPORTER_ASSERT(reporter, a.isEmpty());
    REPORTER_ASSERT(reporter, a == b && a == c && a == d);

    a.set("hello");
    b.set("hellox", 5);
    c.set(a);
    d.resize(5);
    memcpy(d.writable_str(), "helloz", 5);

    REPORTER_ASSERT(reporter, !a.isEmpty());
    REPORTER_ASSERT(reporter, a.size() == 5);
    REPORTER_ASSERT(reporter, a == b && a == c && a == d);
    REPORTER_ASSERT(reporter, a.equals("hello", 5));
    REPORTER_ASSERT(reporter, a.equals("hello"));
    REPORTER_ASSERT(reporter, !a.equals("help"));

    SkString    e(a);
    SkString    f("hello");
    SkString    g("helloz", 5);

    REPORTER_ASSERT(reporter, a == e && a == f && a == g);

    b.set("world");
    c = b;
    REPORTER_ASSERT(reporter, a != b && a != c && b == c);

    a.append(" world");
    e.append("worldz", 5);
    e.insert(5, " ");
    f.set("world");
    f.prepend("hello ");
    REPORTER_ASSERT(reporter, a.equals("hello world") && a == e && a == f);

    a.reset();
    b.resize(0);
    REPORTER_ASSERT(reporter, a.isEmpty() && b.isEmpty() && a == b);

    a.set("a");
    a.set("ab");
    a.set("abc");
    a.set("abcd");

    a.set("");
    a.appendS64(72036854775808LL, 0);
    REPORTER_ASSERT(reporter, a.equals("72036854775808"));

    a.set("");
    a.appendS64(-1844674407370LL, 0);
    REPORTER_ASSERT(reporter, a.equals("-1844674407370"));

    a.set("");
    a.appendS64(73709551616LL, 15);
    REPORTER_ASSERT(reporter, a.equals("000073709551616"));

    a.set("");
    a.appendS64(-429496729612LL, 15);
    REPORTER_ASSERT(reporter, a.equals("-000429496729612"));

    static const struct {
        SkScalar    fValue;
        const char* fString;
    } gRec[] = {
        { 0,            "0" },
        { SK_Scalar1,   "1" },
        { -SK_Scalar1,  "-1" },
        { SK_Scalar1/2, "0.5" },
#ifdef SK_SCALAR_IS_FLOAT
        { 3.4028234e38f,   "3.4028235e+38" },
        { -3.4028234e38f, "-3.4028235e+38" },
#endif
    };
    for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) {
        a.reset();
        a.appendScalar(gRec[i].fValue);
        REPORTER_ASSERT(reporter, a.size() <= SkStrAppendScalar_MaxSize);
//        SkDebugf(" received <%s> expected <%s>\n", a.c_str(), gRec[i].fString);
        REPORTER_ASSERT(reporter, a.equals(gRec[i].fString));
    }
}
开发者ID:ACSOP,项目名称:android_external_skia,代码行数:85,代码来源:StringTest.cpp


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