LLVM
8.0.1
|
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs with the length computed at compile time. More...
#include "llvm/ADT/StringRef.h"
Public Member Functions | |
template<size_t N> | |
constexpr | StringLiteral (const char(&Str)[N]) |
Public Member Functions inherited from llvm::StringRef | |
iterator | begin () const |
iterator | end () const |
const unsigned char * | bytes_begin () const |
const unsigned char * | bytes_end () const |
iterator_range< const unsigned char * > | bytes () const |
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * | data () const |
data - Get a pointer to the start of the string (which may not be null terminated). More... | |
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool | empty () const |
empty - Check if the string is empty. More... | |
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t | size () const |
size - Get the string size. More... | |
LLVM_NODISCARD char | front () const |
front - Get the first character in the string. More... | |
LLVM_NODISCARD char | back () const |
back - Get the last character in the string. More... | |
template<typename Allocator > | |
LLVM_NODISCARD StringRef | copy (Allocator &A) const |
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool | equals (StringRef RHS) const |
equals - Check for string equality, this is more efficient than compare() when the relative ordering of inequal strings isn't needed. More... | |
LLVM_NODISCARD bool | equals_lower (StringRef RHS) const |
equals_lower - Check for string equality, ignoring case. More... | |
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE int | compare (StringRef RHS) const |
compare - Compare two strings; the result is -1, 0, or 1 if this string is lexicographically less than, equal to, or greater than the RHS . More... | |
LLVM_NODISCARD int | compare_lower (StringRef RHS) const |
compare_lower - Compare two strings, ignoring case. More... | |
LLVM_NODISCARD int | compare_numeric (StringRef RHS) const |
compare_numeric - Compare two strings, treating sequences of digits as numbers. More... | |
LLVM_NODISCARD unsigned | edit_distance (StringRef Other, bool AllowReplacements=true, unsigned MaxEditDistance=0) const |
Determine the edit distance between this string and another string. More... | |
LLVM_NODISCARD std::string | str () const |
str - Get the contents as an std::string. More... | |
LLVM_NODISCARD std::string | lower () const |
LLVM_NODISCARD std::string | upper () const |
Convert the given ASCII string to uppercase. More... | |
LLVM_NODISCARD char | operator[] (size_t Index) const |
template<typename T > | |
std::enable_if< std::is_same< T, std::string >::value, StringRef >::type & | operator= (T &&Str)=delete |
Disallow accidental assignment from a temporary std::string. More... | |
operator std::string () const | |
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool | startswith (StringRef Prefix) const |
Check if this string starts with the given Prefix . More... | |
LLVM_NODISCARD bool | startswith_lower (StringRef Prefix) const |
Check if this string starts with the given Prefix , ignoring case. More... | |
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool | endswith (StringRef Suffix) const |
Check if this string ends with the given Suffix . More... | |
LLVM_NODISCARD bool | endswith_lower (StringRef Suffix) const |
Check if this string ends with the given Suffix , ignoring case. More... | |
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t | find (char C, size_t From=0) const |
Search for the first character C in the string. More... | |
LLVM_NODISCARD size_t | find_lower (char C, size_t From=0) const |
Search for the first character C in the string, ignoring case. More... | |
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t | find_if (function_ref< bool(char)> F, size_t From=0) const |
Search for the first character satisfying the predicate F . More... | |
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t | find_if_not (function_ref< bool(char)> F, size_t From=0) const |
Search for the first character not satisfying the predicate F . More... | |
LLVM_NODISCARD size_t | find (StringRef Str, size_t From=0) const |
Search for the first string Str in the string. More... | |
LLVM_NODISCARD size_t | find_lower (StringRef Str, size_t From=0) const |
Search for the first string Str in the string, ignoring case. More... | |
LLVM_NODISCARD size_t | rfind (char C, size_t From=npos) const |
Search for the last character C in the string. More... | |
LLVM_NODISCARD size_t | rfind_lower (char C, size_t From=npos) const |
Search for the last character C in the string, ignoring case. More... | |
LLVM_NODISCARD size_t | rfind (StringRef Str) const |
Search for the last string Str in the string. More... | |
LLVM_NODISCARD size_t | rfind_lower (StringRef Str) const |
Search for the last string Str in the string, ignoring case. More... | |
LLVM_NODISCARD size_t | find_first_of (char C, size_t From=0) const |
Find the first character in the string that is C , or npos if not found. More... | |
LLVM_NODISCARD size_t | find_first_of (StringRef Chars, size_t From=0) const |
Find the first character in the string that is in Chars , or npos if not found. More... | |
LLVM_NODISCARD size_t | find_first_not_of (char C, size_t From=0) const |
Find the first character in the string that is not C or npos if not found. More... | |
LLVM_NODISCARD size_t | find_first_not_of (StringRef Chars, size_t From=0) const |
Find the first character in the string that is not in the string Chars , or npos if not found. More... | |
LLVM_NODISCARD size_t | find_last_of (char C, size_t From=npos) const |
Find the last character in the string that is C , or npos if not found. More... | |
LLVM_NODISCARD size_t | find_last_of (StringRef Chars, size_t From=npos) const |
Find the last character in the string that is in C , or npos if not found. More... | |
LLVM_NODISCARD size_t | find_last_not_of (char C, size_t From=npos) const |
Find the last character in the string that is not C , or npos if not found. More... | |
LLVM_NODISCARD size_t | find_last_not_of (StringRef Chars, size_t From=npos) const |
Find the last character in the string that is not in Chars , or npos if not found. More... | |
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool | contains (StringRef Other) const |
Return true if the given string is a substring of *this, and false otherwise. More... | |
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool | contains (char C) const |
Return true if the given character is contained in *this, and false otherwise. More... | |
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool | contains_lower (StringRef Other) const |
Return true if the given string is a substring of *this, and false otherwise. More... | |
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool | contains_lower (char C) const |
Return true if the given character is contained in *this, and false otherwise. More... | |
LLVM_NODISCARD size_t | count (char C) const |
Return the number of occurrences of C in the string. More... | |
size_t | count (StringRef Str) const |
Return the number of non-overlapped occurrences of Str in the string. More... | |
template<typename T > | |
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type | getAsInteger (unsigned Radix, T &Result) const |
Parse the current string as an integer of the specified radix. More... | |
template<typename T > | |
std::enable_if<!std::numeric_limits< T >::is_signed, bool >::type | getAsInteger (unsigned Radix, T &Result) const |
template<typename T > | |
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type | consumeInteger (unsigned Radix, T &Result) |
Parse the current string as an integer of the specified radix. More... | |
template<typename T > | |
std::enable_if<!std::numeric_limits< T >::is_signed, bool >::type | consumeInteger (unsigned Radix, T &Result) |
bool | getAsInteger (unsigned Radix, APInt &Result) const |
Parse the current string as an integer of the specified Radix , or of an autosensed radix if the Radix given is 0. More... | |
bool | getAsDouble (double &Result, bool AllowInexact=true) const |
Parse the current string as an IEEE double-precision floating point value. More... | |
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef | substr (size_t Start, size_t N=npos) const |
Return a reference to the substring from [Start, Start + N). More... | |
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef | take_front (size_t N=1) const |
Return a StringRef equal to 'this' but with only the first N elements remaining. More... | |
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef | take_back (size_t N=1) const |
Return a StringRef equal to 'this' but with only the last N elements remaining. More... | |
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef | take_while (function_ref< bool(char)> F) const |
Return the longest prefix of 'this' such that every character in the prefix satisfies the given predicate. More... | |
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef | take_until (function_ref< bool(char)> F) const |
Return the longest prefix of 'this' such that no character in the prefix satisfies the given predicate. More... | |
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef | drop_front (size_t N=1) const |
Return a StringRef equal to 'this' but with the first N elements dropped. More... | |
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef | drop_back (size_t N=1) const |
Return a StringRef equal to 'this' but with the last N elements dropped. More... | |
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef | drop_while (function_ref< bool(char)> F) const |
Return a StringRef equal to 'this', but with all characters satisfying the given predicate dropped from the beginning of the string. More... | |
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef | drop_until (function_ref< bool(char)> F) const |
Return a StringRef equal to 'this', but with all characters not satisfying the given predicate dropped from the beginning of the string. More... | |
LLVM_ATTRIBUTE_ALWAYS_INLINE bool | consume_front (StringRef Prefix) |
Returns true if this StringRef has the given prefix and removes that prefix. More... | |
LLVM_ATTRIBUTE_ALWAYS_INLINE bool | consume_back (StringRef Suffix) |
Returns true if this StringRef has the given suffix and removes that suffix. More... | |
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef | slice (size_t Start, size_t End) const |
Return a reference to the substring from [Start, End). More... | |
LLVM_NODISCARD std::pair< StringRef, StringRef > | split (char Separator) const |
Split into two substrings around the first occurrence of a separator character. More... | |
LLVM_NODISCARD std::pair< StringRef, StringRef > | split (StringRef Separator) const |
Split into two substrings around the first occurrence of a separator string. More... | |
LLVM_NODISCARD std::pair< StringRef, StringRef > | rsplit (StringRef Separator) const |
Split into two substrings around the last occurrence of a separator string. More... | |
void | split (SmallVectorImpl< StringRef > &A, StringRef Separator, int MaxSplit=-1, bool KeepEmpty=true) const |
Split into substrings around the occurrences of a separator string. More... | |
void | split (SmallVectorImpl< StringRef > &A, char Separator, int MaxSplit=-1, bool KeepEmpty=true) const |
Split into substrings around the occurrences of a separator character. More... | |
LLVM_NODISCARD std::pair< StringRef, StringRef > | rsplit (char Separator) const |
Split into two substrings around the last occurrence of a separator character. More... | |
LLVM_NODISCARD StringRef | ltrim (char Char) const |
Return string with consecutive Char characters starting from the the left removed. More... | |
LLVM_NODISCARD StringRef | ltrim (StringRef Chars=" \\\) const |
Return string with consecutive characters in Chars starting from the left removed. More... | |
LLVM_NODISCARD StringRef | rtrim (char Char) const |
Return string with consecutive Char characters starting from the right removed. More... | |
LLVM_NODISCARD StringRef | rtrim (StringRef Chars=" \\\) const |
Return string with consecutive characters in Chars starting from the right removed. More... | |
LLVM_NODISCARD StringRef | trim (char Char) const |
Return string with consecutive Char characters starting from the left and right removed. More... | |
LLVM_NODISCARD StringRef | trim (StringRef Chars=" \\\) const |
Return string with consecutive characters in Chars starting from the left and right removed. More... | |
StringRef ()=default | |
Construct an empty string ref. More... | |
StringRef (std::nullptr_t)=delete | |
Disable conversion from nullptr. More... | |
LLVM_ATTRIBUTE_ALWAYS_INLINE | StringRef (const char *Str) |
Construct a string ref from a cstring. More... | |
LLVM_ATTRIBUTE_ALWAYS_INLINE constexpr | StringRef (const char *data, size_t length) |
Construct a string ref from a pointer and length. More... | |
LLVM_ATTRIBUTE_ALWAYS_INLINE | StringRef (const std::string &Str) |
Construct a string ref from an std::string. More... | |
Static Public Member Functions | |
template<size_t N> | |
static constexpr StringLiteral | withInnerNUL (const char(&Str)[N]) |
Static Public Member Functions inherited from llvm::StringRef | |
static StringRef | withNullAsEmpty (const char *data) |
Additional Inherited Members | |
Public Types inherited from llvm::StringRef | |
using | iterator = const char * |
using | const_iterator = const char * |
using | size_type = size_t |
Static Public Attributes inherited from llvm::StringRef | |
static const size_t | npos = ~size_t(0) |
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs with the length computed at compile time.
In order to avoid the invocation of a global constructor, StringLiteral should only be used in a constexpr context, as such:
constexpr StringLiteral S("test");
Definition at line 869 of file StringRef.h.
Definition at line 876 of file StringRef.h.
|
inlinestatic |
Definition at line 889 of file StringRef.h.
References LLVM_ATTRIBUTE_ALWAYS_INLINE.