|
ESPHome 2026.3.0-dev
|
Buffer for JSON serialization that uses stack allocation for small payloads. More...
#include <json_util.h>
Public Member Functions | |
| SerializationBuffer (size_t size) | |
| Construct with known size (typically from measureJson) | |
| ~SerializationBuffer () | |
| SerializationBuffer (SerializationBuffer &&other) noexcept | |
| SerializationBuffer & | operator= (SerializationBuffer &&other) noexcept |
| SerializationBuffer (const SerializationBuffer &)=delete | |
| SerializationBuffer & | operator= (const SerializationBuffer &)=delete |
| const char * | c_str () const |
| Get null-terminated C string. | |
| const char * | data () const |
| Get data pointer. | |
| size_t | size () const |
| Get string length (excluding null terminator) | |
| operator std::string () const | |
| Implicit conversion to std::string for backward compatibility WARNING: This allocates a new std::string on the heap. | |
Static Public Attributes | |
| static constexpr size_t | BUFFER_SIZE = STACK_SIZE |
| Stack buffer size for this instantiation. | |
Buffer for JSON serialization that uses stack allocation for small payloads.
Template parameter STACK_SIZE specifies the stack buffer size (default 512 bytes). Supports move semantics for efficient return-by-value.
Definition at line 22 of file json_util.h.
|
inlineexplicit |
Construct with known size (typically from measureJson)
Definition at line 27 of file json_util.h.
|
inline |
Definition at line 37 of file json_util.h.
|
inlinenoexcept |
Definition at line 40 of file json_util.h.
|
delete |
|
inline |
Get null-terminated C string.
Definition at line 82 of file json_util.h.
|
inline |
Get data pointer.
Definition at line 84 of file json_util.h.
|
inline |
Implicit conversion to std::string for backward compatibility WARNING: This allocates a new std::string on the heap.
Prefer using c_str() or data()/size() directly when possible to avoid allocation.
Definition at line 91 of file json_util.h.
|
delete |
|
inlinenoexcept |
Definition at line 57 of file json_util.h.
|
inline |
Get string length (excluding null terminator)
Definition at line 86 of file json_util.h.
|
staticconstexpr |
Stack buffer size for this instantiation.
Definition at line 24 of file json_util.h.