MySQL 8.4.0
Source Code Documentation
mysql::serialization::Serializable< Derived_serializable_type > Class Template Reference

Interface for serializable data structures. More...

#include <serializable.h>

Public Member Functions

template<class Serializable_functor_type , class Field_functor_type >
void do_for_each_field (Serializable_functor_type &&func_s, Field_functor_type &&func_f)
 calls functor for each field More...
 
template<class Serializable_functor_type , class Field_functor_type >
void do_for_each_field (Serializable_functor_type &&func_s, Field_functor_type &&func_f) const
 calls functor for each field, const version More...
 
template<typename Serializer_type >
std::size_t get_size_internal () const
 Returns serializable object fields size, internal function (without serializable metadata size) More...
 
bool is_any_field_provided () const
 Performs iteration over all of the serializable fields and checks whether any of the fields in this serializable is provided. More...
 
void set_unknown_field_policy (const Unknown_field_policy &policy)
 Sets unknown field policy for this object. More...
 
bool is_ignorable () const
 

Static Public Member Functions

static constexpr Field_id_type get_last_field_id ()
 This function calculates last field id of this type. More...
 
template<typename Serializer_type >
static constexpr std::size_t get_max_size_internal ()
 Returns serializable object fields maximum size, internal function (without serializable metadata size) More...
 

Protected Types

using Tag = Serializable_tag
 

Protected Member Functions

template<class Serializable_functor_type , class Field_functor_type , class Tuple_type , std::size_t... Is>
void do_for_each_field (Serializable_functor_type &&func_s, Field_functor_type &&func_f, Tuple_type &&tuple, std::index_sequence< Is... >)
 do_for_each_field helper More...
 
template<class Serializable_functor_type , class Field_functor_type , class Field_type >
void do_for_one_field (Serializable_functor_type &&func_s, Field_functor_type &&func_f, Field_type &field, std::size_t field_id)
 do_for_each_field helper More...
 
template<class Serializable_functor_type , class Field_functor_type , class Field_type >
void do_for_one_field (Serializable_functor_type &&func_s, Field_functor_type &&func_f, Field_type &field, std::size_t field_id, Serializable_tag)
 do_for_each_field helper More...
 
template<class Serializable_functor_type , class Field_functor_type , class Field_type >
void do_for_one_field (Serializable_functor_type &&, Field_functor_type &&func_f, Field_type &field, std::size_t field_id, Field_definition_tag)
 do_for_each_field helper More...
 
template<class Serializable_functor_type , class Field_functor_type , class Tuple_type , std::size_t... Is>
void do_for_each_field (Serializable_functor_type &&func_s, Field_functor_type &&func_f, Tuple_type &&tuple, std::index_sequence< Is... >) const
 do_for_each_field (const) helper More...
 
template<class Serializable_functor_type , class Field_functor_type , class Field_type >
void do_for_one_field (Serializable_functor_type &&func_s, Field_functor_type &&func_f, const Field_type &field, std::size_t field_id) const
 do_for_each_field (const) helper More...
 
template<class Serializable_functor_type , class Field_functor_type , class Field_type >
void do_for_one_field (Serializable_functor_type &&func_s, Field_functor_type &&func_f, const Field_type &field, std::size_t field_id, Serializable_tag) const
 do_for_each_field (const) helper More...
 
template<class Serializable_functor_type , class Field_functor_type , class Field_type >
void do_for_one_field (Serializable_functor_type &&, Field_functor_type &&func_f, const Field_type &field, std::size_t field_id, Field_definition_tag) const
 do_for_each_field (const) helper More...
 
 Serializable ()=default
 
 Serializable (const Serializable &)=default
 
 Serializable (Serializable &&)=default
 
Serializableoperator= (const Serializable &)=default
 
Serializableoperator= (Serializable &&)=default
 
virtual ~Serializable ()=default
 Creation of Serializable objects is prohibited. More...
 

Private Attributes

Unknown_field_policy m_unknown_field_policy = Unknown_field_policy::ignore
 Unknown field policy for this serializable object. More...
 

Friends

template<class Serializer_derived_type , class Archive_type >
class Serializer
 
template<class Derived_serializable_type_current >
class Serializable
 

Detailed Description

template<class Derived_serializable_type>
class mysql::serialization::Serializable< Derived_serializable_type >

Interface for serializable data structures.

Classes that implement serializable interface may be serialized automatically by the serializer

Note
To be implemented by derived: decltype(auto) define_fields { return std::make_tuple(...); } const and non-const version

Please have a look at examples enclosed in unittest The base class provides:

  • methods to traverse through fields defined by the user in the Derived_serializable_type
  • methods to compute a compile-time upper bound on the size of message defined by the user in Derived_serializable_type
  • methods to compute the exact size of a particular message at runtime, taking into account the current values of fields defined by the user in the Derived_serializable_type Derived class should provide:
  • decltype(auto) define_fields { return std::make_tuple(...); } const defines fields to be encoded. To define fields, helpers defined in the "field_definition_helpers.h" shall be used. Sufficient information about the field is the field reference. The message designer can also define:
    • fixed size of an integer / upper bound of the string length
    • encode predicate, which will be called by the encoding functions to determine whether field should be encoded
    • an unknown_field_policy, defined by the encoder and applied by the decoder in case decoder does not recognize a field
  • decltype(auto) define_fields { return std::make_tuple(...); } defines fields to be decoded. To define fields, helpers defined in the "field_definition_helpers.h" shall be used. Sufficient information about the field is the field reference. The message designer can also define:
    • fixed size of an integer / upper bound of the string length
    • field missing functor, which will be called by the decoding functions in case field is not encoded in the message
    • an unknown_field_policy, defined by the encoder and applied by the decoder in case decoder does not recognize a field

Member Typedef Documentation

◆ Tag

template<class Derived_serializable_type >
using mysql::serialization::Serializable< Derived_serializable_type >::Tag = Serializable_tag
protected

Constructor & Destructor Documentation

◆ Serializable() [1/3]

template<class Derived_serializable_type >
mysql::serialization::Serializable< Derived_serializable_type >::Serializable ( )
protecteddefault

◆ Serializable() [2/3]

template<class Derived_serializable_type >
mysql::serialization::Serializable< Derived_serializable_type >::Serializable ( const Serializable< Derived_serializable_type > &  )
protecteddefault

◆ Serializable() [3/3]

template<class Derived_serializable_type >
mysql::serialization::Serializable< Derived_serializable_type >::Serializable ( Serializable< Derived_serializable_type > &&  )
protecteddefault

◆ ~Serializable()

template<class Derived_serializable_type >
virtual mysql::serialization::Serializable< Derived_serializable_type >::~Serializable ( )
protectedvirtualdefault

Creation of Serializable objects is prohibited.

Member Function Documentation

◆ do_for_each_field() [1/4]

template<class Derived_serializable_type >
template<class Serializable_functor_type , class Field_functor_type >
void mysql::serialization::Serializable< Derived_serializable_type >::do_for_each_field ( Serializable_functor_type &&  func_s,
Field_functor_type &&  func_f 
)

calls functor for each field

Template Parameters
Serializable_functor_typeType of functor to be applied on the serializable
Field_functor_typeType of functor to be applied on the field
Parameters
func_sFunctor to be called for each serializable field
func_fFunctor to be called for each non-serializable field

◆ do_for_each_field() [2/4]

template<class Derived_serializable_type >
template<class Serializable_functor_type , class Field_functor_type >
void mysql::serialization::Serializable< Derived_serializable_type >::do_for_each_field ( Serializable_functor_type &&  func_s,
Field_functor_type &&  func_f 
) const

calls functor for each field, const version

Template Parameters
Serializable_functor_typeType of functor to be applied on the serializable
Field_functor_typeType of functor to be applied on the field
Parameters
func_sFunctor to be called for each serializable field
func_fFunctor to be called for each non-serializable field

◆ do_for_each_field() [3/4]

template<class Derived_serializable_type >
template<class Serializable_functor_type , class Field_functor_type , class Tuple_type , std::size_t... Is>
void mysql::serialization::Serializable< Derived_serializable_type >::do_for_each_field ( Serializable_functor_type &&  func_s,
Field_functor_type &&  func_f,
Tuple_type &&  tuple,
std::index_sequence< Is... >   
)
protected

do_for_each_field helper

◆ do_for_each_field() [4/4]

template<class Derived_serializable_type >
template<class Serializable_functor_type , class Field_functor_type , class Tuple_type , std::size_t... Is>
void mysql::serialization::Serializable< Derived_serializable_type >::do_for_each_field ( Serializable_functor_type &&  func_s,
Field_functor_type &&  func_f,
Tuple_type &&  tuple,
std::index_sequence< Is... >   
) const
protected

do_for_each_field (const) helper

◆ do_for_one_field() [1/6]

template<class Derived_serializable_type >
template<class Serializable_functor_type , class Field_functor_type , class Field_type >
void mysql::serialization::Serializable< Derived_serializable_type >::do_for_one_field ( Serializable_functor_type &&  ,
Field_functor_type &&  func_f,
const Field_type field,
std::size_t  field_id,
Field_definition_tag   
) const
protected

do_for_each_field (const) helper

◆ do_for_one_field() [2/6]

template<class Derived_serializable_type >
template<class Serializable_functor_type , class Field_functor_type , class Field_type >
void mysql::serialization::Serializable< Derived_serializable_type >::do_for_one_field ( Serializable_functor_type &&  ,
Field_functor_type &&  func_f,
Field_type field,
std::size_t  field_id,
Field_definition_tag   
)
protected

do_for_each_field helper

◆ do_for_one_field() [3/6]

template<class Derived_serializable_type >
template<class Serializable_functor_type , class Field_functor_type , class Field_type >
void mysql::serialization::Serializable< Derived_serializable_type >::do_for_one_field ( Serializable_functor_type &&  func_s,
Field_functor_type &&  func_f,
const Field_type field,
std::size_t  field_id 
) const
protected

do_for_each_field (const) helper

◆ do_for_one_field() [4/6]

template<class Derived_serializable_type >
template<class Serializable_functor_type , class Field_functor_type , class Field_type >
void mysql::serialization::Serializable< Derived_serializable_type >::do_for_one_field ( Serializable_functor_type &&  func_s,
Field_functor_type &&  func_f,
const Field_type field,
std::size_t  field_id,
Serializable_tag   
) const
protected

do_for_each_field (const) helper

◆ do_for_one_field() [5/6]

template<class Derived_serializable_type >
template<class Serializable_functor_type , class Field_functor_type , class Field_type >
void mysql::serialization::Serializable< Derived_serializable_type >::do_for_one_field ( Serializable_functor_type &&  func_s,
Field_functor_type &&  func_f,
Field_type field,
std::size_t  field_id 
)
protected

do_for_each_field helper

◆ do_for_one_field() [6/6]

template<class Derived_serializable_type >
template<class Serializable_functor_type , class Field_functor_type , class Field_type >
void mysql::serialization::Serializable< Derived_serializable_type >::do_for_one_field ( Serializable_functor_type &&  func_s,
Field_functor_type &&  func_f,
Field_type field,
std::size_t  field_id,
Serializable_tag   
)
protected

do_for_each_field helper

◆ get_last_field_id()

template<class Derived_serializable_type >
static constexpr Field_id_type mysql::serialization::Serializable< Derived_serializable_type >::get_last_field_id ( )
inlinestaticconstexpr

This function calculates last field id of this type.

Returns
last field id

◆ get_max_size_internal()

template<class Derived_serializable_type >
template<typename Serializer_type >
static constexpr std::size_t mysql::serialization::Serializable< Derived_serializable_type >::get_max_size_internal ( )
inlinestaticconstexpr

Returns serializable object fields maximum size, internal function (without serializable metadata size)

Template Parameters
Serializer_typeType of serializer used to format fields object will have this maximum size
Returns
This class maximum declared size

◆ get_size_internal()

template<class Derived_serializable_type >
template<typename Serializer_type >
std::size_t mysql::serialization::Serializable< Derived_serializable_type >::get_size_internal

Returns serializable object fields size, internal function (without serializable metadata size)

Template Parameters
Serializer_typeType of serializer used to format fields overhead added by serializer, including overhead of nested types
Returns
Serializable internal size

◆ is_any_field_provided()

template<class Derived_serializable_type >
bool mysql::serialization::Serializable< Derived_serializable_type >::is_any_field_provided

Performs iteration over all of the serializable fields and checks whether any of the fields in this serializable is provided.

Returns
True in case any of the fields in all levels, starting from this one, is provided

◆ is_ignorable()

template<class Derived_serializable_type >
bool mysql::serialization::Serializable< Derived_serializable_type >::is_ignorable ( ) const
inline

◆ operator=() [1/2]

template<class Derived_serializable_type >
Serializable & mysql::serialization::Serializable< Derived_serializable_type >::operator= ( const Serializable< Derived_serializable_type > &  )
protecteddefault

◆ operator=() [2/2]

template<class Derived_serializable_type >
Serializable & mysql::serialization::Serializable< Derived_serializable_type >::operator= ( Serializable< Derived_serializable_type > &&  )
protecteddefault

◆ set_unknown_field_policy()

template<class Derived_serializable_type >
void mysql::serialization::Serializable< Derived_serializable_type >::set_unknown_field_policy ( const Unknown_field_policy policy)
inline

Sets unknown field policy for this object.

Parameters
policyChosen policy, determines what decoder should do in case it encounters this object in the stream but this object definition is unknown to the decoder

Friends And Related Function Documentation

◆ Serializable

template<class Derived_serializable_type >
template<class Derived_serializable_type_current >
friend class Serializable
friend

◆ Serializer

template<class Derived_serializable_type >
template<class Serializer_derived_type , class Archive_type >
friend class Serializer
friend

Member Data Documentation

◆ m_unknown_field_policy

template<class Derived_serializable_type >
Unknown_field_policy mysql::serialization::Serializable< Derived_serializable_type >::m_unknown_field_policy = Unknown_field_policy::ignore
private

Unknown field policy for this serializable object.


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