Go to the documentation of this file.
27 #ifndef ABSL_STRINGS_STRING_VIEW_H_
28 #define ABSL_STRINGS_STRING_VIEW_H_
39 #include "absl/base/attributes.h"
40 #include "absl/base/config.h"
41 #include "absl/base/internal/throw_delegate.h"
42 #include "absl/base/macros.h"
43 #include "absl/base/optimization.h"
44 #include "absl/base/port.h"
46 #ifdef ABSL_USES_STD_STRING_VIEW
48 #include <string_view>
56 #else // ABSL_USES_STD_STRING_VIEW
58 #if ABSL_HAVE_BUILTIN(__builtin_memcmp) || \
59 (defined(__GNUC__) && !defined(__clang__)) || \
60 (defined(_MSC_VER) && _MSC_VER >= 1928)
61 #define ABSL_INTERNAL_STRING_VIEW_MEMCMP __builtin_memcmp
62 #else // ABSL_HAVE_BUILTIN(__builtin_memcmp)
63 #define ABSL_INTERNAL_STRING_VIEW_MEMCMP memcmp
64 #endif // ABSL_HAVE_BUILTIN(__builtin_memcmp)
66 #if defined(__cplusplus) && __cplusplus >= 201402L
67 #define ABSL_INTERNAL_STRING_VIEW_CXX14_CONSTEXPR constexpr
69 #define ABSL_INTERNAL_STRING_VIEW_CXX14_CONSTEXPR
189 template <
typename Allocator>
191 const std::basic_string<
char, std::char_traits<char>, Allocator>&
str
311 "absl::string_view::at"),
371 template <
typename A>
372 explicit operator std::basic_string<char, traits_type, A>()
const {
373 if (!
data())
return {};
374 return std::basic_string<char, traits_type, A>(
data(),
size());
402 "absl::string_view::substr"),
614 #if defined(_MSC_VER) && _MSC_VER >= 1910 && !defined(__clang__)
617 while (*
str !=
'\0') ++
str;
619 #elif ABSL_HAVE_BUILTIN(__builtin_strlen) || \
620 (defined(__GNUC__) && !defined(__clang__))
625 return __builtin_strlen(
str);
627 return str ? strlen(
str) : 0;
632 return length_a < length_b ? length_a : length_b;
636 int compare_result) {
637 return compare_result == 0 ?
static_cast<int>(length_a > length_b) -
638 static_cast<int>(length_a < length_b)
639 : (compare_result < 0 ? -1 : 1);
650 return x.size() ==
y.size() &&
660 return x.compare(
y) < 0;
681 #undef ABSL_INTERNAL_STRING_VIEW_CXX14_CONSTEXPR
682 #undef ABSL_INTERNAL_STRING_VIEW_MEMCMP
684 #endif // ABSL_USES_STD_STRING_VIEW
696 return s.substr(
pos,
n);
711 #endif // ABSL_STRINGS_STRING_VIEW_H_
#define ABSL_PREDICT_FALSE(x)
size_type rfind(const char *s, size_type pos, size_type count) const
std::reverse_iterator< const_iterator > const_reverse_iterator
#define ABSL_INTERNAL_STRING_VIEW_MEMCMP
ABSL_NAMESPACE_BEGIN string_view ClippedSubstr(string_view s, size_t pos, size_t n=string_view::npos)
ABSL_INTERNAL_STRING_VIEW_CXX14_CONSTEXPR void remove_suffix(size_type n)
string_view(const std::basic_string< char, std::char_traits< char >, Allocator > &str ABSL_ATTRIBUTE_LIFETIME_BOUND) noexcept
size_type find_last_of(const char *s, size_type pos, size_type count) const
constexpr string_view(const char *str)
ABSL_NAMESPACE_BEGIN std::ostream & operator<<(std::ostream &os, absl::LogSeverity s)
size_type find(string_view s, size_type pos=0) const noexcept
static int copy(grpc_slice_buffer *input, grpc_slice_buffer *output)
constexpr int compare(size_type pos1, size_type count1, string_view v, size_type pos2, size_type count2) const
size_type find_last_not_of(const char *s, size_type pos=npos) const
constexpr const_reference at(size_type i) const
static constexpr size_type StrlenInternal(const char *str)
constexpr const_reference back() const
#define ABSL_NAMESPACE_END
size_type find_first_not_of(const char *s, size_type pos=0) const
bool operator>(const absl::InlinedVector< T, N, A > &a, const absl::InlinedVector< T, N, A > &b)
static constexpr size_type CheckLengthInternal(size_type len)
#define ABSL_HARDENING_ASSERT(expr)
size_type find_first_of(string_view s, size_type pos=0) const noexcept
std::char_traits< char > traits_type
constexpr string_view(const char *data, size_type len)
static constexpr size_type kMaxSize
constexpr string_view NullSafeStringView(const char *p)
size_type find_last_of(char c, size_type pos=npos) const noexcept
constexpr size_type length() const noexcept
size_type find_first_of(const char *s, size_type pos=0) const
void ThrowStdOutOfRange(const std::string &what_arg)
constexpr const_reference front() const
const_reverse_iterator crbegin() const noexcept
#define ABSL_NAMESPACE_BEGIN
size_type find_last_of(const char *s, size_type pos=npos) const
const_reverse_iterator reverse_iterator
constexpr size_type size() const noexcept
constexpr int compare(size_type pos1, size_type count1, string_view v) const
const_reverse_iterator crend() const noexcept
constexpr const_iterator begin() const noexcept
string_view(const char *data, size_type len, SkipCheckLengthTag) noexcept
static constexpr int CompareImpl(size_type length_a, size_type length_b, int compare_result)
bool operator==(const absl::InlinedVector< T, N, A > &a, const absl::InlinedVector< T, N, A > &b)
constexpr int compare(size_type pos1, size_type count1, const char *s, size_type count2) const
constexpr int compare(const char *s) const
size_type rfind(const char *s, size_type pos=npos) const
bool operator!=(const absl::InlinedVector< T, N, A > &a, const absl::InlinedVector< T, N, A > &b)
#define ABSL_PREDICT_TRUE(x)
constexpr const_iterator cend() const noexcept
size_type copy(char *buf, size_type n, size_type pos=0) const
const_reverse_iterator rend() const noexcept
const char * const_iterator
size_type find_first_not_of(string_view s, size_type pos=0) const noexcept
bool operator>=(const absl::InlinedVector< T, N, A > &a, const absl::InlinedVector< T, N, A > &b)
ABSL_INTERNAL_STRING_VIEW_CXX14_CONSTEXPR void remove_prefix(size_type n)
size_type rfind(string_view s, size_type pos=npos) const noexcept
bool operator<=(const absl::InlinedVector< T, N, A > &a, const absl::InlinedVector< T, N, A > &b)
const char * const_pointer
#define ABSL_INTERNAL_STRING_VIEW_CXX14_CONSTEXPR
constexpr int compare(string_view x) const noexcept
size_type find_last_not_of(const char *s, size_type pos, size_type count) const
absl::string_view string_view
const char & const_reference
size_type find(const char *s, size_type pos=0) const
size_type find_first_of(const char *s, size_type pos, size_type count) const
size_type find_last_of(string_view s, size_type pos=npos) const noexcept
constexpr int compare(size_type pos1, size_type count1, const char *s) const
constexpr size_type max_size() const noexcept
ABSL_INTERNAL_STRING_VIEW_CXX14_CONSTEXPR void swap(string_view &s) noexcept
constexpr const_iterator cbegin() const noexcept
constexpr bool empty() const noexcept
std::ptrdiff_t difference_type
constexpr const_reference operator[](size_type i) const
static constexpr size_type npos
const_reverse_iterator rbegin() const noexcept
#define ABSL_ATTRIBUTE_LIFETIME_BOUND
bool operator<(const absl::InlinedVector< T, N, A > &a, const absl::InlinedVector< T, N, A > &b)
static constexpr size_t Min(size_type length_a, size_type length_b)
constexpr string_view() noexcept
constexpr const_pointer data() const noexcept
constexpr const_iterator end() const noexcept
size_type find_last_not_of(string_view s, size_type pos=npos) const noexcept
constexpr string_view substr(size_type pos=0, size_type n=npos) const
grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:21