ESPHome 2026.5.0-dev
Loading...
Searching...
No Matches
esphome::api::ProtoSize Class Reference

#include <proto.h>

Static Public Member Functions

static constexpr uint8_t ESPHOME_ALWAYS_INLINE varint16 (uint16_t value)
 
static constexpr uint8_t ESPHOME_ALWAYS_INLINE varint8 (uint8_t value)
 
static constexpr uint32_t ESPHOME_ALWAYS_INLINE varint (uint32_t value)
 Calculates the size in bytes needed to encode a uint32_t value as a varint.
 
static constexpr uint32_t ESPHOME_ALWAYS_INLINE varint_short (uint32_t value)
 Size of a varint expected to be 1-2 bytes (e.g.
 
static constexpr uint32_t varint (uint64_t value)
 Calculates the size in bytes needed to encode a uint64_t value as a varint.
 
static constexpr uint32_t varint (int32_t value)
 Calculates the size in bytes needed to encode an int32_t value as a varint.
 
static constexpr uint32_t varint (int64_t value)
 Calculates the size in bytes needed to encode an int64_t value as a varint.
 
static constexpr uint32_t field (uint32_t field_id, uint32_t type)
 Calculates the size in bytes needed to encode a field ID and wire type.
 
static constexpr uint32_t calc_int32 (uint32_t field_id_size, int32_t value)
 
static constexpr uint32_t calc_int32_force (uint32_t field_id_size, int32_t value)
 
static constexpr uint32_t calc_uint32 (uint32_t field_id_size, uint32_t value)
 
static constexpr uint32_t calc_uint32_force (uint32_t field_id_size, uint32_t value)
 
static constexpr uint32_t calc_bool (uint32_t field_id_size, bool value)
 
static constexpr uint32_t calc_bool_force (uint32_t field_id_size)
 
static uint32_t calc_float (uint32_t field_id_size, float value)
 
static constexpr uint32_t calc_fixed32 (uint32_t field_id_size, uint32_t value)
 
static constexpr uint32_t calc_sfixed32 (uint32_t field_id_size, int32_t value)
 
static constexpr uint32_t calc_sint32 (uint32_t field_id_size, int32_t value)
 
static constexpr uint32_t ESPHOME_ALWAYS_INLINE calc_sint32_force (uint32_t field_id_size, int32_t value)
 
static constexpr uint32_t calc_int64 (uint32_t field_id_size, int64_t value)
 
static constexpr uint32_t calc_int64_force (uint32_t field_id_size, int64_t value)
 
static constexpr uint32_t calc_uint64 (uint32_t field_id_size, uint64_t value)
 
static constexpr uint32_t ESPHOME_ALWAYS_INLINE calc_uint64_force (uint32_t field_id_size, uint64_t value)
 
static constexpr uint32_t calc_length (uint32_t field_id_size, size_t len)
 
static constexpr uint32_t ESPHOME_ALWAYS_INLINE calc_length_force (uint32_t field_id_size, size_t len)
 
static constexpr uint32_t calc_sint64 (uint32_t field_id_size, int64_t value)
 
static constexpr uint32_t calc_sint64_force (uint32_t field_id_size, int64_t value)
 
static constexpr uint32_t calc_fixed64 (uint32_t field_id_size, uint64_t value)
 
static constexpr uint32_t calc_sfixed64 (uint32_t field_id_size, int64_t value)
 
static constexpr uint32_t calc_message (uint32_t field_id_size, uint32_t nested_size)
 
static constexpr uint32_t ESPHOME_ALWAYS_INLINE calc_message_force (uint32_t field_id_size, uint32_t nested_size)
 

Static Public Attributes

static constexpr uint32_t VARINT_THRESHOLD_1_BYTE = VARINT_MAX_1_BYTE
 
static constexpr uint32_t VARINT_THRESHOLD_2_BYTE = VARINT_MAX_2_BYTE
 
static constexpr uint32_t VARINT_THRESHOLD_3_BYTE = 1 << 21
 
static constexpr uint32_t VARINT_THRESHOLD_4_BYTE = 1 << 28
 

Detailed Description

Definition at line 645 of file proto.h.

Member Function Documentation

◆ calc_bool()

static constexpr uint32_t esphome::api::ProtoSize::calc_bool ( uint32_t field_id_size,
bool value )
inlinestaticconstexpr

Definition at line 791 of file proto.h.

◆ calc_bool_force()

static constexpr uint32_t esphome::api::ProtoSize::calc_bool_force ( uint32_t field_id_size)
inlinestaticconstexpr

Definition at line 792 of file proto.h.

◆ calc_fixed32()

static constexpr uint32_t esphome::api::ProtoSize::calc_fixed32 ( uint32_t field_id_size,
uint32_t value )
inlinestaticconstexpr

Definition at line 796 of file proto.h.

◆ calc_fixed64()

static constexpr uint32_t esphome::api::ProtoSize::calc_fixed64 ( uint32_t field_id_size,
uint64_t value )
inlinestaticconstexpr

Definition at line 832 of file proto.h.

◆ calc_float()

static uint32_t esphome::api::ProtoSize::calc_float ( uint32_t field_id_size,
float value )
inlinestatic

Definition at line 793 of file proto.h.

◆ calc_int32()

static constexpr uint32_t esphome::api::ProtoSize::calc_int32 ( uint32_t field_id_size,
int32_t value )
inlinestaticconstexpr

Definition at line 779 of file proto.h.

◆ calc_int32_force()

static constexpr uint32_t esphome::api::ProtoSize::calc_int32_force ( uint32_t field_id_size,
int32_t value )
inlinestaticconstexpr

Definition at line 782 of file proto.h.

◆ calc_int64()

static constexpr uint32_t esphome::api::ProtoSize::calc_int64 ( uint32_t field_id_size,
int64_t value )
inlinestaticconstexpr

Definition at line 808 of file proto.h.

◆ calc_int64_force()

static constexpr uint32_t esphome::api::ProtoSize::calc_int64_force ( uint32_t field_id_size,
int64_t value )
inlinestaticconstexpr

Definition at line 811 of file proto.h.

◆ calc_length()

static constexpr uint32_t esphome::api::ProtoSize::calc_length ( uint32_t field_id_size,
size_t len )
inlinestaticconstexpr

Definition at line 820 of file proto.h.

◆ calc_length_force()

static constexpr uint32_t ESPHOME_ALWAYS_INLINE esphome::api::ProtoSize::calc_length_force ( uint32_t field_id_size,
size_t len )
inlinestaticconstexpr

Definition at line 823 of file proto.h.

◆ calc_message()

static constexpr uint32_t esphome::api::ProtoSize::calc_message ( uint32_t field_id_size,
uint32_t nested_size )
inlinestaticconstexpr

Definition at line 838 of file proto.h.

◆ calc_message_force()

static constexpr uint32_t ESPHOME_ALWAYS_INLINE esphome::api::ProtoSize::calc_message_force ( uint32_t field_id_size,
uint32_t nested_size )
inlinestaticconstexpr

Definition at line 841 of file proto.h.

◆ calc_sfixed32()

static constexpr uint32_t esphome::api::ProtoSize::calc_sfixed32 ( uint32_t field_id_size,
int32_t value )
inlinestaticconstexpr

Definition at line 799 of file proto.h.

◆ calc_sfixed64()

static constexpr uint32_t esphome::api::ProtoSize::calc_sfixed64 ( uint32_t field_id_size,
int64_t value )
inlinestaticconstexpr

Definition at line 835 of file proto.h.

◆ calc_sint32()

static constexpr uint32_t esphome::api::ProtoSize::calc_sint32 ( uint32_t field_id_size,
int32_t value )
inlinestaticconstexpr

Definition at line 802 of file proto.h.

◆ calc_sint32_force()

static constexpr uint32_t ESPHOME_ALWAYS_INLINE esphome::api::ProtoSize::calc_sint32_force ( uint32_t field_id_size,
int32_t value )
inlinestaticconstexpr

Definition at line 805 of file proto.h.

◆ calc_sint64()

static constexpr uint32_t esphome::api::ProtoSize::calc_sint64 ( uint32_t field_id_size,
int64_t value )
inlinestaticconstexpr

Definition at line 826 of file proto.h.

◆ calc_sint64_force()

static constexpr uint32_t esphome::api::ProtoSize::calc_sint64_force ( uint32_t field_id_size,
int64_t value )
inlinestaticconstexpr

Definition at line 829 of file proto.h.

◆ calc_uint32()

static constexpr uint32_t esphome::api::ProtoSize::calc_uint32 ( uint32_t field_id_size,
uint32_t value )
inlinestaticconstexpr

Definition at line 785 of file proto.h.

◆ calc_uint32_force()

static constexpr uint32_t esphome::api::ProtoSize::calc_uint32_force ( uint32_t field_id_size,
uint32_t value )
inlinestaticconstexpr

Definition at line 788 of file proto.h.

◆ calc_uint64()

static constexpr uint32_t esphome::api::ProtoSize::calc_uint64 ( uint32_t field_id_size,
uint64_t value )
inlinestaticconstexpr

Definition at line 814 of file proto.h.

◆ calc_uint64_force()

static constexpr uint32_t ESPHOME_ALWAYS_INLINE esphome::api::ProtoSize::calc_uint64_force ( uint32_t field_id_size,
uint64_t value )
inlinestaticconstexpr

Definition at line 817 of file proto.h.

◆ field()

static constexpr uint32_t esphome::api::ProtoSize::field ( uint32_t field_id,
uint32_t type )
inlinestaticconstexpr

Calculates the size in bytes needed to encode a field ID and wire type.

Parameters
field_idThe field identifier
typeThe wire type value (from the WireType enum in the protobuf spec)
Returns
The number of bytes needed to encode the field ID and wire type

Definition at line 772 of file proto.h.

◆ varint() [1/4]

static constexpr uint32_t esphome::api::ProtoSize::varint ( int32_t value)
inlinestaticconstexpr

Calculates the size in bytes needed to encode an int32_t value as a varint.

Special handling is needed for negative values, which are sign-extended to 64 bits in Protocol Buffers, resulting in a 10-byte varint.

Parameters
valueThe int32_t value to calculate size for
Returns
The number of bytes needed to encode the value

Definition at line 742 of file proto.h.

◆ varint() [2/4]

static constexpr uint32_t esphome::api::ProtoSize::varint ( int64_t value)
inlinestaticconstexpr

Calculates the size in bytes needed to encode an int64_t value as a varint.

Parameters
valueThe int64_t value to calculate size for
Returns
The number of bytes needed to encode the value

Definition at line 758 of file proto.h.

◆ varint() [3/4]

static constexpr uint32_t ESPHOME_ALWAYS_INLINE esphome::api::ProtoSize::varint ( uint32_t value)
inlinestaticconstexpr

Calculates the size in bytes needed to encode a uint32_t value as a varint.

Parameters
valueThe uint32_t value to calculate size for
Returns
The number of bytes needed to encode the value

Definition at line 671 of file proto.h.

◆ varint() [4/4]

static constexpr uint32_t esphome::api::ProtoSize::varint ( uint64_t value)
inlinestaticconstexpr

Calculates the size in bytes needed to encode a uint64_t value as a varint.

Parameters
valueThe uint64_t value to calculate size for
Returns
The number of bytes needed to encode the value

Definition at line 711 of file proto.h.

◆ varint16()

static constexpr uint8_t ESPHOME_ALWAYS_INLINE esphome::api::ProtoSize::varint16 ( uint16_t value)
inlinestaticconstexpr

Definition at line 656 of file proto.h.

◆ varint8()

static constexpr uint8_t ESPHOME_ALWAYS_INLINE esphome::api::ProtoSize::varint8 ( uint8_t value)
inlinestaticconstexpr

Definition at line 661 of file proto.h.

◆ varint_short()

static constexpr uint32_t ESPHOME_ALWAYS_INLINE esphome::api::ProtoSize::varint_short ( uint32_t value)
inlinestaticconstexpr

Size of a varint expected to be 1-2 bytes (e.g.

zigzag RSSI, small lengths). Inlines both checks; falls back to slow path for 3+ bytes.

Definition at line 680 of file proto.h.

Field Documentation

◆ VARINT_THRESHOLD_1_BYTE

uint32_t esphome::api::ProtoSize::VARINT_THRESHOLD_1_BYTE = VARINT_MAX_1_BYTE
staticconstexpr

Definition at line 649 of file proto.h.

◆ VARINT_THRESHOLD_2_BYTE

uint32_t esphome::api::ProtoSize::VARINT_THRESHOLD_2_BYTE = VARINT_MAX_2_BYTE
staticconstexpr

Definition at line 650 of file proto.h.

◆ VARINT_THRESHOLD_3_BYTE

uint32_t esphome::api::ProtoSize::VARINT_THRESHOLD_3_BYTE = 1 << 21
staticconstexpr

Definition at line 651 of file proto.h.

◆ VARINT_THRESHOLD_4_BYTE

uint32_t esphome::api::ProtoSize::VARINT_THRESHOLD_4_BYTE = 1 << 28
staticconstexpr

Definition at line 652 of file proto.h.


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