Go to the documentation of this file.
19 #ifndef GRPCPP_IMPL_CODEGEN_STRING_REF_H
20 #define GRPCPP_IMPL_CODEGEN_STRING_REF_H
53 : data_(other.data_), length_(other.length_) {}
56 length_ = rhs.length_;
60 string_ref(
const char* s) : data_(s), length_(strlen(s)) {}
61 string_ref(
const char* s,
size_t l) : data_(s), length_(l) {}
83 size_t size()
const {
return length_; }
84 size_t length()
const {
return length_; }
86 bool empty()
const {
return length_ == 0; }
89 const char*
data()
const {
return data_; }
93 size_t min_size = length_ < x.length_ ? length_ : x.length_;
94 int r = memcmp(data_, x.data_, min_size);
97 if (length_ < x.length_)
return -1;
98 if (length_ > x.length_)
return 1;
103 return length_ >= x.length_ && (memcmp(data_, x.data_, x.length_) == 0);
107 return length_ >= x.length_ &&
108 (memcmp(data_ + (length_ - x.length_), x.data_, x.length_) == 0);
122 if (pos > length_) pos = length_;
123 if (n > (length_ - pos)) n = length_ - pos;
141 return out <<
grpc::string(
string.begin(),
string.end());
146 #endif // GRPCPP_IMPL_CODEGEN_STRING_REF_H
bool ends_with(string_ref x) const
Definition: string_ref.h:106
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:61
bool operator==(string_ref x, string_ref y)
Comparison operators.
Definition: string_ref.h:133
const typedef char * const_iterator
types
Definition: string_ref.h:44
bool empty() const
Definition: string_ref.h:86
This header provides an object that reads bytes directly from a grpc::ByteBuffer, via the ZeroCopyInp...
Definition: alarm.h:24
bool starts_with(string_ref x) const
Definition: string_ref.h:102
string_ref & operator=(const string_ref &rhs)
Definition: string_ref.h:54
int compare(string_ref x) const
string operations
Definition: string_ref.h:92
size_t find(string_ref s) const
Definition: string_ref.h:111
string_ref(const grpc::string &s)
Definition: string_ref.h:62
const_iterator cend() const
Definition: string_ref.h:68
bool operator>=(string_ref x, string_ref y)
Definition: string_ref.h:138
bool operator<(string_ref x, string_ref y)
Definition: string_ref.h:135
string_ref(const string_ref &other)
Definition: string_ref.h:52
bool operator<=(string_ref x, string_ref y)
Definition: string_ref.h:136
string_ref(const char *s)
Definition: string_ref.h:60
const_reverse_iterator rbegin() const
Definition: string_ref.h:69
string_ref substr(size_t pos, size_t n=npos) const
Definition: string_ref.h:121
bool operator>(string_ref x, string_ref y)
Definition: string_ref.h:137
const_iterator end() const
Definition: string_ref.h:66
size_t length() const
Definition: string_ref.h:84
const_iterator begin() const
iterators
Definition: string_ref.h:65
string_ref()
construct/copy.
Definition: string_ref.h:51
bool operator!=(string_ref x, string_ref y)
Definition: string_ref.h:134
const char * data() const
element access
Definition: string_ref.h:89
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: string_ref.h:45
const_iterator cbegin() const
Definition: string_ref.h:67
std::string string
Definition: config.h:35
const_reverse_iterator crbegin() const
Definition: string_ref.h:75
const_reverse_iterator rend() const
Definition: string_ref.h:72
size_t size() const
capacity
Definition: string_ref.h:83
size_t find(char c) const
Definition: string_ref.h:116
const_reverse_iterator crend() const
Definition: string_ref.h:78
std::ostream & operator<<(std::ostream &out, const string_ref &string)
Definition: string_ref.h:140
const static size_t npos
constants
Definition: string_ref.h:48
size_t max_size() const
Definition: string_ref.h:85