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


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

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


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

示例1: parse_quoted_fields

int CSV_Parser::parse_quoted_fields(const STR& input_line, STR& field, int& i)
{
    /*
        Quoted fields are the ones which are enclosed within quotes
        For instance - Consider that input_line is - 1997,Ford,E350,"Super, luxurious truck"
        An example for a quoted field would be - Super luxurious truck
        Another instance being - 1997,Ford,E350,"Super, ""luxurious"" truck"
    */
    int j;
    field = "";

    for(j=i; j<input_line.length(); j++)
    {
        if(input_line[j] == '"' && input_line[++j] != '"')
        {
            int k = input_line.find_first_of(CSV_DELIMITER, j);
            if(k > input_line.length())
            {
                k = input_line.length();
            }
            for(k -= j; k-- > 0; )
            {
                field += input_line[j++];
            }
            break;
        }
        else
        {
            field += input_line[j];
        }
    }
    return j;
}
开发者ID:12sky1emre,项目名称:InfiniteSky-1,代码行数:33,代码来源:csv_parser.hpp

示例2: parse_normal_fields

int CSV_Parser::parse_normal_fields(const STR& input_line, STR& field, int& i)
{
    /*
        Normal fields are the ones which contain no escaped or quoted characters
        For instance - Consider that input_line is - 1997,Ford,E350,"Super, luxurious truck"
        An example for a normal field would be - Ford
    */
    int j;
    j = input_line.find_first_of(CSV_DELIMITER, i);
    if(j > input_line.length())
    {
        j = input_line.length();
    }
    field = std :: string(input_line, i, j-i);
    return j;
}
开发者ID:12sky1emre,项目名称:InfiniteSky-1,代码行数:16,代码来源:csv_parser.hpp

示例3: TokenizeT

static size_t TokenizeT(const STR& str,
	const STR& delimiters,
	std::vector<STR>* tokens) {
	tokens->clear();

	size_t start = str.find_first_not_of(delimiters);
	while (start != STR::npos) {
		size_t end = str.find_first_of(delimiters, start + 1);
		if (end == STR::npos) {
			tokens->push_back(str.substr(start));
			break;
		}
		else {
			tokens->push_back(str.substr(start, end - start));
			start = str.find_first_not_of(delimiters, end + 1);
		}
	}

	return tokens->size();
}
开发者ID:623442733,项目名称:cef,代码行数:20,代码来源:string_util.cpp


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