本文整理汇总了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;
}
示例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;
}
示例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();
}