Lines Matching defs:StringRef

1 //===--- StringRef.h - Constant String Reference Wrapper --------*- C++ -*-===//
26 class StringRef;
28 /// Helper functions for StringRef::getAsInteger.
29 bool getAsUnsignedInteger(StringRef Str, unsigned Radix,
32 bool getAsSignedInteger(StringRef Str, unsigned Radix, long long &Result);
34 /// StringRef - Represent a constant reference to a string, i.e. a character
39 /// lifetime extends past that of the StringRef. For this reason, it is not in
40 /// general safe to store a StringRef.
41 class StringRef {
55 // Workaround PR5482: nearly all gcc 4.x miscompile StringRef and std::min()
73 /*implicit*/ StringRef() : Data(0), Length(0) {}
76 /*implicit*/ StringRef(const char *Str)
78 assert(Str && "StringRef cannot be built from a NULL argument");
83 /*implicit*/ StringRef(const char *data, size_t length)
86 "StringRef cannot be built from a NULL argument with non-null length");
90 /*implicit*/ StringRef(const std::string &Str)
129 bool equals(StringRef RHS) const {
135 bool equals_lower(StringRef RHS) const {
141 int compare(StringRef RHS) const {
153 int compare_lower(StringRef RHS) const;
157 int compare_numeric(StringRef RHS) const;
177 unsigned edit_distance(StringRef Other, bool AllowReplacements = true,
208 bool startswith(StringRef Prefix) const {
214 bool endswith(StringRef Suffix) const {
238 size_t find(StringRef Str, size_t From = 0) const;
259 size_t rfind(StringRef Str) const;
271 size_t find_first_of(StringRef Chars, size_t From = 0) const;
281 size_t find_first_not_of(StringRef Chars, size_t From = 0) const;
293 size_t find_last_of(StringRef Chars, size_t From = npos) const;
303 size_t find_last_not_of(StringRef Chars, size_t From = npos) const;
320 size_t count(StringRef Str) const;
386 StringRef substr(size_t Start, size_t N = npos) const {
388 return StringRef(Data + Start, min(N, Length - Start));
391 /// Return a StringRef equal to 'this' but with the first \p N elements
393 StringRef drop_front(size_t N = 1) const {
398 /// Return a StringRef equal to 'this' but with the last \p N elements
400 StringRef drop_back(size_t N = 1) const {
415 StringRef slice(size_t Start, size_t End) const {
418 return StringRef(Data + Start, End - Start);
431 std::pair<StringRef, StringRef> split(char Separator) const {
434 return std::make_pair(*this, StringRef());
448 std::pair<StringRef, StringRef> split(StringRef Separator) const {
451 return std::make_pair(*this, StringRef());
469 void split(SmallVectorImpl<StringRef> &A,
470 StringRef Separator, int MaxSplit = -1,
483 std::pair<StringRef, StringRef> rsplit(char Separator) const {
486 return std::make_pair(*this, StringRef());
492 StringRef ltrim(StringRef Chars = " \t\n\v\f\r") const {
498 StringRef rtrim(StringRef Chars = " \t\n\v\f\r") const {
504 StringRef trim(StringRef Chars = " \t\n\v\f\r") const {
511 /// @name StringRef Comparison Operators
514 inline bool operator==(StringRef LHS, StringRef RHS) {
518 inline bool operator!=(StringRef LHS, StringRef RHS) {
522 inline bool operator<(StringRef LHS, StringRef RHS) {
526 inline bool operator<=(StringRef LHS, StringRef RHS) {
530 inline bool operator>(StringRef LHS, StringRef RHS) {
534 inline bool operator>=(StringRef LHS, StringRef RHS) {
538 inline std::string &operator+=(std::string &buffer, StringRef string) {
544 /// \brief Compute a hash_code for a StringRef.
545 hash_code hash_value(StringRef S);
549 template <> struct isPodLike<StringRef> { static const bool value = true; };
552 inline StringRef toStringRef(bool B) {
553 return StringRef(B ? "true" : "false");