本文整理汇总了C++中StringPiece::find_first_not_of方法的典型用法代码示例。如果您正苦于以下问题:C++ StringPiece::find_first_not_of方法的具体用法?C++ StringPiece::find_first_not_of怎么用?C++ StringPiece::find_first_not_of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringPiece
的用法示例。
在下文中一共展示了StringPiece::find_first_not_of方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SplitStringToIteratorUsing
static inline
void SplitStringToIteratorUsing(const StringPiece& full, const char* delim, ITR& result)
{
// Optimize the common case where delim is a single character.
if (delim[0] != '\0' && delim[1] == '\0')
{
char c = delim[0];
const char* p = full.data();
const char* end = p + full.size();
while (p != end)
{
if (*p == c)
++p;
else
{
const char* start = p;
while (++p != end && *p != c) {}
*result++ = StringType(start, p - start);
}
}
return;
}
std::string::size_type begin_index, end_index;
begin_index = full.find_first_not_of(delim);
while (begin_index != std::string::npos)
{
end_index = full.find_first_of(delim, begin_index);
if (end_index == std::string::npos)
{
*result++ = full.substr(begin_index).as_string();
return;
}
*result++ = full.substr(begin_index, (end_index - begin_index)).as_string();
begin_index = full.find_first_not_of(delim, end_index);
}
}
示例2: ContainsOnlyChars
bool ContainsOnlyChars(const StringPiece& input,
const StringPiece& characters) {
return input.find_first_not_of(characters) == StringPiece::npos;
}