17 #ifndef ABSL_HAVE_STD_STRING_VIEW 29 void WritePadding(std::ostream&
o,
size_t pad) {
31 memset(fill_buf, o.fill(),
sizeof(fill_buf));
33 size_t n = std::min(pad,
sizeof(fill_buf));
45 explicit LookupTable(string_view wanted) {
46 for (
char c : wanted) {
50 bool operator[](
char c)
const {
return table_[Index(c)]; }
53 static unsigned char Index(
char c) {
return static_cast<unsigned char>(c); }
60 std::ostream::sentry sentry(o);
64 if (static_cast<size_t>(o.width()) > piece.
size()) {
65 size_t pad = o.width() - piece.
size();
66 if ((o.flags() & o.adjustfield) == o.left) {
72 if (lpad) WritePadding(o, lpad);
74 if (rpad) WritePadding(o, rpad);
86 const char* start =
ptr_ + pos;
87 std::copy(start, start + rlen, buf);
94 if (empty() || pos > length_) {
95 if (empty() && pos == 0 && s.empty())
return 0;
100 return result ? result -
ptr_ : npos;
104 if (empty() || pos >= length_) {
108 static_cast<const char*
>(memchr(
ptr_ + pos, c, length_ - pos));
109 return result !=
nullptr ? result -
ptr_ : npos;
114 if (length_ < s.length_)
return npos;
115 if (s.empty())
return std::min(length_, pos);
116 const char* last =
ptr_ + std::min(length_ - s.length_, pos) + s.length_;
117 const char* result = std::find_end(
ptr_, last, s.ptr_, s.ptr_ + s.length_);
118 return result != last ? result -
ptr_ : npos;
125 if (empty())
return npos;
126 for (
size_type i = std::min(pos, length_ - 1);; --
i) {
138 if (empty() || s.empty()) {
142 if (s.length_ == 1)
return find_first_of(s.ptr_[0], pos);
155 if (empty())
return npos;
157 if (s.length_ == 1)
return find_first_not_of(s.ptr_[0], pos);
170 if (empty())
return npos;
171 for (; pos < length_; ++pos) {
172 if (
ptr_[pos] != c) {
181 if (empty() || s.empty())
return npos;
183 if (s.length_ == 1)
return find_last_of(s.ptr_[0], pos);
185 for (
size_type i = std::min(pos, length_ - 1);; --
i) {
197 if (empty())
return npos;
199 if (s.empty())
return i;
201 if (s.length_ == 1)
return find_last_not_of(s.ptr_[0], pos);
215 if (empty())
return npos;
233 #define ABSL_STRING_VIEW_SELECTANY __declspec(selectany) 235 #define ABSL_STRING_VIEW_SELECTANY 245 #endif // ABSL_HAVE_STD_STRING_VIEW
static constexpr size_type kMaxSize
size_type find(string_view s, size_type pos=0) const noexcept
static constexpr size_type npos
#define ABSL_STRING_VIEW_SELECTANY
std::ostream & operator<<(std::ostream &os, absl::LogSeverity s)
constexpr size_type size() const noexcept
size_type rfind(string_view s, size_type pos=npos) const noexcept
size_type find_last_of(string_view s, size_type pos=npos) const noexcept
size_type find_last_not_of(string_view s, size_type pos=npos) const noexcept
size_type find_first_not_of(string_view s, size_type pos=0) const noexcept
constexpr const_pointer data() const noexcept
size_type find_first_of(string_view s, size_type pos=0) const noexcept
const char * memmatch(const char *phaystack, size_t haylen, const char *pneedle, size_t neelen)
size_type copy(char *buf, size_type n, size_type pos=0) const