class StringRef

Declaration

class StringRef { /* full declaration omitted */ };

Description

StringRef - Represent a constant reference to a string, i.e. a character array and a length, which need not be null terminated. This class does not own the string data, it is expected to be used in situations where the character data resides in some other buffer, whose lifetime extends past that of the StringRef. For this reason, it is not in general safe to store a StringRef.

Declared at: llvm/include/llvm/ADT/StringRef.h:58

Member Variables

private const char* Data = nullptr
The start of the string, in an external buffer.
private size_t Length = 0
The length of the string.
public static const size_t npos = ~unsigned long(0)

Method Overview

  • public StringRef()
  • public StringRef(std::nullptr_t)
  • public constexpr StringRef(const char * Str)
  • public constexpr StringRef(const char * data, size_t length)
  • public StringRef(const std::string & Str)
  • public char back() const
  • public llvm::StringRef::iterator begin() const
  • public iterator_range<const unsigned char *> bytes() const
  • public const unsigned char * bytes_begin() const
  • public const unsigned char * bytes_end() const
  • public int compare(llvm::StringRef RHS) const
  • private static int compareMemory(const char * Lhs, const char * Rhs, size_t Length)
  • public int compare_insensitive(llvm::StringRef RHS) const
  • public int compare_numeric(llvm::StringRef RHS) const
  • public template <typename T>std::enable_if_t<std::numeric_limits<T>::is_signed, bool> consumeInteger(unsigned int Radix, T & Result)
  • public template <typename T>std::enable_if_t<!std::numeric_limits<T>::is_signed, bool> consumeInteger(unsigned int Radix, T & Result)
  • public bool consume_back(llvm::StringRef Suffix)
  • public bool consume_back_insensitive(llvm::StringRef Suffix)
  • public bool consume_front(llvm::StringRef Prefix)
  • public bool consume_front_insensitive(llvm::StringRef Prefix)
  • public bool contains(char C) const
  • public bool contains(llvm::StringRef Other) const
  • public bool contains_insensitive(char C) const
  • public bool contains_insensitive(llvm::StringRef Other) const
  • public template <typename Allocator>llvm::StringRef copy(Allocator & A) const
  • public size_t count(llvm::StringRef Str) const
  • public size_t count(char C) const
  • public const char * data() const
  • public llvm::StringRef detectEOL() const
  • public llvm::StringRef drop_back(size_t N = 1) const
  • public llvm::StringRef drop_front(size_t N = 1) const
  • public llvm::StringRef drop_until(function_ref<bool (char)> F) const
  • public llvm::StringRef drop_while(function_ref<bool (char)> F) const
  • public unsigned int edit_distance(llvm::StringRef Other, bool AllowReplacements = true, unsigned int MaxEditDistance = 0) const
  • public unsigned int edit_distance_insensitive(llvm::StringRef Other, bool AllowReplacements = true, unsigned int MaxEditDistance = 0) const
  • public constexpr bool empty() const
  • public llvm::StringRef::iterator end() const
  • public bool endswith(llvm::StringRef Suffix) const
  • public bool endswith_insensitive(llvm::StringRef Suffix) const
  • public bool equals(llvm::StringRef RHS) const
  • public bool equals_insensitive(llvm::StringRef RHS) const
  • public size_t find(llvm::StringRef Str, size_t From = 0) const
  • public size_t find(char C, size_t From = 0) const
  • public size_t find_first_not_of(llvm::StringRef Chars, size_t From = 0) const
  • public size_t find_first_not_of(char C, size_t From = 0) const
  • public size_t find_first_of(llvm::StringRef Chars, size_t From = 0) const
  • public size_t find_first_of(char C, size_t From = 0) const
  • public size_t find_if(function_ref<bool (char)> F, size_t From = 0) const
  • public size_t find_if_not(function_ref<bool (char)> F, size_t From = 0) const
  • public size_t find_insensitive(char C, size_t From = 0) const
  • public size_t find_insensitive(llvm::StringRef Str, size_t From = 0) const
  • public size_t find_last_not_of(char C, size_t From = npos) const
  • public size_t find_last_not_of(llvm::StringRef Chars, size_t From = npos) const
  • public size_t find_last_of(llvm::StringRef Chars, size_t From = npos) const
  • public size_t find_last_of(char C, size_t From = npos) const
  • public char front() const
  • public bool getAsDouble(double & Result, bool AllowInexact = true) const
  • public bool getAsInteger(unsigned int Radix, llvm::APInt & Result) const
  • public template <typename T>std::enable_if_t<!std::numeric_limits<T>::is_signed, bool> getAsInteger(unsigned int Radix, T & Result) const
  • public template <typename T>std::enable_if_t<std::numeric_limits<T>::is_signed, bool> getAsInteger(unsigned int Radix, T & Result) const
  • public std::string lower() const
  • public llvm::StringRef ltrim(char Char) const
  • public llvm::StringRef ltrim(llvm::StringRef Chars = " \t\n\v\f\r") const
  • public std::string operator basic_string() const
  • public size_t rfind(llvm::StringRef Str) const
  • public size_t rfind(char C, size_t From = npos) const
  • public size_t rfind_insensitive(char C, size_t From = npos) const
  • public size_t rfind_insensitive(llvm::StringRef Str) const
  • public std::pair<StringRef, StringRef> rsplit(char Separator) const
  • public std::pair<StringRef, StringRef> rsplit(llvm::StringRef Separator) const
  • public llvm::StringRef rtrim(char Char) const
  • public llvm::StringRef rtrim(llvm::StringRef Chars = " \t\n\v\f\r") const
  • public constexpr size_t size() const
  • public llvm::StringRef slice(size_t Start, size_t End) const
  • public std::pair<StringRef, StringRef> split(char Separator) const
  • public void split(SmallVectorImpl<llvm::StringRef> & A, char Separator, int MaxSplit = -1, bool KeepEmpty = true) const
  • public void split(SmallVectorImpl<llvm::StringRef> & A, llvm::StringRef Separator, int MaxSplit = -1, bool KeepEmpty = true) const
  • public std::pair<StringRef, StringRef> split(llvm::StringRef Separator) const
  • public bool startswith(llvm::StringRef Prefix) const
  • public bool startswith_insensitive(llvm::StringRef Prefix) const
  • public std::string str() const
  • private static constexpr size_t strLen(const char * Str)
  • public llvm::StringRef substr(size_t Start, size_t N = npos) const
  • public llvm::StringRef take_back(size_t N = 1) const
  • public llvm::StringRef take_front(size_t N = 1) const
  • public llvm::StringRef take_until(function_ref<bool (char)> F) const
  • public llvm::StringRef take_while(function_ref<bool (char)> F) const
  • public llvm::StringRef trim(char Char) const
  • public llvm::StringRef trim(llvm::StringRef Chars = " \t\n\v\f\r") const
  • public std::string upper() const

Methods

StringRef()

Description

Construct an empty string ref.

Declared at: llvm/include/llvm/ADT/StringRef.h:100

StringRef(std::nullptr_t)

Description

Disable conversion from nullptr. This prevents things like if (S == nullptr)

Declared at: llvm/include/llvm/ADT/StringRef.h:104

Parameters

std::nullptr_t

constexpr StringRef(const char* Str)

Description

Construct a string ref from a cstring.

Declared at: llvm/include/llvm/ADT/StringRef.h:107

Parameters

const char* Str

constexpr StringRef(const char* data,
                    size_t length)

Description

Construct a string ref from a pointer and length.

Declared at: llvm/include/llvm/ADT/StringRef.h:111

Parameters

const char* data
size_t length

StringRef(const std::string& Str)

Description

Construct a string ref from an std::string.

Declared at: llvm/include/llvm/ADT/StringRef.h:115

Parameters

const std::string& Str

char back() const

Description

back - Get the last character in the string.

Declared at: llvm/include/llvm/ADT/StringRef.h:168

llvm::StringRef::iterator begin() const

Description

@ } @ {

Declared at: llvm/include/llvm/ADT/StringRef.h:128

iterator_range<const unsigned char*> bytes() const

Declared at: llvm/include/llvm/ADT/StringRef.h:138

const unsigned char* bytes_begin() const

Declared at: llvm/include/llvm/ADT/StringRef.h:132

const unsigned char* bytes_end() const

Declared at: llvm/include/llvm/ADT/StringRef.h:135

int compare(llvm::StringRef RHS) const

Description

compare - Compare two strings; the result is -1, 0, or 1 if this string is lexicographically less than, equal to, or greater than the \p RHS.

Declared at: llvm/include/llvm/ADT/StringRef.h:201

Parameters

llvm::StringRef RHS

static int compareMemory(const char* Lhs,
                         const char* Rhs,
                         size_t Length)

Declared at: llvm/include/llvm/ADT/StringRef.h:75

Parameters

const char* Lhs
const char* Rhs
size_t Length

int compare_insensitive(llvm::StringRef RHS) const

Description

Compare two strings, ignoring case.

Declared at: llvm/include/llvm/ADT/StringRef.h:214

Parameters

llvm::StringRef RHS

int compare_numeric(llvm::StringRef RHS) const

Description

compare_numeric - Compare two strings, treating sequences of digits as numbers.

Declared at: llvm/include/llvm/ADT/StringRef.h:219

Parameters

llvm::StringRef RHS

template <typename T>
std::enable_if_t<
    std::numeric_limits<T>::is_signed,
    bool>
consumeInteger(unsigned int Radix, T& Result)

Description

Parse the current string as an integer of the specified radix. If\p Radix is specified as zero, this does radix autosensing using extended C rules: 0 is octal, 0x is hex, 0b is binary. If the string does not begin with a number of the specified radix, this returns true to signify the error. The string is considered erroneous if empty or if it overflows T. The portion of the string representing the discovered numeric value is removed from the beginning of the string.

Declared at: llvm/include/llvm/ADT/StringRef.h:548

Templates

T

Parameters

unsigned int Radix
T& Result

template <typename T>
std::enable_if_t<
    !std::numeric_limits<T>::is_signed,
    bool>
consumeInteger(unsigned int Radix, T& Result)

Declared at: llvm/include/llvm/ADT/StringRef.h:559

Templates

T

Parameters

unsigned int Radix
T& Result

bool consume_back(llvm::StringRef Suffix)

Description

Returns true if this StringRef has the given suffix and removes that suffix.

Declared at: llvm/include/llvm/ADT/StringRef.h:706

Parameters

llvm::StringRef Suffix

bool consume_back_insensitive(
    llvm::StringRef Suffix)

Description

Returns true if this StringRef has the given suffix, ignoring case, and removes that suffix.

Declared at: llvm/include/llvm/ADT/StringRef.h:716

Parameters

llvm::StringRef Suffix

bool consume_front(llvm::StringRef Prefix)

Description

Returns true if this StringRef has the given prefix and removes that prefix.

Declared at: llvm/include/llvm/ADT/StringRef.h:686

Parameters

llvm::StringRef Prefix

bool consume_front_insensitive(
    llvm::StringRef Prefix)

Description

Returns true if this StringRef has the given prefix, ignoring case, and removes that prefix.

Declared at: llvm/include/llvm/ADT/StringRef.h:696

Parameters

llvm::StringRef Prefix

bool contains(char C) const

Description

Return true if the given character is contained in *this, and false otherwise.

Declared at: llvm/include/llvm/ADT/StringRef.h:471

Parameters

char C

bool contains(llvm::StringRef Other) const

Description

Return true if the given string is a substring of *this, and false otherwise.

Declared at: llvm/include/llvm/ADT/StringRef.h:466

Parameters

llvm::StringRef Other

bool contains_insensitive(char C) const

Description

Return true if the given character is contained in *this, and false otherwise.

Declared at: llvm/include/llvm/ADT/StringRef.h:483

Parameters

char C

bool contains_insensitive(
    llvm::StringRef Other) const

Description

Return true if the given string is a substring of *this, and false otherwise.

Declared at: llvm/include/llvm/ADT/StringRef.h:476

Parameters

llvm::StringRef Other

template <typename Allocator>
llvm::StringRef copy(Allocator& A) const

Declared at: llvm/include/llvm/ADT/StringRef.h:175

Templates

Allocator

Parameters

Allocator& A

size_t count(llvm::StringRef Str) const

Description

Return the number of non-overlapped occurrences of \p Str in the string.

Declared at: llvm/include/llvm/ADT/StringRef.h:503

Parameters

llvm::StringRef Str

size_t count(char C) const

Description

Return the number of occurrences of \p C in the string.

Declared at: llvm/include/llvm/ADT/StringRef.h:493

Parameters

char C

const char* data() const

Description

data - Get a pointer to the start of the string (which may not be null terminated).

Declared at: llvm/include/llvm/ADT/StringRef.h:149

llvm::StringRef detectEOL() const

Description

Detect the line ending style of the string. If the string contains a line ending, return the line ending character sequence that is detected. Otherwise return '\n' for unix line endings.

Declared at: llvm/include/llvm/ADT/StringRef.h:892

Returns

- The line ending character sequence.

llvm::StringRef drop_back(size_t N = 1) const

Description

Return a StringRef equal to 'this' but with the last \p N elements dropped.

Declared at: llvm/include/llvm/ADT/StringRef.h:665

Parameters

size_t N = 1

llvm::StringRef drop_front(size_t N = 1) const

Description

Return a StringRef equal to 'this' but with the first \p N elements dropped.

Declared at: llvm/include/llvm/ADT/StringRef.h:657

Parameters

size_t N = 1

llvm::StringRef drop_until(
    function_ref<bool(char)> F) const

Description

Return a StringRef equal to 'this', but with all characters not satisfying the given predicate dropped from the beginning of the string.

Declared at: llvm/include/llvm/ADT/StringRef.h:680

Parameters

function_ref<bool(char)> F

llvm::StringRef drop_while(
    function_ref<bool(char)> F) const

Description

Return a StringRef equal to 'this', but with all characters satisfying the given predicate dropped from the beginning of the string.

Declared at: llvm/include/llvm/ADT/StringRef.h:673

Parameters

function_ref<bool(char)> F

unsigned int edit_distance(
    llvm::StringRef Other,
    bool AllowReplacements = true,
    unsigned int MaxEditDistance = 0) const

Description

Determine the edit distance between this string and another string.

Declared at: llvm/include/llvm/ADT/StringRef.h:240

Parameters

llvm::StringRef Other
the string to compare this string against.
bool AllowReplacements = true
whether to allow character replacements (change one character into another) as a single operation, rather than as two operations (an insertion and a removal).
unsigned int MaxEditDistance = 0
If non-zero, the maximum edit distance that this routine is allowed to compute. If the edit distance will exceed that maximum, returns \c MaxEditDistance+1.

Returns

the minimum number of character insertions, removals, or (if \p AllowReplacements is \c true) replacements needed to transform one of the given strings into the other. If zero, the strings are identical.

unsigned int edit_distance_insensitive(
    llvm::StringRef Other,
    bool AllowReplacements = true,
    unsigned int MaxEditDistance = 0) const

Declared at: llvm/include/llvm/ADT/StringRef.h:244

Parameters

llvm::StringRef Other
bool AllowReplacements = true
unsigned int MaxEditDistance = 0

constexpr bool empty() const

Description

empty - Check if the string is empty.

Declared at: llvm/include/llvm/ADT/StringRef.h:153

llvm::StringRef::iterator end() const

Declared at: llvm/include/llvm/ADT/StringRef.h:130

bool endswith(llvm::StringRef Suffix) const

Description

Check if this string ends with the given \p Suffix.

Declared at: llvm/include/llvm/ADT/StringRef.h:301

Parameters

llvm::StringRef Suffix

bool endswith_insensitive(
    llvm::StringRef Suffix) const

Description

Check if this string ends with the given \p Suffix, ignoring case.

Declared at: llvm/include/llvm/ADT/StringRef.h:308

Parameters

llvm::StringRef Suffix

bool equals(llvm::StringRef RHS) const

Description

equals - Check for string equality, this is more efficient than compare() when the relative ordering of inequal strings isn't needed.

Declared at: llvm/include/llvm/ADT/StringRef.h:187

Parameters

llvm::StringRef RHS

bool equals_insensitive(llvm::StringRef RHS) const

Description

Check for string equality, ignoring case.

Declared at: llvm/include/llvm/ADT/StringRef.h:194

Parameters

llvm::StringRef RHS

size_t find(llvm::StringRef Str,
            size_t From = 0) const

Description

Search for the first string \p Str in the string.

Declared at: llvm/include/llvm/ADT/StringRef.h:365

Parameters

llvm::StringRef Str
size_t From = 0

Returns

The index of the first occurrence of \p Str, or npos if not found.

size_t find(char C, size_t From = 0) const

Description

Search for the first character \p C in the string.

Declared at: llvm/include/llvm/ADT/StringRef.h:319

Parameters

char C
size_t From = 0

Returns

The index of the first occurrence of \p C, or npos if not found.

size_t find_first_not_of(llvm::StringRef Chars,
                         size_t From = 0) const

Description

Find the first character in the string that is not in the string\p Chars, or npos if not found. Complexity: O(size() + Chars.size())

Declared at: llvm/include/llvm/ADT/StringRef.h:435

Parameters

llvm::StringRef Chars
size_t From = 0

size_t find_first_not_of(char C,
                         size_t From = 0) const

Description

Find the first character in the string that is not \p C or npos if not found.

Declared at: llvm/include/llvm/ADT/StringRef.h:428

Parameters

char C
size_t From = 0

size_t find_first_of(llvm::StringRef Chars,
                     size_t From = 0) const

Description

Find the first character in the string that is in \p Chars, or npos if not found. Complexity: O(size() + Chars.size())

Declared at: llvm/include/llvm/ADT/StringRef.h:423

Parameters

llvm::StringRef Chars
size_t From = 0

size_t find_first_of(char C,
                     size_t From = 0) const

Description

Find the first character in the string that is \p C, or npos if not found. Same as find.

Declared at: llvm/include/llvm/ADT/StringRef.h:414

Parameters

char C
size_t From = 0

size_t find_if(function_ref<bool(char)> F,
               size_t From = 0) const

Description

Search for the first character satisfying the predicate \p F

Declared at: llvm/include/llvm/ADT/StringRef.h:341

Parameters

function_ref<bool(char)> F
size_t From = 0

Returns

The index of the first character satisfying \p F starting from\p From, or npos if not found.

size_t find_if_not(function_ref<bool(char)> F,
                   size_t From = 0) const

Description

Search for the first character not satisfying the predicate \p F

Declared at: llvm/include/llvm/ADT/StringRef.h:356

Parameters

function_ref<bool(char)> F
size_t From = 0

Returns

The index of the first character not satisfying \p F starting from \p From, or npos if not found.

size_t find_insensitive(char C,
                        size_t From = 0) const

Description

Search for the first character \p C in the string, ignoring case.

Declared at: llvm/include/llvm/ADT/StringRef.h:334

Parameters

char C
size_t From = 0

Returns

The index of the first occurrence of \p C, or npos if not found.

size_t find_insensitive(llvm::StringRef Str,
                        size_t From = 0) const

Description

Search for the first string \p Str in the string, ignoring case.

Declared at: llvm/include/llvm/ADT/StringRef.h:372

Parameters

llvm::StringRef Str
size_t From = 0

Returns

The index of the first occurrence of \p Str, or npos if not found.

size_t find_last_not_of(char C,
                        size_t From = npos) const

Description

Find the last character in the string that is not \p C, or npos if not found.

Declared at: llvm/include/llvm/ADT/StringRef.h:454

Parameters

char C
size_t From = npos

size_t find_last_not_of(llvm::StringRef Chars,
                        size_t From = npos) const

Description

Find the last character in the string that is not in \p Chars, or npos if not found. Complexity: O(size() + Chars.size())

Declared at: llvm/include/llvm/ADT/StringRef.h:461

Parameters

llvm::StringRef Chars
size_t From = npos

size_t find_last_of(llvm::StringRef Chars,
                    size_t From = npos) const

Description

Find the last character in the string that is in \p C, or npos if not found. Complexity: O(size() + Chars.size())

Declared at: llvm/include/llvm/ADT/StringRef.h:449

Parameters

llvm::StringRef Chars
size_t From = npos

size_t find_last_of(char C,
                    size_t From = npos) const

Description

Find the last character in the string that is \p C, or npos if not found.

Declared at: llvm/include/llvm/ADT/StringRef.h:440

Parameters

char C
size_t From = npos

char front() const

Description

front - Get the first character in the string.

Declared at: llvm/include/llvm/ADT/StringRef.h:161

bool getAsDouble(double& Result,
                 bool AllowInexact = true) const

Description

Parse the current string as an IEEE double-precision floating point value. The string must be a well-formed double. If \p AllowInexact is false, the function will fail if the string cannot be represented exactly. Otherwise, the function only fails in case of an overflow or underflow, or an invalid floating point representation.

Declared at: llvm/include/llvm/ADT/StringRef.h:587

Parameters

double& Result
bool AllowInexact = true

bool getAsInteger(unsigned int Radix,
                  llvm::APInt& Result) const

Description

Parse the current string as an integer of the specified \p Radix, or of an autosensed radix if the \p Radix given is 0. The current value in\p Result is discarded, and the storage is changed to be wide enough to store the parsed integer. APInt::fromString is superficially similar but assumes the string is well-formed in the given radix.

Declared at: llvm/include/llvm/ADT/StringRef.h:578

Parameters

unsigned int Radix
llvm::APInt& Result

Returns

true if the string does not solely consist of a valid non-empty number in the appropriate base.

template <typename T>
std::enable_if_t<
    !std::numeric_limits<T>::is_signed,
    bool>
getAsInteger(unsigned int Radix, T& Result) const

Declared at: llvm/include/llvm/ADT/StringRef.h:525

Templates

T

Parameters

unsigned int Radix
T& Result

template <typename T>
std::enable_if_t<
    std::numeric_limits<T>::is_signed,
    bool>
getAsInteger(unsigned int Radix, T& Result) const

Description

Parse the current string as an integer of the specified radix. If\p Radix is specified as zero, this does radix autosensing using extended C rules: 0 is octal, 0x is hex, 0b is binary. If the string is invalid or if only a subset of the string is valid, this returns true to signify the error. The string is considered erroneous if empty or if it overflows T.

Declared at: llvm/include/llvm/ADT/StringRef.h:514

Templates

T

Parameters

unsigned int Radix
T& Result

std::string lower() const

Description

@ } @ {

Declared at: llvm/include/llvm/ADT/StringRef.h:595

llvm::StringRef ltrim(char Char) const

Description

Return string with consecutive \p Char characters starting from the the left removed.

Declared at: llvm/include/llvm/ADT/StringRef.h:846

Parameters

char Char

llvm::StringRef ltrim(
    llvm::StringRef Chars = " \t\n\v\f\r") const

Description

Return string with consecutive characters in \p Chars starting from the left removed.

Declared at: llvm/include/llvm/ADT/StringRef.h:853

Parameters

llvm::StringRef Chars = " \t\n\v\f\r"

std::string operator basic_string() const

Description

@ } @ {

Declared at: llvm/include/llvm/ADT/StringRef.h:276

size_t rfind(llvm::StringRef Str) const

Description

Search for the last string \p Str in the string.

Declared at: llvm/include/llvm/ADT/StringRef.h:402

Parameters

llvm::StringRef Str

Returns

The index of the last occurrence of \p Str, or npos if not found.

size_t rfind(char C, size_t From = npos) const

Description

Search for the last character \p C in the string.

Declared at: llvm/include/llvm/ADT/StringRef.h:379

Parameters

char C
size_t From = npos

Returns

The index of the last occurrence of \p C, or npos if not found.

size_t rfind_insensitive(char C,
                         size_t From = npos) const

Description

Search for the last character \p C in the string, ignoring case.

Declared at: llvm/include/llvm/ADT/StringRef.h:395

Parameters

char C
size_t From = npos

Returns

The index of the last occurrence of \p C, or npos if not found.

size_t rfind_insensitive(
    llvm::StringRef Str) const

Description

Search for the last string \p Str in the string, ignoring case.

Declared at: llvm/include/llvm/ADT/StringRef.h:409

Parameters

llvm::StringRef Str

Returns

The index of the last occurrence of \p Str, or npos if not found.

std::pair<StringRef, StringRef> rsplit(
    char Separator) const

Description

Split into two substrings around the last occurrence of a separator character. If \p Separator is in the string, then the result is a pair (LHS, RHS) such that (*this == LHS + Separator + RHS) is true and RHS is minimal. If \p Separator is not in the string, then the result is a pair (LHS, RHS) where (*this == LHS) and (RHS == "").

Declared at: llvm/include/llvm/ADT/StringRef.h:839

Parameters

char Separator
- The character to split on.

Returns

- The split substrings.

std::pair<StringRef, StringRef> rsplit(
    llvm::StringRef Separator) const

Description

Split into two substrings around the last occurrence of a separator string. If \p Separator is in the string, then the result is a pair (LHS, RHS) such that (*this == LHS + Separator + RHS) is true and RHS is minimal. If \p Separator is not in the string, then the result is a pair (LHS, RHS) where (*this == LHS) and (RHS == "").

Declared at: llvm/include/llvm/ADT/StringRef.h:786

Parameters

llvm::StringRef Separator
- The string to split on.

Returns

- The split substrings.

llvm::StringRef rtrim(char Char) const

Description

Return string with consecutive \p Char characters starting from the right removed.

Declared at: llvm/include/llvm/ADT/StringRef.h:860

Parameters

char Char

llvm::StringRef rtrim(
    llvm::StringRef Chars = " \t\n\v\f\r") const

Description

Return string with consecutive characters in \p Chars starting from the right removed.

Declared at: llvm/include/llvm/ADT/StringRef.h:867

Parameters

llvm::StringRef Chars = " \t\n\v\f\r"

constexpr size_t size() const

Description

size - Get the string size.

Declared at: llvm/include/llvm/ADT/StringRef.h:157

llvm::StringRef slice(size_t Start,
                      size_t End) const

Description

Return a reference to the substring from [Start, End).

Declared at: llvm/include/llvm/ADT/StringRef.h:736

Parameters

size_t Start
The index of the starting character in the substring; if the index is npos or greater than the length of the string then the empty substring will be returned.
size_t End
The index following the last character to include in the substring. If this is npos or exceeds the number of characters remaining in the string, the string suffix (starting with \p Start) will be returned. If this is less than \p Start, an empty string will be returned.

std::pair<StringRef, StringRef> split(
    char Separator) const

Description

Split into two substrings around the first occurrence of a separator character. If \p Separator is in the string, then the result is a pair (LHS, RHS) such that (*this == LHS + Separator + RHS) is true and RHS is maximal. If \p Separator is not in the string, then the result is a pair (LHS, RHS) where (*this == LHS) and (RHS == "").

Declared at: llvm/include/llvm/ADT/StringRef.h:753

Parameters

char Separator
The character to split on.

Returns

The split substrings.

void split(SmallVectorImpl<llvm::StringRef>& A,
           char Separator,
           int MaxSplit = -1,
           bool KeepEmpty = true) const

Description

Split into substrings around the occurrences of a separator character. Each substring is stored in \p A. If \p MaxSplit is >= 0, at most\p MaxSplit splits are done and consequently < = \p MaxSplit + 1 elements are added to A. If \p KeepEmpty is false, empty strings are not added to \p A. They still count when considering \p MaxSplit An useful invariant is that Separator.join(A) == *this if MaxSplit == -1 and KeepEmpty == true

Declared at: llvm/include/llvm/ADT/StringRef.h:825

Parameters

SmallVectorImpl<llvm::StringRef>& A
- Where to put the substrings.
char Separator
- The string to split on.
int MaxSplit = -1
- The maximum number of times the string is split.
bool KeepEmpty = true
- True if empty substring should be added.

void split(SmallVectorImpl<llvm::StringRef>& A,
           llvm::StringRef Separator,
           int MaxSplit = -1,
           bool KeepEmpty = true) const

Description

Split into substrings around the occurrences of a separator string. Each substring is stored in \p A. If \p MaxSplit is >= 0, at most\p MaxSplit splits are done and consequently < = \p MaxSplit + 1 elements are added to A. If \p KeepEmpty is false, empty strings are not added to \p A. They still count when considering \p MaxSplit An useful invariant is that Separator.join(A) == *this if MaxSplit == -1 and KeepEmpty == true

Declared at: llvm/include/llvm/ADT/StringRef.h:807

Parameters

SmallVectorImpl<llvm::StringRef>& A
- Where to put the substrings.
llvm::StringRef Separator
- The string to split on.
int MaxSplit = -1
- The maximum number of times the string is split.
bool KeepEmpty = true
- True if empty substring should be added.

std::pair<StringRef, StringRef> split(
    llvm::StringRef Separator) const

Description

Split into two substrings around the first occurrence of a separator string. If \p Separator is in the string, then the result is a pair (LHS, RHS) such that (*this == LHS + Separator + RHS) is true and RHS is maximal. If \p Separator is not in the string, then the result is a pair (LHS, RHS) where (*this == LHS) and (RHS == "").

Declared at: llvm/include/llvm/ADT/StringRef.h:768

Parameters

llvm::StringRef Separator
- The string to split on.

Returns

- The split substrings.

bool startswith(llvm::StringRef Prefix) const

Description

Check if this string starts with the given \p Prefix.

Declared at: llvm/include/llvm/ADT/StringRef.h:290

Parameters

llvm::StringRef Prefix

bool startswith_insensitive(
    llvm::StringRef Prefix) const

Description

Check if this string starts with the given \p Prefix, ignoring case.

Declared at: llvm/include/llvm/ADT/StringRef.h:297

Parameters

llvm::StringRef Prefix

std::string str() const

Description

str - Get the contents as an std::string.

Declared at: llvm/include/llvm/ADT/StringRef.h:249

static constexpr size_t strLen(const char* Str)

Declared at: llvm/include/llvm/ADT/StringRef.h:81

Parameters

const char* Str

llvm::StringRef substr(size_t Start,
                       size_t N = npos) const

Description

Return a reference to the substring from [Start, Start + N).

Declared at: llvm/include/llvm/ADT/StringRef.h:615

Parameters

size_t Start
The index of the starting character in the substring; if the index is npos or greater than the length of the string then the empty substring will be returned.
size_t N = npos
The number of characters to included in the substring. If N exceeds the number of characters remaining in the string, the string suffix (starting with \p Start) will be returned.

llvm::StringRef take_back(size_t N = 1) const

Description

Return a StringRef equal to 'this' but with only the last \p N elements remaining. If \p N is greater than the length of the string, the entire string is returned.

Declared at: llvm/include/llvm/ADT/StringRef.h:634

Parameters

size_t N = 1

llvm::StringRef take_front(size_t N = 1) const

Description

Return a StringRef equal to 'this' but with only the first \p N elements remaining. If \p N is greater than the length of the string, the entire string is returned.

Declared at: llvm/include/llvm/ADT/StringRef.h:624

Parameters

size_t N = 1

llvm::StringRef take_until(
    function_ref<bool(char)> F) const

Description

Return the longest prefix of 'this' such that no character in the prefix satisfies the given predicate.

Declared at: llvm/include/llvm/ADT/StringRef.h:650

Parameters

function_ref<bool(char)> F

llvm::StringRef take_while(
    function_ref<bool(char)> F) const

Description

Return the longest prefix of 'this' such that every character in the prefix satisfies the given predicate.

Declared at: llvm/include/llvm/ADT/StringRef.h:643

Parameters

function_ref<bool(char)> F

llvm::StringRef trim(char Char) const

Description

Return string with consecutive \p Char characters starting from the left and right removed.

Declared at: llvm/include/llvm/ADT/StringRef.h:874

Parameters

char Char

llvm::StringRef trim(
    llvm::StringRef Chars = " \t\n\v\f\r") const

Description

Return string with consecutive characters in \p Chars starting from the left and right removed.

Declared at: llvm/include/llvm/ADT/StringRef.h:881

Parameters

llvm::StringRef Chars = " \t\n\v\f\r"

std::string upper() const

Description

Convert the given ASCII string to uppercase.

Declared at: llvm/include/llvm/ADT/StringRef.h:599