Lines Matching defs:StringRef

1 //===--- StringRef.h - Constant String Reference Wrapper --------*- C++ -*-===//
27 class StringRef;
29 /// Helper functions for StringRef::getAsInteger.
30 bool getAsUnsignedInteger(StringRef Str, unsigned Radix,
33 bool getAsSignedInteger(StringRef Str, unsigned Radix, long long &Result);
35 /// StringRef - Represent a constant reference to a string, i.e. a character
40 /// lifetime extends past that of the StringRef. For this reason, it is not in
41 /// general safe to store a StringRef.
42 class StringRef {
69 /*implicit*/ StringRef() : Data(nullptr), Length(0) {}
72 /*implicit*/ StringRef(const char *Str)
74 assert(Str && "StringRef cannot be built from a NULL argument");
80 /*implicit*/ StringRef(const char *data, size_t length)
83 "StringRef cannot be built from a NULL argument with non-null length");
88 /*implicit*/ StringRef(const std::string &Str)
138 // copy - Allocate copy in Allocator and return StringRef to it.
139 template <typename Allocator> StringRef copy(Allocator &A) const {
142 return StringRef();
145 return StringRef(S, Length);
151 bool equals(StringRef RHS) const {
157 bool equals_lower(StringRef RHS) const {
164 int compare(StringRef RHS) const {
176 int compare_lower(StringRef RHS) const;
180 int compare_numeric(StringRef RHS) const;
200 unsigned edit_distance(StringRef Other, bool AllowReplacements = true,
232 bool startswith(StringRef Prefix) const {
238 bool startswith_lower(StringRef Prefix) const;
242 bool endswith(StringRef Suffix) const {
248 bool endswith_lower(StringRef Suffix) const;
273 size_t find(StringRef Str, size_t From = 0) const;
294 size_t rfind(StringRef Str) const;
306 size_t find_first_of(StringRef Chars, size_t From = 0) const;
316 size_t find_first_not_of(StringRef Chars, size_t From = 0) const;
328 size_t find_last_of(StringRef Chars, size_t From = npos) const;
338 size_t find_last_not_of(StringRef Chars, size_t From = npos) const;
355 size_t count(StringRef Str) const;
425 StringRef substr(size_t Start, size_t N = npos) const {
427 return StringRef(Data + Start, std::min(N, Length - Start));
430 /// Return a StringRef equal to 'this' but with the first \p N elements
433 StringRef drop_front(size_t N = 1) const {
438 /// Return a StringRef equal to 'this' but with the last \p N elements
441 StringRef drop_back(size_t N = 1) const {
458 StringRef slice(size_t Start, size_t End) const {
461 return StringRef(Data + Start, End - Start);
474 std::pair<StringRef, StringRef> split(char Separator) const {
477 return std::make_pair(*this, StringRef());
491 std::pair<StringRef, StringRef> split(StringRef Separator) const {
494 return std::make_pair(*this, StringRef());
512 void split(SmallVectorImpl<StringRef> &A,
513 StringRef Separator, int MaxSplit = -1,
530 void split(SmallVectorImpl<StringRef> &A, char Separator, int MaxSplit = -1,
543 std::pair<StringRef, StringRef> rsplit(char Separator) const {
546 return std::make_pair(*this, StringRef());
552 StringRef ltrim(char Char) const {
558 StringRef ltrim(StringRef Chars = " \t\n\v\f\r") const {
564 StringRef rtrim(char Char) const {
570 StringRef rtrim(StringRef Chars = " \t\n\v\f\r") const {
576 StringRef trim(char Char) const {
582 StringRef trim(StringRef Chars = " \t\n\v\f\r") const {
589 /// @name StringRef Comparison Operators
593 inline bool operator==(StringRef LHS, StringRef RHS) {
598 inline bool operator!=(StringRef LHS, StringRef RHS) {
602 inline bool operator<(StringRef LHS, StringRef RHS) {
606 inline bool operator<=(StringRef LHS, StringRef RHS) {
610 inline bool operator>(StringRef LHS, StringRef RHS) {
614 inline bool operator>=(StringRef LHS, StringRef RHS) {
618 inline std::string &operator+=(std::string &buffer, StringRef string) {
624 /// \brief Compute a hash_code for a StringRef.
625 hash_code hash_value(StringRef S);
629 template <> struct isPodLike<StringRef> { static const bool value = true; };