|
ESPHome 2026.2.1
|
StringRef is a reference to a string owned by something else. More...
#include <string_ref.h>
Public Types | |
| using | traits_type = std::char_traits<char> |
| using | value_type = traits_type::char_type |
| using | allocator_type = std::allocator<char> |
| using | size_type = std::allocator_traits<allocator_type>::size_type |
| using | difference_type = std::allocator_traits<allocator_type>::difference_type |
| using | const_reference = const value_type & |
| using | const_pointer = const value_type * |
| using | const_iterator = const_pointer |
| using | const_reverse_iterator = std::reverse_iterator<const_iterator> |
Public Member Functions | |
| constexpr | StringRef () |
| StringRef (const std::string &s) | |
| StringRef (const char *s) | |
| constexpr | StringRef (const char *s, size_t n) |
| template<typename CharT > | |
| constexpr | StringRef (const CharT *s, size_t n) |
| template<typename InputIt > | |
| StringRef (InputIt first, InputIt last) | |
| template<typename InputIt > | |
| StringRef (InputIt *first, InputIt *last) | |
| constexpr const_iterator | begin () const |
| constexpr const_iterator | cbegin () const |
| constexpr const_iterator | end () const |
| constexpr const_iterator | cend () const |
| const_reverse_iterator | rbegin () const |
| const_reverse_iterator | crbegin () const |
| const_reverse_iterator | rend () const |
| const_reverse_iterator | crend () const |
| constexpr const char * | c_str () const |
| constexpr size_type | size () const |
| constexpr size_type | length () const |
| constexpr bool | empty () const |
| constexpr const_reference | operator[] (size_type pos) const |
| std::string | str () const |
| const uint8_t * | byte () const |
| operator std::string () const | |
| size_type | find (const char *s, size_type pos=0) const |
| Find first occurrence of substring, returns std::string::npos if not found. | |
| size_type | find (char c, size_type pos=0) const |
| std::string | substr (size_type pos=0, size_type count=std::string::npos) const |
| Return substring as std::string. | |
Static Public Member Functions | |
| template<typename CharT , size_t N> | |
| static constexpr StringRef | from_lit (const CharT(&s)[N]) |
| static StringRef | from_maybe_nullptr (const char *s) |
StringRef is a reference to a string owned by something else.
So it behaves like simple string, but it does not own pointer. When it is default constructed, it has empty string. You can freely copy or move around this struct, but never free its pointer. str() function can be used to export the content as std::string. StringRef is adopted from https://github.com/nghttp2/nghttp2/blob/29cbf8b83ff78faf405d1086b16adc09a8772eca/src/template.h#L376
Definition at line 26 of file string_ref.h.
| using esphome::StringRef::allocator_type = std::allocator<char> |
Definition at line 30 of file string_ref.h.
Definition at line 35 of file string_ref.h.
| using esphome::StringRef::const_pointer = const value_type * |
Definition at line 34 of file string_ref.h.
| using esphome::StringRef::const_reference = const value_type & |
Definition at line 33 of file string_ref.h.
| using esphome::StringRef::const_reverse_iterator = std::reverse_iterator<const_iterator> |
Definition at line 36 of file string_ref.h.
| using esphome::StringRef::difference_type = std::allocator_traits<allocator_type>::difference_type |
Definition at line 32 of file string_ref.h.
| using esphome::StringRef::size_type = std::allocator_traits<allocator_type>::size_type |
Definition at line 31 of file string_ref.h.
| using esphome::StringRef::traits_type = std::char_traits<char> |
Definition at line 28 of file string_ref.h.
| using esphome::StringRef::value_type = traits_type::char_type |
Definition at line 29 of file string_ref.h.
|
inlineconstexpr |
Definition at line 38 of file string_ref.h.
|
inlineexplicit |
Definition at line 39 of file string_ref.h.
|
inlineexplicit |
Definition at line 40 of file string_ref.h.
|
inlineconstexpr |
Definition at line 41 of file string_ref.h.
|
inlineconstexpr |
Definition at line 43 of file string_ref.h.
|
inline |
Definition at line 45 of file string_ref.h.
|
inline |
Definition at line 48 of file string_ref.h.
|
inlineconstexpr |
Definition at line 61 of file string_ref.h.
|
inline |
Definition at line 80 of file string_ref.h.
|
inlineconstexpr |
Definition at line 73 of file string_ref.h.
|
inlineconstexpr |
Definition at line 62 of file string_ref.h.
|
inlineconstexpr |
Definition at line 65 of file string_ref.h.
|
inline |
Definition at line 68 of file string_ref.h.
|
inline |
Definition at line 71 of file string_ref.h.
|
inlineconstexpr |
Definition at line 76 of file string_ref.h.
|
inlineconstexpr |
Definition at line 64 of file string_ref.h.
Definition at line 95 of file string_ref.h.
Find first occurrence of substring, returns std::string::npos if not found.
Note: Requires the underlying string to be null-terminated.
Definition at line 86 of file string_ref.h.
|
inlinestaticconstexpr |
Definition at line 50 of file string_ref.h.
|
inlinestatic |
Definition at line 53 of file string_ref.h.
|
inlineconstexpr |
Definition at line 75 of file string_ref.h.
|
inline |
Definition at line 82 of file string_ref.h.
|
inlineconstexpr |
Definition at line 77 of file string_ref.h.
|
inline |
Definition at line 67 of file string_ref.h.
|
inline |
Definition at line 70 of file string_ref.h.
|
inlineconstexpr |
Definition at line 74 of file string_ref.h.
|
inline |
Definition at line 79 of file string_ref.h.
|
inline |
Return substring as std::string.
Definition at line 103 of file string_ref.h.