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


C++ basic_string::find_first_of方法代码示例

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


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

示例1: split_by_tokens

ResultList split_by_tokens(const std::basic_string<CharT> &s,
    const std::basic_string<CharT> &tokens, bool keepEmptyParts = true)
{
    if (tokens.length() == 1)
        return split<ResultList>(s, tokens, keepEmptyParts);

    ResultList slist;

    typename std::basic_string<CharT>::size_type start = 0;
    typename std::basic_string<CharT>::size_type pos;

    std::basic_string<CharT> part;

    // If delimiter.empty():
    //   pos = s.find_first_of(delimiter, start);
    // pos will be s.npos.
    while ((pos = s.find_first_of(tokens, start)) != s.npos) { // strtok
        part = s.substr(start, pos - start);

        if (!part.empty() || keepEmptyParts)
            slist.push_back(part);

        start = pos + 1;
    }

    if (start != s.length() || keepEmptyParts)
        slist.push_back(s.substr(start));

    return slist;
}
开发者ID:myd7349,项目名称:Ongoing-Study,代码行数:30,代码来源:split.hpp

示例2: node_select_piece

		explicit node_select_piece(const std::basic_string<char_type>& str)
			: tag(), type(specifier_type::none_), attr()
		{
			auto f1 = std_future::overload(
				[](const std::string& str) { return str.find_first_of("#."); },
				[](const std::wstring& str) { return str.find_first_of(L"#."); }
			);
			const auto split_pos = f1(str);
			if (basic_string<char_type>::npos == split_pos) {
				tag = str;
			}
			else {
				auto is_sharp = std_future::overload(
					[](const char c) { return '#' == c; },
					[](const wchar_t c) { return L'#' == c; }
				);
				tag = str.substr(0, split_pos);
				type = (is_sharp(str[split_pos])) ? specifier_type::id_ : specifier_type::class_;
				attr = str.substr(split_pos + 1);
			}
		}
开发者ID:yumetodo,项目名称:boost_html_parse,代码行数:21,代码来源:html_parse.cpp

示例3: if

    std::vector< std::basic_string< CharType > > str_split( std::basic_string< CharType > const & p_str, std::basic_string< CharType > const & p_delims, uint32_t p_maxSplits, bool p_bKeepVoid )
    {
        typedef std::basic_string< CharType > string_t;
        std::vector< string_t > l_arrayReturn;

        if ( ! p_str.empty() && ! p_delims.empty() && p_maxSplits > 0 )
        {
            l_arrayReturn.reserve( p_maxSplits + 1 );
            std::size_t l_numSplits = 0;
            std::size_t	l_pos = 0;
            std::size_t	l_start = 0;

            do
            {
                l_pos = p_str.find_first_of( p_delims, l_start );

                if ( l_pos == l_start )
                {
                    l_start = l_pos + 1;

                    if ( p_bKeepVoid )
                    {
                        l_arrayReturn.push_back( string_t() );
                    }
                }
                else if ( l_pos == string_t::npos || l_numSplits == p_maxSplits )
                {
                    string_t remnants = p_str.substr( l_start );

                    if ( !remnants.empty() || p_bKeepVoid )
                    {
                        l_arrayReturn.push_back( remnants );
                    }

                    return l_arrayReturn;
                }
                else
                {
                    l_arrayReturn.push_back( p_str.substr( l_start, l_pos - l_start ) );
                    l_start = l_pos + 1;
                }

                //l_start = p_str.find_first_not_of( p_delims, l_start );
                ++ l_numSplits;
            }
            while ( l_pos != string_t::npos );
        }

        return l_arrayReturn;
    }
开发者ID:DragonJoker,项目名称:DatabaseConnector,代码行数:50,代码来源:DatabaseStringUtils.cpp

示例4: StringTokenizeT

int StringTokenizeT(const std::basic_string<CharType> &input,
					const std::basic_string<CharType> &delimitor,
					std::list<std::basic_string<CharType> > &output)
{
	size_t token_begin;
	size_t token_end;

	output.clear();

	for (token_begin = token_end = 0; token_end != std::basic_string<CharType>::npos;)
	{
		token_begin = input.find_first_not_of(delimitor, token_begin);
		if (token_begin == std::basic_string<CharType>::npos)
			break;
		token_end = input.find_first_of(delimitor, token_begin + 1);
		output.push_back(input.substr(token_begin, token_end - token_begin));
		token_begin = token_end + 1;
	}

	return static_cast<int>(output.size());
}
开发者ID:arlen7772gg,项目名称:NIM_Duilib_Framework,代码行数:21,代码来源:string_util.cpp

示例5: is_simple_data

 bool is_simple_data(const std::basic_string<Ch> &data)
 {
     const static std::basic_string<Ch> chars = convert_chtype<Ch, char>(" \t{};\n\"");
     return !data.empty() && data.find_first_of(chars) == data.npos;
 }
开发者ID:craton-,项目名称:php_mapnik,代码行数:5,代码来源:info_parser_write.hpp

示例6: is_simple_key

 bool is_simple_key(const std::basic_string<Ch> &key)
 {
     const static std::basic_string<Ch> chars = convert_chtype<Ch, char>(" \t{};\n\"");
     return !key.empty() && key.find_first_of(chars) == key.npos;
 }
开发者ID:craton-,项目名称:php_mapnik,代码行数:5,代码来源:info_parser_write.hpp


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