本文整理汇总了C++中llvm::StringRef::find_last_of方法的典型用法代码示例。如果您正苦于以下问题:C++ StringRef::find_last_of方法的具体用法?C++ StringRef::find_last_of怎么用?C++ StringRef::find_last_of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm::StringRef
的用法示例。
在下文中一共展示了StringRef::find_last_of方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReverseFindMatchingChars
bool ReverseFindMatchingChars(const llvm::StringRef &s,
const llvm::StringRef &left_right_chars,
size_t &left_pos, size_t &right_pos,
size_t pos = llvm::StringRef::npos) {
assert(left_right_chars.size() == 2);
left_pos = llvm::StringRef::npos;
const char left_char = left_right_chars[0];
const char right_char = left_right_chars[1];
pos = s.find_last_of(left_right_chars, pos);
if (pos == llvm::StringRef::npos || s[pos] == left_char)
return false;
right_pos = pos;
uint32_t depth = 1;
while (pos > 0 && depth > 0) {
pos = s.find_last_of(left_right_chars, pos);
if (pos == llvm::StringRef::npos)
return false;
if (s[pos] == left_char) {
if (--depth == 0) {
left_pos = pos;
return left_pos < right_pos;
}
} else if (s[pos] == right_char) {
++depth;
}
}
return false;
}
示例2: inclusionDirective
void HeaderTracker::inclusionDirective( llvm::StringRef searchPath, llvm::StringRef relativePath, llvm::StringRef fileName, bool isAngled, clang::FileEntry const * entry )
{
commitMacros();
assert( !fileStack_.empty() );
bool const relativeToParent( !isAngled && ( fileStack_.back().file->getDir()->getName() == searchPath ) );
Dir dir;
HeaderName headerName;
if ( relativeToParent )
{
dir = Dir( fileStack_.back().dir );
llvm::StringRef const parentFilename = fileStack_.back().name.get();
std::size_t const slashPos = parentFilename.find_last_of('/');
if ( slashPos == llvm::StringRef::npos )
headerName = HeaderName( relativePath );
else
{
llvm::SmallString<512> fileName( parentFilename.data(), parentFilename.data() + slashPos + 1 );
fileName.append( relativePath );
headerName = HeaderName( fileName.str() );
}
}
else
{
dir = Dir( searchPath );
headerName = HeaderName( relativePath );
}
fileStack_.emplace_back
(
dir,
headerName,
relativeToParent,
entry
);
}