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


C++ STRING::find_last_not_of方法代码示例

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


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

示例1: trim

static void trim(STRING& str)
{
    static const WCHAR Spaces[] = L" \t\r\n";
    size_t i = str.find_first_not_of(Spaces);
    size_t j = str.find_last_not_of(Spaces);
    if (i == STRING::npos || j == STRING::npos)
    {
        str.clear();
    }
    else
    {
        str = str.substr(i, j - i + 1);
    }
}
开发者ID:Moteesh,项目名称:reactos,代码行数:14,代码来源:fontsub.cpp

示例2: EscapeBackSlashes

 /*!
  * Add escaping to each sequence of backslashes that immediately precedes
  * a quote character.  Each backslash in such a sequence must be escaped
  * with another backslash.  Note that backslashes that are not part of a
  * sequence that immediately precedes a quote are NOT escaped.  E.g.:
  *
  *  \a" -> \a"
  *  foo\bar"baz\\"fum -> foo\bar"baz\\\\"fum
  */
 void EscapeBackSlashes()
 {
     size_t quote = _quoted.find_first_of('"', 1);
     while (quote != STRING::npos)
     {
         size_t numSlashes = 0;
         size_t notSlash = _quoted.find_last_not_of('\\', quote-1);
         if (notSlash != quote-1)
         {
             if (notSlash == STRING::npos)
                 numSlashes = quote;
             else
                 numSlashes = quote - notSlash - 1;
             _quoted.insert(quote, numSlashes, '\\');
         }
         quote = _quoted.find_first_of('"', quote + numSlashes + 1);
     }
 }
开发者ID:EmilyBragg,项目名称:profiling-tool,代码行数:27,代码来源:quote-argument-ms.hpp

示例3: AddQuotes

    /*!
     * Add quotes around the string if it contains any whitespace.
     */
    void AddQuotes(const T *whitespace)
    {
        if (_quoted.find_first_of(whitespace) != STRING::npos)
        {
            _quoted.insert(0, 1, '"');
            _quoted.append(1, '"');

            // If the last character (prior to adding the quotes) was a backslash,
            // it needs to be escaped now because it precedes a quote.
            //
            size_t quote = _quoted.size() - 1;
            if (_quoted[quote-1] == '\\')
            {
                size_t notSlash = _quoted.find_last_not_of('\\', quote-2);
                size_t numSlashes = quote - notSlash - 1;
                _quoted.insert(quote, numSlashes, '\\');
            }
        }
    }
开发者ID:EmilyBragg,项目名称:profiling-tool,代码行数:22,代码来源:quote-argument-ms.hpp


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