aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/ADT/StringRef.h
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-11-11 00:28:53 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-11-11 00:28:53 +0000
commit64066bd8b593082f622bbc25716938a453363d2f (patch)
treea388003855cae002ff0e7875abfb7b72e666891d /include/llvm/ADT/StringRef.h
parent253e9b2990b090162e389475c4ef419ff7e2c5d1 (diff)
downloadexternal_llvm-64066bd8b593082f622bbc25716938a453363d2f.zip
external_llvm-64066bd8b593082f622bbc25716938a453363d2f.tar.gz
external_llvm-64066bd8b593082f622bbc25716938a453363d2f.tar.bz2
Add From arguments to StringRef search functions, and tweak doxyments.
Also, add unittests for find_first_of and find_first_not_of. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86770 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/StringRef.h')
-rw-r--r--include/llvm/ADT/StringRef.h30
1 files changed, 19 insertions, 11 deletions
diff --git a/include/llvm/ADT/StringRef.h b/include/llvm/ADT/StringRef.h
index 4e81b84..a5c43fa 100644
--- a/include/llvm/ADT/StringRef.h
+++ b/include/llvm/ADT/StringRef.h
@@ -152,8 +152,8 @@ namespace llvm {
///
/// \return - The index of the first occurence of \arg C, or npos if not
/// found.
- size_t find(char C) const {
- for (size_t i = 0, e = Length; i != e; ++i)
+ size_t find(char C, size_t From = 0) const {
+ for (size_t i = std::min(From, Length), e = Length; i != e; ++i)
if (Data[i] == C)
return i;
return npos;
@@ -163,7 +163,7 @@ namespace llvm {
///
/// \return - The index of the first occurence of \arg Str, or npos if not
/// found.
- size_t find(StringRef Str) const;
+ size_t find(StringRef Str, size_t From = 0) const;
/// rfind - Search for the last character \arg C in the string.
///
@@ -186,17 +186,25 @@ namespace llvm {
/// found.
size_t rfind(StringRef Str) const;
- /// find_first_of - Find the first instance of the specified character or
- /// return npos if not in string. Same as find.
- size_type find_first_of(char C) const { return find(C); }
+ /// find_first_of - Find the first character in the string that is \arg C,
+ /// or npos if not found. Same as find.
+ size_type find_first_of(char C, size_t From = 0) const { return find(C); }
- /// find_first_of - Find the first character from the string 'Chars' in the
- /// current string or return npos if not in string.
- size_type find_first_of(StringRef Chars) const;
+ /// find_first_of - Find the first character in the string that is in \arg
+ /// Chars, or npos if not found.
+ ///
+ /// Note: O(size() * Chars.size())
+ size_type find_first_of(StringRef Chars, size_t From = 0) const;
/// find_first_not_of - Find the first character in the string that is not
- /// in the string 'Chars' or return npos if all are in string. Same as find.
- size_type find_first_not_of(StringRef Chars) const;
+ /// \arg C or npos if not found.
+ size_type find_first_not_of(char C, size_t From = 0) const;
+
+ /// find_first_not_of - Find the first character in the string that is not
+ /// in the string \arg Chars, or npos if not found.
+ ///
+ /// Note: O(size() * Chars.size())
+ size_type find_first_not_of(StringRef Chars, size_t From = 0) const;
/// @}
/// @name Helpful Algorithms