WPILibC++  2019.3.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
wpi::StringLiteral Class Reference

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 <StringRef.h>

Inheritance diagram for wpi::StringLiteral:
wpi::StringRef

Public Member Functions

template<size_t N>
constexpr StringLiteral (const char(&Str)[N])
 
- Public Member Functions inherited from wpi::StringRef
iterator begin () const noexcept
 
iterator end () const noexcept
 
const unsigned char * bytes_begin () const noexcept
 
const unsigned char * bytes_end () const noexcept
 
iterator_range< const unsigned
char * > 
bytes () const noexcept
 
LLVM_NODISCARD
LLVM_ATTRIBUTE_ALWAYS_INLINE
const char * 
data () const noexcept
 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 noexcept
 empty - Check if the string is empty.
 
LLVM_NODISCARD
LLVM_ATTRIBUTE_ALWAYS_INLINE
size_t 
size () const noexcept
 size - Get the string size.
 
LLVM_NODISCARD char front () const noexcept
 front - Get the first character in the string.
 
LLVM_NODISCARD char back () const noexcept
 back - Get the last character in the string.
 
template<typename Allocator >
LLVM_NODISCARD StringRef copy (Allocator &A) const
 
LLVM_NODISCARD
LLVM_ATTRIBUTE_ALWAYS_INLINE
bool 
equals (StringRef RHS) const noexcept
 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 noexcept
 equals_lower - Check for string equality, ignoring case.
 
LLVM_NODISCARD
LLVM_ATTRIBUTE_ALWAYS_INLINE
int 
compare (StringRef RHS) const noexcept
 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 noexcept
 compare_lower - Compare two strings, ignoring case.
 
LLVM_NODISCARD int compare_numeric (StringRef RHS) const noexcept
 compare_numeric - Compare two strings, treating sequences of digits as numbers. More...
 
LLVM_NODISCARD std::string str () const
 str - Get the contents as an std::string.
 
LLVM_NODISCARD std::string lower () const
 
LLVM_NODISCARD std::string upper () const
 Convert the given ASCII string to uppercase.
 
LLVM_NODISCARD char operator[] (size_t Index) const noexcept
 
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 noexcept
 Check if this string starts with the given Prefix.
 
LLVM_NODISCARD bool startswith_lower (StringRef Prefix) const noexcept
 Check if this string starts with the given Prefix, ignoring case.
 
LLVM_NODISCARD
LLVM_ATTRIBUTE_ALWAYS_INLINE
bool 
endswith (StringRef Suffix) const noexcept
 Check if this string ends with the given Suffix.
 
LLVM_NODISCARD bool endswith_lower (StringRef Suffix) const noexcept
 Check if this string ends with the given Suffix, ignoring case.
 
LLVM_NODISCARD
LLVM_ATTRIBUTE_ALWAYS_INLINE
size_t 
find (char C, size_t From=0) const noexcept
 Search for the first character C in the string. More...
 
LLVM_NODISCARD size_t find_lower (char C, size_t From=0) const noexcept
 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 noexcept
 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 noexcept
 Search for the first character not satisfying the predicate F. More...
 
LLVM_NODISCARD size_t find (StringRef Str, size_t From=0) const noexcept
 Search for the first string Str in the string. More...
 
LLVM_NODISCARD size_t find_lower (StringRef Str, size_t From=0) const noexcept
 Search for the first string Str in the string, ignoring case. More...
 
LLVM_NODISCARD size_t rfind (char C, size_t From=npos) const noexcept
 Search for the last character C in the string. More...
 
LLVM_NODISCARD size_t rfind_lower (char C, size_t From=npos) const noexcept
 Search for the last character C in the string, ignoring case. More...
 
LLVM_NODISCARD size_t rfind (StringRef Str) const noexcept
 Search for the last string Str in the string. More...
 
LLVM_NODISCARD size_t rfind_lower (StringRef Str) const noexcept
 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 noexcept
 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 noexcept
 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 noexcept
 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 noexcept
 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 noexcept
 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 noexcept
 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 noexcept
 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 noexcept
 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 noexcept
 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 noexcept
 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 noexcept
 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 noexcept
 Return true if the given character is contained in *this, and false otherwise. More...
 
LLVM_NODISCARD size_t count (char C) const noexcept
 Return the number of occurrences of C in the string.
 
size_t count (StringRef Str) const noexcept
 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 noexcept
 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 noexcept
 
template<typename T >
std::enable_if
< std::numeric_limits< T >
::is_signed, bool >::type 
consumeInteger (unsigned Radix, T &Result) noexcept
 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) noexcept
 
LLVM_NODISCARD
LLVM_ATTRIBUTE_ALWAYS_INLINE
StringRef 
substr (size_t Start, size_t N=npos) const noexcept
 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 noexcept
 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 noexcept
 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 noexcept
 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 noexcept
 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 noexcept
 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 noexcept
 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 noexcept
 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 noexcept
 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) noexcept
 Returns true if this StringRef has the given prefix and removes that prefix. More...
 
LLVM_ATTRIBUTE_ALWAYS_INLINE bool consume_back (StringRef Suffix) noexcept
 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 noexcept
 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...
 
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 noexcept
 Return string with consecutive Char characters starting from the the left removed. More...
 
LLVM_NODISCARD StringRef ltrim (StringRef Chars=" \t\n\v\f\r") const noexcept
 Return string with consecutive characters in Chars starting from the left removed. More...
 
LLVM_NODISCARD StringRef rtrim (char Char) const noexcept
 Return string with consecutive Char characters starting from the right removed. More...
 
LLVM_NODISCARD StringRef rtrim (StringRef Chars=" \t\n\v\f\r") const noexcept
 Return string with consecutive characters in Chars starting from the right removed. More...
 
LLVM_NODISCARD StringRef trim (char Char) const noexcept
 Return string with consecutive Char characters starting from the left and right removed. More...
 
LLVM_NODISCARD StringRef trim (StringRef Chars=" \t\n\v\f\r") const noexcept
 Return string with consecutive characters in Chars starting from the left and right removed. More...
 
 StringRef ()=default
 Construct an empty string ref.
 
 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.
 
LLVM_ATTRIBUTE_ALWAYS_INLINE
constexpr 
StringRef (const char *data, size_t length)
 Construct a string ref from a pointer and length.
 
LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef (const std::string &Str)
 Construct a string ref from an std::string.
 

Static Public Member Functions

template<size_t N>
static constexpr StringLiteral withInnerNUL (const char(&Str)[N])
 
- Static Public Member Functions inherited from wpi::StringRef
static StringRef withNullAsEmpty (const char *data)
 

Additional Inherited Members

- Public Types inherited from wpi::StringRef
using iterator = const char *
 
using const_iterator = const char *
 
using size_type = size_t
 
- Static Public Attributes inherited from wpi::StringRef
static const size_t npos = ~size_t(0)
 

Detailed Description

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");


The documentation for this class was generated from the following file: