esphome-api-client 0.5.0
Modern C++17 client for the ESPHome native API (plaintext + Noise)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
esphome::api::ProtoMessage Class Referenceabstract

Base class every generated message derives from. More...

#include <proto_message.hpp>

Inheritance diagram for esphome::api::ProtoMessage:
Inheritance graph
[legend]

Public Member Functions

 ProtoMessage ()=default
 
 ProtoMessage (const ProtoMessage &)=default
 
 ProtoMessage (ProtoMessage &&)=default
 
ProtoMessageoperator= (const ProtoMessage &)=default
 
ProtoMessageoperator= (ProtoMessage &&)=default
 
virtual ~ProtoMessage ()=default
 
virtual void encode (ProtoWriter &writer) const =0
 Serialize this message's fields to writer (ascending field number).
 
virtual bool decode (ProtoReader &reader)=0
 Decode wire bytes into this message.
 
virtual std::size_t calculate_size () const =0
 Exact number of bytes encode() will write.
 
virtual std::uint32_t message_id () const =0
 The protocol message id (the proto (id) option), or 0 if the message carries none.
 
virtual const char * message_name () const =0
 The proto message name (e.g. "ListEntitiesLightResponse").
 
virtual std::unique_ptr< ProtoMessageclone () const =0
 A deep copy of this message as a new owning pointer.
 
std::size_t ByteSizeLong () const
 Alias for calculate_size() — matches protobuf's API.
 
bool SerializeToArray (void *data, const int size) const
 Serialize into a caller-provided buffer of exactly size bytes.
 
std::string SerializeAsString () const
 Serialize to a freshly allocated string.
 
bool ParseFromArray (const void *data, const int size)
 Parse wire bytes into this message. Returns false on malformed input.
 

Detailed Description

Base class every generated message derives from.

Constructor & Destructor Documentation

◆ ProtoMessage() [1/3]

esphome::api::ProtoMessage::ProtoMessage ( )
default

◆ ProtoMessage() [2/3]

esphome::api::ProtoMessage::ProtoMessage ( const ProtoMessage )
default

◆ ProtoMessage() [3/3]

esphome::api::ProtoMessage::ProtoMessage ( ProtoMessage &&  )
default

◆ ~ProtoMessage()

virtual esphome::api::ProtoMessage::~ProtoMessage ( )
virtualdefault

Member Function Documentation

◆ ByteSizeLong()

std::size_t esphome::api::ProtoMessage::ByteSizeLong ( ) const
inline

Alias for calculate_size() — matches protobuf's API.

◆ calculate_size()

virtual std::size_t esphome::api::ProtoMessage::calculate_size ( ) const
pure virtual

Exact number of bytes encode() will write.

◆ clone()

virtual std::unique_ptr< ProtoMessage > esphome::api::ProtoMessage::clone ( ) const
pure virtual

A deep copy of this message as a new owning pointer.

◆ decode()

virtual bool esphome::api::ProtoMessage::decode ( ProtoReader reader)
pure virtual

Decode wire bytes into this message.

Returns false on truncation / malformed input. Unknown fields are skipped (forward-compat).

◆ encode()

virtual void esphome::api::ProtoMessage::encode ( ProtoWriter writer) const
pure virtual

Serialize this message's fields to writer (ascending field number).

◆ message_id()

virtual std::uint32_t esphome::api::ProtoMessage::message_id ( ) const
pure virtual

The protocol message id (the proto (id) option), or 0 if the message carries none.

◆ message_name()

virtual const char * esphome::api::ProtoMessage::message_name ( ) const
pure virtual

The proto message name (e.g. "ListEntitiesLightResponse").

◆ operator=() [1/2]

ProtoMessage & esphome::api::ProtoMessage::operator= ( const ProtoMessage )
default

◆ operator=() [2/2]

ProtoMessage & esphome::api::ProtoMessage::operator= ( ProtoMessage &&  )
default

◆ ParseFromArray()

bool esphome::api::ProtoMessage::ParseFromArray ( const void *  data,
const int  size 
)
inline

Parse wire bytes into this message. Returns false on malformed input.

◆ SerializeAsString()

std::string esphome::api::ProtoMessage::SerializeAsString ( ) const
inline

Serialize to a freshly allocated string.

◆ SerializeToArray()

bool esphome::api::ProtoMessage::SerializeToArray ( void *  data,
const int  size 
) const
inline

Serialize into a caller-provided buffer of exactly size bytes.

Returns false if the message does not encode to exactly size bytes.


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