ESPHome
2024.12.0
|
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 bool | empty () const |
constexpr const_reference | operator[] (size_type pos) const |
std::string | str () const |
const uint8_t * | byte () const |
operator std::string () const | |
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 21 of file string_ref.h.
using esphome::StringRef::allocator_type = std::allocator<char> |
Definition at line 25 of file string_ref.h.
Definition at line 30 of file string_ref.h.
using esphome::StringRef::const_pointer = const value_type * |
Definition at line 29 of file string_ref.h.
using esphome::StringRef::const_reference = const value_type & |
Definition at line 28 of file string_ref.h.
using esphome::StringRef::const_reverse_iterator = std::reverse_iterator<const_iterator> |
Definition at line 31 of file string_ref.h.
using esphome::StringRef::difference_type = std::allocator_traits<allocator_type>::difference_type |
Definition at line 27 of file string_ref.h.
using esphome::StringRef::size_type = std::allocator_traits<allocator_type>::size_type |
Definition at line 26 of file string_ref.h.
using esphome::StringRef::traits_type = std::char_traits<char> |
Definition at line 23 of file string_ref.h.
using esphome::StringRef::value_type = traits_type::char_type |
Definition at line 24 of file string_ref.h.
|
inline |
Definition at line 33 of file string_ref.h.
|
inlineexplicit |
Definition at line 34 of file string_ref.h.
|
inlineexplicit |
Definition at line 35 of file string_ref.h.
|
inline |
Definition at line 36 of file string_ref.h.
|
inline |
Definition at line 38 of file string_ref.h.
|
inline |
Definition at line 40 of file string_ref.h.
|
inline |
Definition at line 43 of file string_ref.h.
|
inline |
Definition at line 56 of file string_ref.h.
|
inline |
Definition at line 74 of file string_ref.h.
|
inline |
Definition at line 68 of file string_ref.h.
|
inline |
Definition at line 57 of file string_ref.h.
|
inline |
Definition at line 60 of file string_ref.h.
|
inline |
Definition at line 63 of file string_ref.h.
|
inline |
Definition at line 66 of file string_ref.h.
|
inline |
Definition at line 70 of file string_ref.h.
|
inline |
Definition at line 59 of file string_ref.h.
|
inlinestatic |
Definition at line 45 of file string_ref.h.
|
inlinestatic |
Definition at line 48 of file string_ref.h.
|
inline |
Definition at line 76 of file string_ref.h.
|
inline |
Definition at line 71 of file string_ref.h.
|
inline |
Definition at line 62 of file string_ref.h.
|
inline |
Definition at line 65 of file string_ref.h.
|
inline |
Definition at line 69 of file string_ref.h.
|
inline |
Definition at line 73 of file string_ref.h.