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


C++ StringT::substr方法代码示例

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


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

示例1: trigraph

inline StringT
convert_trigraphs(StringT const &value)
{
    StringT result;
    typename StringT::size_type pos = 0;
    typename StringT::size_type pos1 = value.find_first_of ("?", 0);
    if (StringT::npos != pos1) {
        do {
            result += value.substr(pos, pos1-pos);
            StringT trigraph (value.substr(pos1)); 
            if (is_trigraph(trigraph)) {
                result += convert_trigraph(trigraph);
                pos1 = value.find_first_of ("?", pos = pos1+3);
            }
            else {
                result += value[pos1];
                pos1 = value.find_first_of ("?", pos = pos1+1);
            }
        } while (StringT::npos != pos1);
        result += value.substr(pos);
    }
    else {
        result = value;
    }
    return result;
}
开发者ID:AndresGalaviz,项目名称:NAO,代码行数:26,代码来源:convert_trigraphs.hpp

示例2: while

 inline StringT
 unescape_lit(StringT const &value)
 {
     StringT result;
     typename StringT::size_type pos = 0;
     typename StringT::size_type pos1 = value.find_first_of ("\\", 0);
     if (StringT::npos != pos1) {
         do {
             if ('\\' == value[pos1+1] || '\"' == value[pos1+1] || 
                 '?' == value[pos1+1])
             {
                 result = result + value.substr(pos, pos1-pos);
                 pos1 = value.find_first_of ("\\", (pos = pos1+1)+1);
             }
             else {
                 result = result + value.substr(pos, pos1-pos+1);
                 pos1 = value.find_first_of ("\\", pos = pos1+1);
             }
             
         } while (pos1 != StringT::npos);
         result = result + value.substr(pos);
     }
     else {
     // the string doesn't contain any escaped character sequences
         result = value;
     }
     return result;
 }
开发者ID:AlexRa,项目名称:Kirstens-clone,代码行数:28,代码来源:macro_helpers.hpp

示例3: StringT

 inline StringT
 escape_lit(StringT const &value)
 {
     StringT result;
     typename StringT::size_type pos = 0;
     typename StringT::size_type pos1 = value.find_first_of ("\"\\?", 0);
     if (StringT::npos != pos1) {
         do {
             result += value.substr(pos, pos1-pos) 
                         + StringT("\\") 
                         + StringT(1, value[pos1]);
             pos1 = value.find_first_of ("\"\\?", pos = pos1+1);
         } while (StringT::npos != pos1);
         result += value.substr(pos);
     }
     else {
         result = value;
     }
     return result;
 }
开发者ID:DanielParra159,项目名称:EngineAndGame,代码行数:20,代码来源:macro_helpers.hpp

示例4: uchar_val

inline void
validate_identifier_name (StringT const &name, std::size_t line,
    std::size_t column, StringT const &file_name)
{
    using namespace std;    // some systems have strtoul in namespace std::

typename StringT::size_type pos = name.find_first_of('\\');

    while (StringT::npos != pos) {
    // the identifier name contains a backslash (must be universal char)
        BOOST_ASSERT('u' == name[pos+1] || 'U' == name[pos+1]);

    StringT uchar_val(name.substr(pos+2, ('u' == name[pos+1]) ? 4 : 8));
    universal_char_type type =
        classify_universal_char(strtoul(uchar_val.c_str(), 0, 16));

        if (universal_char_type_valid != type) {
        // an invalid char was found, so throw an exception
        StringT error_uchar(name.substr(pos, ('u' == name[pos+1]) ? 6 : 10));

            if (universal_char_type_invalid == type) {
                BOOST_WAVE_LEXER_THROW(lexing_exception, universal_char_invalid,
                    error_uchar, line, column, file_name.c_str());
            }
            else if (universal_char_type_base_charset == type) {
                BOOST_WAVE_LEXER_THROW(lexing_exception, universal_char_base_charset,
                    error_uchar, line, column, file_name.c_str());
            }
            else {
                BOOST_WAVE_LEXER_THROW(lexing_exception, universal_char_not_allowed,
                    error_uchar, line, column, file_name.c_str());
            }
        }

    // find next universal char (if appropriate)
        pos = name.find_first_of('\\', pos+2);
    }
}
开发者ID:zcobell,项目名称:QADCModules,代码行数:38,代码来源:validate_universal_char.hpp

示例5: switch

 inline StringT
 unescape_lit(StringT const &value)
 {
     StringT result;
     typename StringT::size_type pos = 0;
     typename StringT::size_type pos1 = value.find_first_of ("\\", 0);
     if (StringT::npos != pos1) {
         do {
             switch (value[pos1+1]) {
             case '\\':
             case '\"':
             case '?':
                 result = result + value.substr(pos, pos1-pos);
                 pos1 = value.find_first_of ("\\", (pos = pos1+1)+1);
                 break;
                 
             case 'n':
                 result = result + value.substr(pos, pos1-pos) + "\n";
                 pos1 = value.find_first_of ("\\", pos = pos1+1);
                 ++pos;
                 break;
                 
             default:
                 result = result + value.substr(pos, pos1-pos+1);
                 pos1 = value.find_first_of ("\\", pos = pos1+1);
             }
             
         } while (pos1 != StringT::npos);
         result = result + value.substr(pos);
     }
     else {
     // the string doesn't contain any escaped character sequences
         result = value;
     }
     return result;
 }
开发者ID:DanielParra159,项目名称:EngineAndGame,代码行数:36,代码来源:macro_helpers.hpp

示例6:

inline bool 
is_special_macroname (StringT const &name)
{
    if (name.size() < 7)
        return false;

    if ("defined" == name)
        return true;

    if ('_' == name[0] && '_' == name[1]) {
    StringT str = name.substr(2);

        if (str == "cplusplus"  || str == "STDC__" || 
            str == "TIME__"     || str == "DATE__" ||
            str == "LINE__"     || str == "FILE__" ||
            str == "INCLUDE_LEVEL__")
        {
            return true;
        }
    }
    return false;
}
开发者ID:QuentinRougemont,项目名称:MicrosatDemogInference,代码行数:22,代码来源:cpp_macromap_utils.hpp


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