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


C++ SString::Begin方法代码示例

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


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

示例1: MutateUrlToPath

    void MutateUrlToPath(SString &urlOrPath)
    {
        BINDER_LOG_ENTER(W("Utils::MutateUrlToPath"));
        const SString fileUrlPrefix(SString::Literal, W("file://"));
        SString::Iterator i = urlOrPath.Begin();

        BINDER_LOG_STRING(W("URL"), urlOrPath);

        if (urlOrPath.MatchCaseInsensitive(i, fileUrlPrefix))
        {
            urlOrPath.Delete(i, fileUrlPrefix.GetCount());

            i = urlOrPath.Begin() + 1;
            if (i[0] ==  W(':'))
            {
                // CLR erroneously passes in file:// prepended to file paths,
                // so we can't tell the difference between UNC and local file.
                goto Exit;
            }

            i = urlOrPath.Begin();
#if !defined(PLATFORM_UNIX)
            if (i[0] == W('/'))
            {
                // Disk path file:///
                urlOrPath.Delete(i, 1);
            }
            else if (i[0] != W('\\'))
            {
                // UNC Path, re-insert "//" if not the wrong file://\\...
                urlOrPath.Insert(i, W("//"));
            }
#else
            // Unix doesn't have a distinction between local and network path
            _ASSERTE(i[0] == W('\\') || i[0] == W('/'));
#endif
        }

    Exit:
        while (urlOrPath.Find(i, W('/')))
        {
            urlOrPath.Replace(i, W('\\'));
        }

        BINDER_LOG_STRING(W("Path"), urlOrPath);
        BINDER_LOG_LEAVE(W("Utils::MutateUrlToPath"));
    }
开发者ID:A-And,项目名称:coreclr,代码行数:47,代码来源:utils.cpp

示例2: MutatePathToUrl

    void MutatePathToUrl(SString &pathOrUrl)
    {
        BINDER_LOG_ENTER(W("Utils::MutatePathToUrl"));
        SString::Iterator i = pathOrUrl.Begin();

        BINDER_LOG_STRING(W("Path"), pathOrUrl);

#if !defined(PLATFORM_UNIX)
        // Network path \\server --> file://server
        // Disk path    c:\dir   --> file:///c:/dir
        if (i[0] == W('\\'))
        {
            const SString networkUrlPrefix(SString::Literal, W("file:"));

            // Network path
            pathOrUrl.Insert(i, networkUrlPrefix);
            pathOrUrl.Skip(i, networkUrlPrefix);
        }
        else
        {
            const SString diskPathUrlPrefix(SString::Literal, W("file:///"));

            // Disk path
            pathOrUrl.Insert(i, diskPathUrlPrefix);
            pathOrUrl.Skip(i, diskPathUrlPrefix);
        }
#else
        // Unix doesn't have a distinction between a network or a local path
        _ASSERTE(i[0] == W('\\') || i[0] == W('/'));
        const SString fileUrlPrefix(SString::Literal, W("file://"));

        pathOrUrl.Insert(i, fileUrlPrefix);
        pathOrUrl.Skip(i, fileUrlPrefix);
#endif

        while (pathOrUrl.Find(i, W('\\')))
        {
            pathOrUrl.Replace(i, W('/'));
        }

        BINDER_LOG_STRING(W("URL"), pathOrUrl);
        BINDER_LOG_LEAVE(W("Utils::MutatePathToUrl"));
    }
开发者ID:A-And,项目名称:coreclr,代码行数:43,代码来源:utils.cpp

示例3: TrimTrailingWhiteSpaces

    void StringLexer::TrimTrailingWhiteSpaces(SString &currentString)
    {
        SString::Iterator begin = currentString.Begin();
        SString::Iterator cursor = currentString.End() - 1;
        BOOL fFoundWhiteSpace = FALSE;

        for (;;)
        {
            if ((cursor >= begin) && IsWhitespace(cursor[0]))
            {
                fFoundWhiteSpace = TRUE;
                cursor--;
                continue;
            }
            break;
        }
            
        if (fFoundWhiteSpace)
        {
            currentString.Truncate(cursor + 1);
        }
    }
开发者ID:0xMF,项目名称:coreclr,代码行数:22,代码来源:stringlexer.cpp


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