Go to the documentation of this file.
19 #ifndef GRPCPP_SUPPORT_STRING_REF_H
20 #define GRPCPP_SUPPORT_STRING_REF_H
53 : data_(other.data_), length_(other.length_) {}
57 length_ = rhs.length_;
62 string_ref(
const char* s) : data_(s), length_(strlen(s)) {}
63 string_ref(
const char* s,
size_t l) : data_(s), length_(l) {}
86 size_t size()
const {
return length_; }
87 size_t length()
const {
return length_; }
89 bool empty()
const {
return length_ == 0; }
92 const char*
data()
const {
return data_; }
96 size_t min_size = length_ < x.length_ ? length_ : x.length_;
97 int r = memcmp(data_, x.data_, min_size);
100 if (length_ < x.length_)
return -1;
101 if (length_ > x.length_)
return 1;
106 return length_ >= x.length_ && (memcmp(data_, x.data_, x.length_) == 0);
110 return length_ >= x.length_ &&
111 (memcmp(data_ + (length_ - x.length_), x.data_, x.length_) == 0);
125 if (pos > length_) pos = length_;
126 if (n > (length_ - pos)) n = length_ - pos;
144 return out << std::string(
string.begin(),
string.end());
149 #endif // GRPCPP_SUPPORT_STRING_REF_H
bool ends_with(string_ref x) const
Definition: string_ref.h:109
This class is a non owning reference to a string.
Definition: string_ref.h:41
string_ref(const char *s, size_t l)
Definition: string_ref.h:63
bool operator==(string_ref x, string_ref y)
Comparison operators.
Definition: string_ref.h:136
const typedef char * const_iterator
types
Definition: string_ref.h:44
bool empty() const
Definition: string_ref.h:89
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm.h:33
bool starts_with(string_ref x) const
Definition: string_ref.h:105
string_ref & operator=(const string_ref &rhs)
Definition: string_ref.h:55
int compare(string_ref x) const
string operations
Definition: string_ref.h:95
size_t find(string_ref s) const
Definition: string_ref.h:114
const_iterator cend() const
Definition: string_ref.h:71
bool operator>=(string_ref x, string_ref y)
Definition: string_ref.h:141
bool operator<(string_ref x, string_ref y)
Definition: string_ref.h:138
string_ref(const string_ref &other)
Definition: string_ref.h:52
bool operator<=(string_ref x, string_ref y)
Definition: string_ref.h:139
string_ref(const char *s)
Definition: string_ref.h:62
const_reverse_iterator rbegin() const
Definition: string_ref.h:72
string_ref substr(size_t pos, size_t n=npos) const
Definition: string_ref.h:124
bool operator>(string_ref x, string_ref y)
Definition: string_ref.h:140
const_iterator end() const
Definition: string_ref.h:69
size_t length() const
Definition: string_ref.h:87
const_iterator begin() const
iterators
Definition: string_ref.h:68
string_ref()
construct/copy.
Definition: string_ref.h:51
bool operator!=(string_ref x, string_ref y)
Definition: string_ref.h:137
const char * data() const
element access
Definition: string_ref.h:92
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: string_ref.h:45
const_iterator cbegin() const
Definition: string_ref.h:70
string_ref(const std::string &s)
Definition: string_ref.h:65
const_reverse_iterator crbegin() const
Definition: string_ref.h:78
const_reverse_iterator rend() const
Definition: string_ref.h:75
size_t size() const
capacity
Definition: string_ref.h:86
size_t find(char c) const
Definition: string_ref.h:119
const_reverse_iterator crend() const
Definition: string_ref.h:81
std::ostream & operator<<(std::ostream &out, const string_ref &string)
Definition: string_ref.h:143
const static size_t npos
constants
Definition: string_ref.h:48
size_t max_size() const
Definition: string_ref.h:88