Add {start,end}with_lower methods to StringRef.

startswith_lower is ocassionally useful and I think worth adding.
endwith_lower is added for completeness.

Differential Revision: http://llvm-reviews.chandlerc.com/D2041

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193706 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rui Ueyama
2013-10-30 18:32:26 +00:00
parent 3f04b50686
commit f34c3ca304
3 changed files with 53 additions and 5 deletions

View File

@@ -210,12 +210,18 @@ namespace llvm {
compareMemory(Data, Prefix.Data, Prefix.Length) == 0;
}
/// Check if this string starts with the given \p Prefix, ignoring case.
bool startswith_lower(StringRef Prefix) const;
/// Check if this string ends with the given \p Suffix.
bool endswith(StringRef Suffix) const {
return Length >= Suffix.Length &&
compareMemory(end() - Suffix.Length, Suffix.Data, Suffix.Length) == 0;
}
/// Check if this string ends with the given \p Suffix, ignoring case.
bool endswith_lower(StringRef Suffix) const;
/// @}
/// @name String Searching
/// @{