ESPHome 2025.5.0
Loading...
Searching...
No Matches
esphome::api::ProtoWriteBuffer Class Reference

#include <proto.h>

Public Member Functions

 ProtoWriteBuffer (std::vector< uint8_t > *buffer)
 
void write (uint8_t value)
 
void encode_varint_raw (ProtoVarInt value)
 
void encode_varint_raw (uint32_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_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)
 
void encode_fixed32 (uint32_t field_id, uint32_t value, bool force=false)
 
void encode_fixed64 (uint32_t field_id, uint64_t value, bool force=false)
 
template<typename T >
void encode_enum (uint32_t field_id, T value, bool force=false)
 
void encode_float (uint32_t field_id, float value, bool force=false)
 
void encode_int32 (uint32_t field_id, int32_t value, bool force=false)
 
void encode_int64 (uint32_t field_id, int64_t value, bool force=false)
 
void encode_sint32 (uint32_t field_id, int32_t value, bool force=false)
 
void encode_sint64 (uint32_t field_id, int64_t value, bool force=false)
 
template<class C >
void encode_message (uint32_t field_id, const C &value, bool force=false)
 
std::vector< uint8_t > * get_buffer () const
 

Protected Attributes

std::vector< uint8_t > * buffer_
 

Detailed Description

Definition at line 186 of file proto.h.

Constructor & Destructor Documentation

◆ ProtoWriteBuffer()

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

Definition at line 188 of file proto.h.

Member Function Documentation

◆ encode_bool()

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

Definition at line 235 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 220 of file proto.h.

◆ encode_enum()

template<typename T >
void esphome::api::ProtoWriteBuffer::encode_enum ( uint32_t field_id,
T value,
bool force = false )
inline

Definition at line 265 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)
  • 1: 64-bit (fixed64, sfixed64, double)
  • 2: Length-delimited (string, bytes, embedded messages, packed repeated fields)
  • 5: 32-bit (fixed32, sfixed32, float)

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

Definition at line 204 of file proto.h.

◆ encode_fixed32()

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

Definition at line 241 of file proto.h.

◆ encode_fixed64()

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

Definition at line 251 of file proto.h.

◆ encode_float()

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

Definition at line 268 of file proto.h.

◆ encode_int32()

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

Definition at line 279 of file proto.h.

◆ encode_int64()

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

Definition at line 287 of file proto.h.

◆ encode_message()

template<class C >
void esphome::api::ProtoWriteBuffer::encode_message ( uint32_t field_id,
const C & value,
bool force = false )
inline

Definition at line 308 of file proto.h.

◆ encode_sint32()

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

Definition at line 290 of file proto.h.

◆ encode_sint64()

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

Definition at line 299 of file proto.h.

◆ encode_string() [1/2]

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

Definition at line 208 of file proto.h.

◆ encode_string() [2/2]

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

Definition at line 217 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 223 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 229 of file proto.h.

◆ encode_varint_raw() [1/2]

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

Definition at line 190 of file proto.h.

◆ encode_varint_raw() [2/2]

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

Definition at line 191 of file proto.h.

◆ get_buffer()

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

Definition at line 320 of file proto.h.

◆ write()

void esphome::api::ProtoWriteBuffer::write ( uint8_t value)
inline

Definition at line 189 of file proto.h.

Field Documentation

◆ buffer_

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

Definition at line 323 of file proto.h.


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