EmbeddedProto  2.0.0
EmbeddedProto is a C++ Protocol Buffer implementation specifically suitable for microcontrollers.
Public Member Functions | List of all members
EmbeddedProto::RepeatedFieldFixedSize< DATA_TYPE, MAX_LENGTH > Class Template Reference

A template class that actually holds some data. More...

#include <RepeatedFieldFixedSize.h>

Inheritance diagram for EmbeddedProto::RepeatedFieldFixedSize< DATA_TYPE, MAX_LENGTH >:
Inheritance graph
[legend]
Collaboration diagram for EmbeddedProto::RepeatedFieldFixedSize< DATA_TYPE, MAX_LENGTH >:
Collaboration graph
[legend]

Public Member Functions

 RepeatedFieldFixedSize ()
 
 ~RepeatedFieldFixedSize () override=default
 
RepeatedFieldFixedSize< DATA_TYPE, MAX_LENGTH > & operator= (const RepeatedFieldFixedSize< DATA_TYPE, MAX_LENGTH > &rhs)
 Assign one repieted field to the other, but only when the length and type matches. More...
 
uint32_t get_length () const override
 Obtain the total number of DATA_TYPE items in the array. More...
 
uint32_t get_max_length () const override
 Obtain the maximum number of DATA_TYPE items which can at most be stored in the array. More...
 
uint32_t get_size () const override
 Obtain the total number of bytes currently stored in the array. More...
 
uint32_t get_max_size () const override
 Obtain the maximum number of bytes which can at most be stored in the array. More...
 
DATA_TYPE & get (uint32_t index) override
 Get a reference to the value at the given index. More...
 
const DATA_TYPE & get_const (uint32_t index) const override
 Get a constant reference to the value at the given index. More...
 
void set (uint32_t index, const DATA_TYPE &value) override
 Set the value at the given index. More...
 
Error set_data (const DATA_TYPE *data, const uint32_t length) override
 Given a different array of known length copy that data into this object. More...
 
Error add (const DATA_TYPE &value) override
 Append a value to the end of the array. More...
 
void clear () override
 Remove all data in the array and set it to the default value. More...
 
- Public Member Functions inherited from EmbeddedProto::RepeatedField< DATA_TYPE >
 RepeatedField ()=default
 
virtual ~RepeatedField ()=default
 
DATA_TYPE & operator[] (uint32_t index)
 Get a reference to the value at the given index. More...
 
const DATA_TYPE & operator[] (uint32_t index) const
 Get a reference to the value at the given index. But constant. More...
 
Error serialize (WriteBufferInterface &buffer) const
 
Error serialize_with_id (uint32_t field_number, WriteBufferInterface &buffer) const final
 
Error deserialize (::EmbeddedProto::ReadBufferInterface &buffer) final
 Function to deserialize this array. More...
 
uint32_t serialized_size_packed (int32_t field_number) const
 Calculate the size of this field when serialized. More...
 
uint32_t serialized_size_unpacked (int32_t field_number) const
 Calculate the size of this field when serialized. More...
 
- Public Member Functions inherited from EmbeddedProto::Field
 Field ()=default
 
virtual ~Field ()=default
 
virtual Error deserialize (ReadBufferInterface &buffer)=0
 
uint32_t serialized_size () const
 Calculate the size of this message when serialized. More...
 

Detailed Description

template<class DATA_TYPE, uint32_t MAX_LENGTH>
class EmbeddedProto::RepeatedFieldFixedSize< DATA_TYPE, MAX_LENGTH >

A template class that actually holds some data.

This is a separate class to make it possible to not have the size defined in every function or class using this type of object.

Constructor & Destructor Documentation

◆ RepeatedFieldFixedSize()

template<class DATA_TYPE , uint32_t MAX_LENGTH>
EmbeddedProto::RepeatedFieldFixedSize< DATA_TYPE, MAX_LENGTH >::RepeatedFieldFixedSize ( )
inline

◆ ~RepeatedFieldFixedSize()

template<class DATA_TYPE , uint32_t MAX_LENGTH>
EmbeddedProto::RepeatedFieldFixedSize< DATA_TYPE, MAX_LENGTH >::~RepeatedFieldFixedSize ( )
overridedefault

Member Function Documentation

◆ add()

template<class DATA_TYPE , uint32_t MAX_LENGTH>
Error EmbeddedProto::RepeatedFieldFixedSize< DATA_TYPE, MAX_LENGTH >::add ( const DATA_TYPE &  value)
inlineoverridevirtual

Append a value to the end of the array.

Parameters
[in]valueThe data to add.
Returns
Error::NO_ERRORS when every was successful. Error::ARRAY_FULL when there is no space left.

Implements EmbeddedProto::RepeatedField< DATA_TYPE >.

◆ clear()

template<class DATA_TYPE , uint32_t MAX_LENGTH>
void EmbeddedProto::RepeatedFieldFixedSize< DATA_TYPE, MAX_LENGTH >::clear ( )
inlineoverridevirtual

Remove all data in the array and set it to the default value.

Implements EmbeddedProto::RepeatedField< DATA_TYPE >.

◆ get()

template<class DATA_TYPE , uint32_t MAX_LENGTH>
DATA_TYPE& EmbeddedProto::RepeatedFieldFixedSize< DATA_TYPE, MAX_LENGTH >::get ( uint32_t  index)
inlineoverridevirtual

Get a reference to the value at the given index.

Parameters
[in]indexThe desired index to return.
Returns
The reference to the value at the given index.

Implements EmbeddedProto::RepeatedField< DATA_TYPE >.

◆ get_const()

template<class DATA_TYPE , uint32_t MAX_LENGTH>
const DATA_TYPE& EmbeddedProto::RepeatedFieldFixedSize< DATA_TYPE, MAX_LENGTH >::get_const ( uint32_t  index) const
inlineoverridevirtual

Get a constant reference to the value at the given index.

Parameters
[in]indexThe desired index to return.
Returns
The constant reference to the value at the given index.

Implements EmbeddedProto::RepeatedField< DATA_TYPE >.

◆ get_length()

template<class DATA_TYPE , uint32_t MAX_LENGTH>
uint32_t EmbeddedProto::RepeatedFieldFixedSize< DATA_TYPE, MAX_LENGTH >::get_length ( ) const
inlineoverridevirtual

Obtain the total number of DATA_TYPE items in the array.

Implements EmbeddedProto::RepeatedField< DATA_TYPE >.

◆ get_max_length()

template<class DATA_TYPE , uint32_t MAX_LENGTH>
uint32_t EmbeddedProto::RepeatedFieldFixedSize< DATA_TYPE, MAX_LENGTH >::get_max_length ( ) const
inlineoverridevirtual

Obtain the maximum number of DATA_TYPE items which can at most be stored in the array.

Implements EmbeddedProto::RepeatedField< DATA_TYPE >.

◆ get_max_size()

template<class DATA_TYPE , uint32_t MAX_LENGTH>
uint32_t EmbeddedProto::RepeatedFieldFixedSize< DATA_TYPE, MAX_LENGTH >::get_max_size ( ) const
inlineoverridevirtual

Obtain the maximum number of bytes which can at most be stored in the array.

Implements EmbeddedProto::RepeatedField< DATA_TYPE >.

◆ get_size()

template<class DATA_TYPE , uint32_t MAX_LENGTH>
uint32_t EmbeddedProto::RepeatedFieldFixedSize< DATA_TYPE, MAX_LENGTH >::get_size ( ) const
inlineoverridevirtual

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

Implements EmbeddedProto::RepeatedField< DATA_TYPE >.

◆ operator=()

template<class DATA_TYPE , uint32_t MAX_LENGTH>
RepeatedFieldFixedSize<DATA_TYPE, MAX_LENGTH>& EmbeddedProto::RepeatedFieldFixedSize< DATA_TYPE, MAX_LENGTH >::operator= ( const RepeatedFieldFixedSize< DATA_TYPE, MAX_LENGTH > &  rhs)
inline

Assign one repieted field to the other, but only when the length and type matches.

◆ set()

template<class DATA_TYPE , uint32_t MAX_LENGTH>
void EmbeddedProto::RepeatedFieldFixedSize< DATA_TYPE, MAX_LENGTH >::set ( uint32_t  index,
const DATA_TYPE &  value 
)
inlineoverridevirtual

Set the value at the given index.

Parameters
[in]indexThe desired index to change.
[in]valueThe value we would like to set.

Implements EmbeddedProto::RepeatedField< DATA_TYPE >.

◆ set_data()

template<class DATA_TYPE , uint32_t MAX_LENGTH>
Error EmbeddedProto::RepeatedFieldFixedSize< DATA_TYPE, MAX_LENGTH >::set_data ( const DATA_TYPE *  data,
const uint32_t  length 
)
inlineoverridevirtual

Given a different array of known length copy that data into this object.

Parameters
[in]dataA pointer the array to copy from.
[in]lengthThe number of value of DATA_TYPE in the array.
Returns
Error::NO_ERRORS when every was successful. Error::ARRAY_FULL when there is no space left.

Implements EmbeddedProto::RepeatedField< DATA_TYPE >.


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