ESPHome 2026.3.0-dev
Loading...
Searching...
No Matches
esphome::wifi::CompactString Class Reference

20-byte string: 18 chars inline + null, heap for longer. More...

#include <wifi_component.h>

Public Member Functions

 CompactString ()
 
 CompactString (const char *str, size_t len)
 
 CompactString (const CompactString &other)
 
 CompactString (CompactString &&other) noexcept
 
CompactStringoperator= (const CompactString &other)
 
CompactStringoperator= (CompactString &&other) noexcept
 
 ~CompactString ()
 
const char * data () const
 
const char * c_str () const
 
size_t size () const
 
bool empty () const
 
StringRef ref () const
 Return a StringRef view of this string (zero-copy)
 
bool operator== (const CompactString &other) const
 
bool operator!= (const CompactString &other) const
 
bool operator== (const StringRef &other) const
 
bool operator!= (const StringRef &other) const
 
bool operator== (const char *other) const
 
bool operator!= (const char *other) const
 

Static Public Attributes

static constexpr uint8_t MAX_LENGTH = 127
 
static constexpr uint8_t INLINE_CAPACITY = 18
 

Protected Member Functions

char * get_heap_ptr_ () const
 
void set_heap_ptr_ (char *ptr)
 

Protected Attributes

char storage_ [INLINE_CAPACITY+1]
 
uint8_t length_: 7
 
uint8_t is_heap_: 1
 

Detailed Description

20-byte string: 18 chars inline + null, heap for longer.

Always null-terminated. Used internally for WiFi SSID/password storage to reduce heap fragmentation.

Definition at line 177 of file wifi_component.h.

Constructor & Destructor Documentation

◆ CompactString() [1/4]

esphome::wifi::CompactString::CompactString ( )
inline

Definition at line 182 of file wifi_component.h.

◆ CompactString() [2/4]

esphome::wifi::CompactString::CompactString ( const char * str,
size_t len )

Definition at line 52 of file wifi_component.cpp.

◆ CompactString() [3/4]

esphome::wifi::CompactString::CompactString ( const CompactString & other)

Definition at line 75 of file wifi_component.cpp.

◆ CompactString() [4/4]

esphome::wifi::CompactString::CompactString ( CompactString && other)
noexcept

Definition at line 85 of file wifi_component.cpp.

◆ ~CompactString()

esphome::wifi::CompactString::~CompactString ( )

Definition at line 101 of file wifi_component.cpp.

Member Function Documentation

◆ c_str()

const char * esphome::wifi::CompactString::c_str ( ) const
inline

Definition at line 191 of file wifi_component.h.

◆ data()

const char * esphome::wifi::CompactString::data ( ) const
inline

Definition at line 190 of file wifi_component.h.

◆ empty()

bool esphome::wifi::CompactString::empty ( ) const
inline

Definition at line 193 of file wifi_component.h.

◆ get_heap_ptr_()

char * esphome::wifi::CompactString::get_heap_ptr_ ( ) const
inlineprotected

Definition at line 206 of file wifi_component.h.

◆ operator!=() [1/3]

bool esphome::wifi::CompactString::operator!= ( const char * other) const
inline

Definition at line 203 of file wifi_component.h.

◆ operator!=() [2/3]

bool esphome::wifi::CompactString::operator!= ( const CompactString & other) const
inline

Definition at line 199 of file wifi_component.h.

◆ operator!=() [3/3]

bool esphome::wifi::CompactString::operator!= ( const StringRef & other) const
inline

Definition at line 201 of file wifi_component.h.

◆ operator=() [1/2]

CompactString & esphome::wifi::CompactString::operator= ( CompactString && other)
noexcept

Definition at line 93 of file wifi_component.cpp.

◆ operator=() [2/2]

CompactString & esphome::wifi::CompactString::operator= ( const CompactString & other)

Definition at line 77 of file wifi_component.cpp.

◆ operator==() [1/3]

bool esphome::wifi::CompactString::operator== ( const char * other) const
inline

Definition at line 202 of file wifi_component.h.

◆ operator==() [2/3]

bool esphome::wifi::CompactString::operator== ( const CompactString & other) const

Definition at line 107 of file wifi_component.cpp.

◆ operator==() [3/3]

bool esphome::wifi::CompactString::operator== ( const StringRef & other) const

Definition at line 110 of file wifi_component.cpp.

◆ ref()

StringRef esphome::wifi::CompactString::ref ( ) const
inline

Return a StringRef view of this string (zero-copy)

Definition at line 196 of file wifi_component.h.

◆ set_heap_ptr_()

void esphome::wifi::CompactString::set_heap_ptr_ ( char * ptr)
inlineprotected

Definition at line 211 of file wifi_component.h.

◆ size()

size_t esphome::wifi::CompactString::size ( ) const
inline

Definition at line 192 of file wifi_component.h.

Field Documentation

◆ INLINE_CAPACITY

uint8_t esphome::wifi::CompactString::INLINE_CAPACITY = 18
staticconstexpr

Definition at line 180 of file wifi_component.h.

◆ is_heap_

uint8_t esphome::wifi::CompactString::is_heap_
protected

Definition at line 217 of file wifi_component.h.

◆ length_

uint8_t esphome::wifi::CompactString::length_
protected

Definition at line 216 of file wifi_component.h.

◆ MAX_LENGTH

uint8_t esphome::wifi::CompactString::MAX_LENGTH = 127
staticconstexpr

Definition at line 179 of file wifi_component.h.

◆ storage_

char esphome::wifi::CompactString::storage_[INLINE_CAPACITY+1]
protected

Definition at line 215 of file wifi_component.h.


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