ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
esphome::ProgmemStringTable< Strs > Struct Template Reference

Compile-time string table that packs strings into a single blob with offset lookup. More...

#include <progmem.h>

Static Public Member Functions

static constexpr auto make_blob ()
 Generate packed string blob at compile time.
 
static constexpr auto make_offsets ()
 Generate offset table at compile time.
 

Static Public Attributes

static constexpr size_t COUNT = sizeof...(Strs)
 
static constexpr size_t BLOB_SIZE = (0 + ... + (Strs.size() + 1))
 
static constexpr size_t MAX_LENGTH = std::max({Strs.size()...})
 Length of the longest string, for sizing a RAM copy on ESP8266.
 
static constexpr bool INDEXED = BLOB_SIZE <= UINT8_MAX
 One-byte offsets address up to 255 bytes; a larger blob has no offset table and is scanned instead, which costs less flash than wider offsets for the rarely read tables that get this big.
 

Detailed Description

template<FixedString... Strs>
struct esphome::ProgmemStringTable< Strs >

Compile-time string table that packs strings into a single blob with offset lookup.

Blobs over 255 bytes have no offsets and are scanned, so keep those for rarely read strings. Use PROGMEM_STRING_TABLE macro to instantiate with proper flash placement on ESP8266.

Example: PROGMEM_STRING_TABLE(MyStrings, "foo", "bar", "baz"); ProgmemStr str = MyStrings::get_progmem_str(idx, MyStrings::LAST_INDEX); // For ArduinoJson const LogString *log_str = MyStrings::get_log_str(idx, MyStrings::LAST_INDEX); // For logging

Definition at line 82 of file progmem.h.

Member Function Documentation

◆ make_blob()

template<FixedString... Strs>
static constexpr auto esphome::ProgmemStringTable< Strs >::make_blob ( )
inlinestaticconstexpr

Generate packed string blob at compile time.

Definition at line 92 of file progmem.h.

◆ make_offsets()

template<FixedString... Strs>
static constexpr auto esphome::ProgmemStringTable< Strs >::make_offsets ( )
inlinestaticconstexpr

Generate offset table at compile time.

Definition at line 104 of file progmem.h.

Field Documentation

◆ BLOB_SIZE

template<FixedString... Strs>
size_t esphome::ProgmemStringTable< Strs >::BLOB_SIZE = (0 + ... + (Strs.size() + 1))
staticconstexpr

Definition at line 84 of file progmem.h.

◆ COUNT

template<FixedString... Strs>
size_t esphome::ProgmemStringTable< Strs >::COUNT = sizeof...(Strs)
staticconstexpr

Definition at line 83 of file progmem.h.

◆ INDEXED

template<FixedString... Strs>
bool esphome::ProgmemStringTable< Strs >::INDEXED = BLOB_SIZE <= UINT8_MAX
staticconstexpr

One-byte offsets address up to 255 bytes; a larger blob has no offset table and is scanned instead, which costs less flash than wider offsets for the rarely read tables that get this big.

Definition at line 89 of file progmem.h.

◆ MAX_LENGTH

template<FixedString... Strs>
size_t esphome::ProgmemStringTable< Strs >::MAX_LENGTH = std::max({Strs.size()...})
staticconstexpr

Length of the longest string, for sizing a RAM copy on ESP8266.

Definition at line 86 of file progmem.h.


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