Lines Matching defs:StringRef

1 //===--- StringRef.h - Constant String Reference Wrapper --------*- C++ -*-===//
25 class StringRef;
27 /// Helper functions for StringRef::getAsInteger.
28 bool getAsUnsignedInteger(StringRef Str, unsigned Radix,
31 bool getAsSignedInteger(StringRef Str, unsigned Radix, long long &Result);
33 /// StringRef - Represent a constant reference to a string, i.e. a character
38 /// lifetime extends past that of the StringRef. For this reason, it is not in
39 /// general safe to store a StringRef.
40 class StringRef {
54 // Workaround PR5482: nearly all gcc 4.x miscompile StringRef and std::min()
72 /*implicit*/ StringRef() : Data(nullptr), Length(0) {}
75 /*implicit*/ StringRef(const char *Str)
77 assert(Str && "StringRef cannot be built from a NULL argument");
82 /*implicit*/ StringRef(const char *data, size_t length)
85 "StringRef cannot be built from a NULL argument with non-null length");
89 /*implicit*/ StringRef(const std::string &Str)
126 // copy - Allocate copy in Allocator and return StringRef to it.
127 template <typename Allocator> StringRef copy(Allocator &A) {
130 return StringRef(S, Length);
135 bool equals(StringRef RHS) const {
141 bool equals_lower(StringRef RHS) const {
147 int compare(StringRef RHS) const {
159 int compare_lower(StringRef RHS) const;
163 int compare_numeric(StringRef RHS) const;
183 unsigned edit_distance(StringRef Other, bool AllowReplacements = true,
214 bool startswith(StringRef Prefix) const {
220 bool startswith_lower(StringRef Prefix) const;
223 bool endswith(StringRef Suffix) const {
229 bool endswith_lower(StringRef Suffix) const;
250 size_t find(StringRef Str, size_t From = 0) const;
271 size_t rfind(StringRef Str) const;
283 size_t find_first_of(StringRef Chars, size_t From = 0) const;
293 size_t find_first_not_of(StringRef Chars, size_t From = 0) const;
305 size_t find_last_of(StringRef Chars, size_t From = npos) const;
315 size_t find_last_not_of(StringRef Chars, size_t From = npos) const;
332 size_t count(StringRef Str) const;
398 StringRef substr(size_t Start, size_t N = npos) const {
400 return StringRef(Data + Start, min(N, Length - Start));
403 /// Return a StringRef equal to 'this' but with the first \p N elements
405 StringRef drop_front(size_t N = 1) const {
410 /// Return a StringRef equal to 'this' but with the last \p N elements
412 StringRef drop_back(size_t N = 1) const {
427 StringRef slice(size_t Start, size_t End) const {
430 return StringRef(Data + Start, End - Start);
443 std::pair<StringRef, StringRef> split(char Separator) const {
446 return std::make_pair(*this, StringRef());
460 std::pair<StringRef, StringRef> split(StringRef Separator) const {
463 return std::make_pair(*this, StringRef());
481 void split(SmallVectorImpl<StringRef> &A,
482 StringRef Separator, int MaxSplit = -1,
495 std::pair<StringRef, StringRef> rsplit(char Separator) const {
498 return std::make_pair(*this, StringRef());
504 StringRef ltrim(StringRef Chars = " \t\n\v\f\r") const {
510 StringRef rtrim(StringRef Chars = " \t\n\v\f\r") const {
516 StringRef trim(StringRef Chars = " \t\n\v\f\r") const {
523 /// @name StringRef Comparison Operators
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 bool operator<=(StringRef LHS, StringRef RHS) {
542 inline bool operator>(StringRef LHS, StringRef RHS) {
546 inline bool operator>=(StringRef LHS, StringRef RHS) {
550 inline std::string &operator+=(std::string &buffer, StringRef string) {
556 /// \brief Compute a hash_code for a StringRef.
557 hash_code hash_value(StringRef S);
561 template <> struct isPodLike<StringRef> { static const bool value = true; };