StringRef is a reference to a string owned by something else.
More...
#include <string_ref.h>
|
| 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 |
| |
| size_type | copy (char *dest, size_type count, size_type pos=0) const |
| | Copy characters to destination buffer (std::string::copy-like, but returns 0 instead of throwing on out-of-range)
|
| |
| std::string | str () const |
| |
| const uint8_t * | byte () const |
| |
| | operator std::string () const |
| |
| int | compare (const StringRef &other) const |
| | Compare (compatible with std::string::compare)
|
| |
| int | compare (const char *s) const |
| |
| int | compare (const std::string &s) 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.
|
| |
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.
◆ allocator_type
◆ const_iterator
◆ const_pointer
◆ const_reference
◆ const_reverse_iterator
◆ difference_type
◆ size_type
◆ traits_type
◆ value_type
◆ StringRef() [1/7]
| esphome::StringRef::StringRef |
( |
| ) |
|
|
inlineconstexpr |
◆ StringRef() [2/7]
| esphome::StringRef::StringRef |
( |
const std::string & | s | ) |
|
|
inlineexplicit |
◆ StringRef() [3/7]
| esphome::StringRef::StringRef |
( |
const char * | s | ) |
|
|
inlineexplicit |
◆ StringRef() [4/7]
| esphome::StringRef::StringRef |
( |
const char * | s, |
|
|
size_t | n ) |
|
inlineconstexpr |
◆ StringRef() [5/7]
template<typename CharT >
| esphome::StringRef::StringRef |
( |
const CharT * | s, |
|
|
size_t | n ) |
|
inlineconstexpr |
◆ StringRef() [6/7]
template<typename InputIt >
| esphome::StringRef::StringRef |
( |
InputIt | first, |
|
|
InputIt | last ) |
|
inline |
◆ StringRef() [7/7]
template<typename InputIt >
| esphome::StringRef::StringRef |
( |
InputIt * | first, |
|
|
InputIt * | last ) |
|
inline |
◆ begin()
◆ byte()
| const uint8_t * esphome::StringRef::byte |
( |
| ) |
const |
|
inline |
◆ c_str()
| const char * esphome::StringRef::c_str |
( |
| ) |
const |
|
inlineconstexpr |
◆ cbegin()
◆ cend()
◆ compare() [1/3]
| int esphome::StringRef::compare |
( |
const char * | s | ) |
const |
|
inline |
◆ compare() [2/3]
| int esphome::StringRef::compare |
( |
const std::string & | s | ) |
const |
|
inline |
◆ compare() [3/3]
| int esphome::StringRef::compare |
( |
const StringRef & | other | ) |
const |
|
inline |
Compare (compatible with std::string::compare)
Definition at line 94 of file string_ref.h.
◆ copy()
Copy characters to destination buffer (std::string::copy-like, but returns 0 instead of throwing on out-of-range)
Definition at line 80 of file string_ref.h.
◆ crbegin()
◆ crend()
◆ empty()
| bool esphome::StringRef::empty |
( |
| ) |
const |
|
inlineconstexpr |
◆ end()
◆ find() [1/2]
◆ find() [2/2]
Find first occurrence of substring, returns std::string::npos if not found.
Note: Requires the underlying string to be null-terminated.
Definition at line 109 of file string_ref.h.
◆ from_lit()
template<typename CharT , size_t N>
| static constexpr StringRef esphome::StringRef::from_lit |
( |
const CharT(&) | s[N] | ) |
|
|
inlinestaticconstexpr |
◆ from_maybe_nullptr()
| static StringRef esphome::StringRef::from_maybe_nullptr |
( |
const char * | s | ) |
|
|
inlinestatic |
◆ length()
| size_type esphome::StringRef::length |
( |
| ) |
const |
|
inlineconstexpr |
◆ operator std::string()
| esphome::StringRef::operator std::string |
( |
| ) |
const |
|
inline |
◆ operator[]()
◆ rbegin()
◆ rend()
◆ size()
◆ str()
| std::string esphome::StringRef::str |
( |
| ) |
const |
|
inline |
◆ substr()
| std::string esphome::StringRef::substr |
( |
size_type | pos = 0, |
|
|
size_type | count = std::string::npos ) const |
|
inline |
Return substring as std::string.
Definition at line 126 of file string_ref.h.
The documentation for this class was generated from the following file: