本文整理汇总了C++中NarrowString::find_first_not_of方法的典型用法代码示例。如果您正苦于以下问题:C++ NarrowString::find_first_not_of方法的具体用法?C++ NarrowString::find_first_not_of怎么用?C++ NarrowString::find_first_not_of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NarrowString
的用法示例。
在下文中一共展示了NarrowString::find_first_not_of方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getNthToken
bool getNthToken (const NarrowString & str, const size_t n, size_t & pos, size_t & endpos, NarrowString & token, const char * sepChars)
{
size_t desired_first_nonspace = 0;
size_t space = 0;
//check for trivial case
if(n == 0)
desired_first_nonspace = pos;
else
{
for (size_t i = 0; i < n; ++i)
{
//find the first whitespace character
space = str.find_first_of ( sepChars, pos );
if (space == std::string::npos)
return false;
//now find the next non-whitespace character after it
desired_first_nonspace = str.find_first_not_of( sepChars, space );
if (desired_first_nonspace == std::string::npos)
return false;
pos = desired_first_nonspace;
}
}
//find the end of the token
const size_t first_space = str.find_first_of (sepChars, desired_first_nonspace );
//now get that token
if (first_space != std::string::npos)
token = str.substr (desired_first_nonspace, first_space - desired_first_nonspace);
else
token = str.substr (desired_first_nonspace);
endpos = desired_first_nonspace;
return true;
}
示例2: getFirstToken
bool getFirstToken (const NarrowString & str, size_t pos, size_t & endpos, NarrowString & token, const char * sepChars)
{
const size_t first_nonspace = str.find_first_not_of ( sepChars, pos );
if (first_nonspace != std::string::npos)
{
const size_t first_space = str.find_first_of (sepChars, first_nonspace );
if (first_space != std::string::npos)
token = str.substr (first_nonspace, first_space - first_nonspace);
else
token = str.substr (first_nonspace);
endpos = first_space;
return true;
}
else
return false;
}