EmbeddedProto  2.0.0
EmbeddedProto is a C++ Protocol Buffer implementation specifically suitable for microcontrollers.
Public Member Functions | List of all members
EmbeddedProto::MessageSizeCalculator Class Reference

This class is used in a message to calculate the current serialized size. More...

#include <MessageSizeCalculator.h>

Inheritance diagram for EmbeddedProto::MessageSizeCalculator:
Inheritance graph
[legend]
Collaboration diagram for EmbeddedProto::MessageSizeCalculator:
Collaboration graph
[legend]

Public Member Functions

 MessageSizeCalculator ()=default
 
 ~MessageSizeCalculator () override=default
 
void clear () override
 Reset the size count of the buffer. More...
 
uint32_t get_size () const override
 Obtain the total number of bytes currently stored in the buffer. More...
 
uint32_t get_max_size () const override
 To continue serialization return the maximum number that fits in a 32bit unsigned int. More...
 
uint32_t get_available_size () const override
 To continue serialization return the maximum number that fits in a 32bit unsigned int. More...
 
bool push (const uint8_t byte) override
 For calculating the size we just increment the counter and always return true. More...
 
bool push (const uint8_t *bytes, const uint32_t length) override
 Increment the size with the given length. More...
 
- Public Member Functions inherited from EmbeddedProto::WriteBufferInterface
 WriteBufferInterface ()=default
 
virtual ~WriteBufferInterface ()=default
 

Detailed Description

This class is used in a message to calculate the current serialized size.

To calculate the size of a message given the current data a dummy serialization is performed. This class mimics the buffer in which the data is stored. Instead of storing it, only the size is incremented for the bytes pushed. No actual data is pushed into a buffer.

See also
MessageInterface::serialized_size()

Constructor & Destructor Documentation

◆ MessageSizeCalculator()

EmbeddedProto::MessageSizeCalculator::MessageSizeCalculator ( )
default

◆ ~MessageSizeCalculator()

EmbeddedProto::MessageSizeCalculator::~MessageSizeCalculator ( )
overridedefault

Member Function Documentation

◆ clear()

void EmbeddedProto::MessageSizeCalculator::clear ( )
inlineoverridevirtual

Reset the size count of the buffer.

Implements EmbeddedProto::WriteBufferInterface.

◆ get_available_size()

uint32_t EmbeddedProto::MessageSizeCalculator::get_available_size ( ) const
inlineoverridevirtual

To continue serialization return the maximum number that fits in a 32bit unsigned int.

Implements EmbeddedProto::WriteBufferInterface.

◆ get_max_size()

uint32_t EmbeddedProto::MessageSizeCalculator::get_max_size ( ) const
inlineoverridevirtual

To continue serialization return the maximum number that fits in a 32bit unsigned int.

Implements EmbeddedProto::WriteBufferInterface.

◆ get_size()

uint32_t EmbeddedProto::MessageSizeCalculator::get_size ( ) const
inlineoverridevirtual

Obtain the total number of bytes currently stored in the buffer.

Implements EmbeddedProto::WriteBufferInterface.

◆ push() [1/2]

bool EmbeddedProto::MessageSizeCalculator::push ( const uint8_t *  bytes,
const uint32_t  length 
)
inlineoverridevirtual

Increment the size with the given length.

Implements EmbeddedProto::WriteBufferInterface.

◆ push() [2/2]

bool EmbeddedProto::MessageSizeCalculator::push ( const uint8_t  byte)
inlineoverridevirtual

For calculating the size we just increment the counter and always return true.

Implements EmbeddedProto::WriteBufferInterface.


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