ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
esphome::ConstVector< T, true > Class Template Reference

Owning variant: a codegen table that outlives it, or a heap copy of a runtime list it owns. More...

#include <helpers.h>

Public Types

using value_type = T
 

Public Member Functions

constexpr ConstVector ()=default
 
constexpr ConstVector (const T *data, size_t size)
 
 ConstVector (const ConstVector &)=delete
 
ConstVector & operator= (const ConstVector &)=delete
 
 ~ConstVector ()
 
const T * begin () const
 
const T * end () const
 
const T * data () const
 
size_t size () const
 
bool empty () const
 
const T & operator[] (size_t index) const
 
const T & at (size_t index) const
 
void assign_static (const T *data, size_t size)
 Codegen only: call before any runtime copy; it does not free a previous owned copy (generated setup() runs before any lambda or automation can call set_options).
 
void append_copy (const T *extra, size_t count)
 Appends count elements into one new heap array this owns; the current list and extra may be codegen tables in flash.
 
void prepend_copy (const T *extra, size_t count)
 Like append_copy(), with extra placed in front of the current list.
 
void assign_copy (const T *data, size_t size)
 Copies the list into a heap array this owns, freeing a previous owned copy.
 

Protected Member Functions

void release_ ()
 
void merge_copy_ (const T *first, size_t first_count, const T *second, size_t second_count)
 

Static Protected Member Functions

static void copy_items (const T *src, size_t count, T *dst)
 

Protected Attributes

const T * data_ {nullptr}
 
size_t size_ {0}
 

Static Protected Attributes

static constexpr size_t OWNED_BIT = size_t{1} << (sizeof(size_t) * 8 - 1)
 

Detailed Description

template<typename T>
class esphome::ConstVector< T, true >

Owning variant: a codegen table that outlives it, or a heap copy of a runtime list it owns.

Ownership is the top bit of the size; it is not copyable, so a copy can never outlive the owner. Elements must be whole words: on ESP8266, iterating or indexing a codegen table reads them straight from flash.

Definition at line 154 of file helpers.h.

Member Typedef Documentation

◆ value_type

template<typename T >
using esphome::ConstVector< T, true >::value_type = T

Definition at line 159 of file helpers.h.

Constructor & Destructor Documentation

◆ ConstVector() [1/3]

template<typename T >
esphome::ConstVector< T, true >::ConstVector ( )
constexprdefault

◆ ConstVector() [2/3]

template<typename T >
esphome::ConstVector< T, true >::ConstVector ( const T * data,
size_t size )
inlineconstexpr

Definition at line 162 of file helpers.h.

◆ ConstVector() [3/3]

template<typename T >
esphome::ConstVector< T, true >::ConstVector ( const ConstVector< T, true > & )
delete

◆ ~ConstVector()

template<typename T >
esphome::ConstVector< T, true >::~ConstVector ( )
inline

Definition at line 165 of file helpers.h.

Member Function Documentation

◆ append_copy()

template<typename T >
void esphome::ConstVector< T, true >::append_copy ( const T * extra,
size_t count )
inline

Appends count elements into one new heap array this owns; the current list and extra may be codegen tables in flash.

Definition at line 183 of file helpers.h.

◆ assign_copy()

template<typename T >
void esphome::ConstVector< T, true >::assign_copy ( const T * data,
size_t size )
inline

Copies the list into a heap array this owns, freeing a previous owned copy.

Definition at line 187 of file helpers.h.

◆ assign_static()

template<typename T >
void esphome::ConstVector< T, true >::assign_static ( const T * data,
size_t size )
inline

Codegen only: call before any runtime copy; it does not free a previous owned copy (generated setup() runs before any lambda or automation can call set_options).

Definition at line 177 of file helpers.h.

◆ at()

template<typename T >
const T & esphome::ConstVector< T, true >::at ( size_t index) const
inline

Definition at line 173 of file helpers.h.

◆ begin()

template<typename T >
const T * esphome::ConstVector< T, true >::begin ( ) const
inline

Definition at line 167 of file helpers.h.

◆ copy_items()

template<typename T >
static void esphome::ConstVector< T, true >::copy_items ( const T * src,
size_t count,
T * dst )
inlinestaticprotected

Definition at line 205 of file helpers.h.

◆ data()

template<typename T >
const T * esphome::ConstVector< T, true >::data ( ) const
inline

Definition at line 169 of file helpers.h.

◆ empty()

template<typename T >
bool esphome::ConstVector< T, true >::empty ( ) const
inline

Definition at line 171 of file helpers.h.

◆ end()

template<typename T >
const T * esphome::ConstVector< T, true >::end ( ) const
inline

Definition at line 168 of file helpers.h.

◆ merge_copy_()

template<typename T >
void esphome::ConstVector< T, true >::merge_copy_ ( const T * first,
size_t first_count,
const T * second,
size_t second_count )
inlineprotected

Definition at line 196 of file helpers.h.

◆ operator=()

template<typename T >
ConstVector & esphome::ConstVector< T, true >::operator= ( const ConstVector< T, true > & )
delete

◆ operator[]()

template<typename T >
const T & esphome::ConstVector< T, true >::operator[] ( size_t index) const
inline

Definition at line 172 of file helpers.h.

◆ prepend_copy()

template<typename T >
void esphome::ConstVector< T, true >::prepend_copy ( const T * extra,
size_t count )
inline

Like append_copy(), with extra placed in front of the current list.

Definition at line 185 of file helpers.h.

◆ release_()

template<typename T >
void esphome::ConstVector< T, true >::release_ ( )
inlineprotected

Definition at line 192 of file helpers.h.

◆ size()

template<typename T >
size_t esphome::ConstVector< T, true >::size ( ) const
inline

Definition at line 170 of file helpers.h.

Field Documentation

◆ data_

template<typename T >
const T* esphome::ConstVector< T, true >::data_ {nullptr}
protected

Definition at line 215 of file helpers.h.

◆ OWNED_BIT

template<typename T >
size_t esphome::ConstVector< T, true >::OWNED_BIT = size_t{1} << (sizeof(size_t) * 8 - 1)
staticconstexprprotected

Definition at line 190 of file helpers.h.

◆ size_

template<typename T >
size_t esphome::ConstVector< T, true >::size_ {0}
protected

Definition at line 216 of file helpers.h.


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