ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
esphome::ProgmemStringRef Class Reference

A string that may live in flash (on ESP8266): pointer and length, with no byte-reading operations. More...

#include <string_ref.h>

Public Member Functions

constexpr ProgmemStringRef ()=default
 
constexpr ProgmemStringRef (const char *s, size_t len)
 
constexpr ProgmemStringRef (const StringRef &s)
 
constexpr const char * progmem_ptr () const
 
constexpr size_t size () const
 
constexpr bool empty () const
 
size_t write_to (char *buf, size_t buf_size) const
 Copy into buf (null terminated, truncated to fit), returns the length copied.
 
bool equals (const StringRef &other) const
 
constexpr const StringRef & ram_ref () const
 The string is in RAM here, so it can be viewed directly.
 
constexpr const char * c_str () const
 

Static Public Member Functions

template<size_t N>
static constexpr ProgmemStringRef from_lit (const char(&s)[N])
 A PROGMEM char array, with its length known at compile time.
 

Detailed Description

A string that may live in flash (on ESP8266): pointer and length, with no byte-reading operations.

progmem_ptr() is safe as a "%s" log argument; read the contents with write_to() or equals().

Definition at line 236 of file string_ref.h.

Constructor & Destructor Documentation

◆ ProgmemStringRef() [1/3]

esphome::ProgmemStringRef::ProgmemStringRef ( )
constexprdefault

◆ ProgmemStringRef() [2/3]

esphome::ProgmemStringRef::ProgmemStringRef ( const char * s,
size_t len )
inlineconstexpr

Definition at line 239 of file string_ref.h.

◆ ProgmemStringRef() [3/3]

esphome::ProgmemStringRef::ProgmemStringRef ( const StringRef & s)
inlineexplicitconstexpr

Definition at line 240 of file string_ref.h.

Member Function Documentation

◆ c_str()

const char * esphome::ProgmemStringRef::c_str ( ) const
inlineconstexpr

Definition at line 280 of file string_ref.h.

◆ empty()

bool esphome::ProgmemStringRef::empty ( ) const
inlineconstexpr

Definition at line 246 of file string_ref.h.

◆ equals()

bool esphome::ProgmemStringRef::equals ( const StringRef & other) const
inline

Definition at line 262 of file string_ref.h.

◆ from_lit()

template<size_t N>
static constexpr ProgmemStringRef esphome::ProgmemStringRef::from_lit ( const char(&) s[N])
inlinestaticconstexpr

A PROGMEM char array, with its length known at compile time.

Definition at line 242 of file string_ref.h.

◆ progmem_ptr()

const char * esphome::ProgmemStringRef::progmem_ptr ( ) const
inlineconstexpr

Definition at line 244 of file string_ref.h.

◆ ram_ref()

const StringRef & esphome::ProgmemStringRef::ram_ref ( ) const
inlineconstexpr

The string is in RAM here, so it can be viewed directly.

Definition at line 274 of file string_ref.h.

◆ size()

size_t esphome::ProgmemStringRef::size ( ) const
inlineconstexpr

Definition at line 245 of file string_ref.h.

◆ write_to()

size_t esphome::ProgmemStringRef::write_to ( char * buf,
size_t buf_size ) const
inline

Copy into buf (null terminated, truncated to fit), returns the length copied.

Definition at line 249 of file string_ref.h.


The documentation for this class was generated from the following file: