ESPHome 2026.3.0-dev
Loading...
Searching...
No Matches
esphome::api::ProtoWriteBuffer Class Reference

#include <proto.h>

Public Member Functions

 ProtoWriteBuffer (std::vector< uint8_t > *buffer)
 
 ProtoWriteBuffer (std::vector< uint8_t > *buffer, size_t write_pos)
 
void encode_varint_raw (uint32_t value)
 
void encode_varint_raw_64 (uint64_t value)
 
void encode_field_raw (uint32_t field_id, uint32_t type)
 Encode a field key (tag/wire type combination).
 
void encode_string (uint32_t field_id, const char *string, size_t len, bool force=false)
 
void encode_string (uint32_t field_id, const std::string &value, bool force=false)
 
void encode_string (uint32_t field_id, const StringRef &ref, bool force=false)
 
void encode_bytes (uint32_t field_id, const uint8_t *data, size_t len, bool force=false)
 
void encode_uint32 (uint32_t field_id, uint32_t value, bool force=false)
 
void encode_uint64 (uint32_t field_id, uint64_t value, bool force=false)
 
void encode_bool (uint32_t field_id, bool value, bool force=false)
 
 __attribute__ ((noinline)) void encode_fixed32(uint32_t field_id
 
void encode_message (uint32_t field_id, const ProtoMessage &value, bool force=true)
 Encode a nested message field (force=true for repeated, false for singular)
 
std::vector< uint8_t > * get_buffer () const
 

Data Fields

uint32_t value
 
uint32_t bool force
 

Protected Member Functions

void debug_check_bounds_ (size_t bytes, const char *caller=__builtin_FUNCTION())
 
void debug_check_encode_size_ (uint32_t field_id, uint32_t expected, ptrdiff_t actual)
 
void debug_check_bounds_ (size_t bytes)
 

Protected Attributes

std::vector< uint8_t > * buffer_
 
uint8_t * pos_
 

Detailed Description

Definition at line 238 of file proto.h.

Constructor & Destructor Documentation

◆ ProtoWriteBuffer() [1/2]

esphome::api::ProtoWriteBuffer::ProtoWriteBuffer ( std::vector< uint8_t > * buffer)
inline

Definition at line 240 of file proto.h.

◆ ProtoWriteBuffer() [2/2]

esphome::api::ProtoWriteBuffer::ProtoWriteBuffer ( std::vector< uint8_t > * buffer,
size_t write_pos )
inline

Definition at line 241 of file proto.h.

Member Function Documentation

◆ __attribute__()

esphome::api::ProtoWriteBuffer::__attribute__ ( (noinline) )

◆ debug_check_bounds_() [1/2]

void esphome::api::ProtoWriteBuffer::debug_check_bounds_ ( size_t bytes)
inlineprotected

Definition at line 375 of file proto.h.

◆ debug_check_bounds_() [2/2]

void esphome::api::ProtoWriteBuffer::debug_check_bounds_ ( size_t bytes,
const char * caller = __builtin_FUNCTION() )
protected

Definition at line 91 of file proto.cpp.

◆ debug_check_encode_size_()

void esphome::api::ProtoWriteBuffer::debug_check_encode_size_ ( uint32_t field_id,
uint32_t expected,
ptrdiff_t actual )
protected

Definition at line 98 of file proto.cpp.

◆ encode_bool()

void esphome::api::ProtoWriteBuffer::encode_bool ( uint32_t field_id,
bool value,
bool force = false )
inline

Definition at line 307 of file proto.h.

◆ encode_bytes()

void esphome::api::ProtoWriteBuffer::encode_bytes ( uint32_t field_id,
const uint8_t * data,
size_t len,
bool force = false )
inline

Definition at line 292 of file proto.h.

◆ encode_field_raw()

void esphome::api::ProtoWriteBuffer::encode_field_raw ( uint32_t field_id,
uint32_t type )
inline

Encode a field key (tag/wire type combination).

Parameters
field_idField number (tag) in the protobuf message
typeWire type value:
  • 0: Varint (int32, int64, uint32, uint64, sint32, sint64, bool, enum)
  • 2: Length-delimited (string, bytes, embedded messages, packed repeated fields)
  • 5: 32-bit (fixed32, sfixed32, float)
  • Note: Wire type 1 (64-bit fixed) is not supported

Following https://protobuf.dev/programming-guides/encoding/#structure

Definition at line 273 of file proto.h.

◆ encode_message()

void esphome::api::ProtoWriteBuffer::encode_message ( uint32_t field_id,
const ProtoMessage & value,
bool force = true )
inline

Encode a nested message field (force=true for repeated, false for singular)

Definition at line 953 of file proto.h.

◆ encode_string() [1/3]

void esphome::api::ProtoWriteBuffer::encode_string ( uint32_t field_id,
const char * string,
size_t len,
bool force = false )
inline

Definition at line 274 of file proto.h.

◆ encode_string() [2/3]

void esphome::api::ProtoWriteBuffer::encode_string ( uint32_t field_id,
const std::string & value,
bool force = false )
inline

Definition at line 286 of file proto.h.

◆ encode_string() [3/3]

void esphome::api::ProtoWriteBuffer::encode_string ( uint32_t field_id,
const StringRef & ref,
bool force = false )
inline

Definition at line 289 of file proto.h.

◆ encode_uint32()

void esphome::api::ProtoWriteBuffer::encode_uint32 ( uint32_t field_id,
uint32_t value,
bool force = false )
inline

Definition at line 295 of file proto.h.

◆ encode_uint64()

void esphome::api::ProtoWriteBuffer::encode_uint64 ( uint32_t field_id,
uint64_t value,
bool force = false )
inline

Definition at line 301 of file proto.h.

◆ encode_varint_raw()

void esphome::api::ProtoWriteBuffer::encode_varint_raw ( uint32_t value)
inline

Definition at line 243 of file proto.h.

◆ encode_varint_raw_64()

void esphome::api::ProtoWriteBuffer::encode_varint_raw_64 ( uint64_t value)
inline

Definition at line 252 of file proto.h.

◆ get_buffer()

std::vector< uint8_t > * esphome::api::ProtoWriteBuffer::get_buffer ( ) const
inline

Definition at line 368 of file proto.h.

Field Documentation

◆ buffer_

std::vector<uint8_t>* esphome::api::ProtoWriteBuffer::buffer_
protected

Definition at line 378 of file proto.h.

◆ force

uint32_t bool esphome::api::ProtoWriteBuffer::force

Definition at line 315 of file proto.h.

◆ pos_

uint8_t* esphome::api::ProtoWriteBuffer::pos_
protected

Definition at line 379 of file proto.h.

◆ value

uint32_t esphome::api::ProtoWriteBuffer::value

Definition at line 315 of file proto.h.


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