MySQL 8.4.2
Source Code Documentation
|
Interface for serializer. More...
#include <serializer.h>
Public Types | |
using | Serializer_current_type = Serializer< Serializer_derived_type, Archive_type > |
Public Member Functions | |
bool | is_error () const |
bool | is_good () const |
const Serialization_error & | get_error () |
template<typename T > | |
Serializer_current_type & | operator<< (const T &arg) |
Function for the API user to serialize data. More... | |
template<typename T > | |
Serializer_current_type & | operator>> (T &arg) |
Function for the API user to serialize data. More... | |
Archive_type & | get_archive () |
Function for the API user to access reference of the archive. More... | |
template<typename T > | |
Serializer< Serializer_derived_type, Archive_type > & | operator<< (const T &arg) |
template<typename T > | |
Serializer< Serializer_derived_type, Archive_type > & | operator>> (T &arg) |
Static Public Member Functions | |
template<typename T > | |
static std::size_t | get_size (const T &arg) |
Protected Member Functions | |
Serializer_derived_type * | get_derived () |
Casts this to derived type. More... | |
template<class Field_type , Field_size field_size_defined> | |
void | encode_field (Level_type level, Field_id_type field_id, const Field_definition< Field_type, field_size_defined > &field_definition) |
Function used to encode one field. More... | |
template<class Field_type , Field_size field_size_defined> | |
void | decode_field (Level_type level, Field_id_type field_id, std::size_t serializable_end_pos, Field_definition< Field_type, field_size_defined > &field_definition) |
Function used to decode one field. More... | |
template<class Serializable_type > | |
void | encode_serializable (Level_type level, Field_id_type field_id, const Serializable_type &serializable, bool skip_id) |
Function used to encode serializable field, this function saves serializable metadata and calls serializable encode method. More... | |
template<class Serializable_type > | |
void | encode_serializable_fields (const Serializable_type &serializable, Level_type level) |
Function used to encode fields of specializations of Serializable class, iterates over constant fields allowing them to be saved into an archive. More... | |
template<class Serializable_type > | |
void | decode_serializable (Level_type level, Field_id_type field_id, std::size_t serializable_end_pos, Serializable_type &serializable, bool skip_id) |
Function used to decode serializable field, this function loads serializable metadata and calls serializable decode method. More... | |
template<class Serializable_type > | |
void | decode_serializable_fields (Serializable_type &serializable, Level_type level, std::size_t serializable_end_pos) |
Function used to decode fields of specializations of Serializable class, iterates over non constant fields, allowing them to be filled with data from an archive. More... | |
void | clear_error () |
virtual | ~Serializer ()=default |
Destructor. More... | |
Static Protected Member Functions | |
template<class Field_type , Field_size field_size_defined> | |
static std::size_t | get_size_field_def (Field_id_type field_id, const Field_definition< Field_type, field_size_defined > &field_definition) |
Function returns size of field object written to an archive. More... | |
template<class Serializable_concrete_type > | |
static std::size_t | get_size_serializable (Field_id_type field_id, const Serializable_concrete_type &serializable, bool skip_id=false) |
Function returns size of serializable object written to an archive. More... | |
template<class Field_type , Field_size field_size_defined> | |
static constexpr std::size_t | get_max_size () |
Function returns maximum size of the field written to an archive, based on its type. More... | |
template<class Serializable_concrete_type > | |
static constexpr std::size_t | get_max_size () |
Function returns maximum size of the Serializable_concrete_type class object data written to an archive, based on its type. More... | |
Protected Attributes | |
Level_type | m_level {0} |
Level of the serializable tree. More... | |
Archive_type | m_archive |
Archive that stores the data. More... | |
Serialization_error | m_error |
Holds information about error. More... | |
Friends | |
template<typename Serializable_derived_current_type > | |
class | Serializable |
template<typename Serializer_type , typename Type > | |
struct | Serializable_size_calculator_helper |
Interface for serializer.
This class provides functionality of encoder and decoder, storing the formatted data in the defined Archive_type. This class converts a hierarchical message (Serializable type) into a linear sequence of message boundaries and fields (with the usage of Serializable interface). To do so, it traverses the message in depth-first order and applies the user-defined predicates to determine if a field should be included in encoded message or not. Field ids are generated during iteration over fields with the usage of the Serializable interface. Particular message boundaries formatting and fields formatting is decided by the Serializer_derived_type. The methods that Serializer_derived_type shall provide are explicitly marked in methods documentation as "to be implemented by Serializer_derived_type". Derived class shall provide a specific formatting of message boundaries, specific formatting of particular fields and size calculation methods (get_size_serializable, get_size_field_def, get_max_size for simple/complex fields)
Serializer_derived_type | Concrete Serializer type, this is CRTP |
Archive_type | Concrete archive type to store data |
using mysql::serialization::Serializer< Serializer_derived_type, Archive_type >::Serializer_current_type = Serializer<Serializer_derived_type, Archive_type> |
|
protectedvirtualdefault |
Destructor.
|
inlineprotected |
|
protected |
Function used to decode one field.
Field_type | Type of field |
field_size_defined | Defined field size in archive |
[in] | level | Level of the serializable tree, may be ignored, used mainly for text formatting |
[in] | field_id | Expected field id |
[in] | serializable_end_pos | End position of current serializable type |
[in] | field_definition | Definition of the field |
|
protected |
Function used to decode serializable field, this function loads serializable metadata and calls serializable decode method.
Serializable_type | serializable data type |
[in] | level | Level of the serializable tree, may be ignored, used mainly for text formatting |
[in] | field_id | Field id |
[in] | serializable_end_pos | End position of current serializable type |
[in] | serializable | Serializable object universal reference |
[in] | skip_id | Skip decoding of serializable id. In case a field is placed in a container, we skip encoding / decoding of the field id. Field id encoding / decoding is skipped in case field_id was already processed or a complex type is put in the container |
|
protected |
Function used to decode fields of specializations of Serializable class, iterates over non constant fields, allowing them to be filled with data from an archive.
Serializable_type | serializable data type |
[in] | serializable | Serializable object universal reference |
[in] | level | Serializable tree level, serializable may contain other serializable fields, level is used for informational purpose or additional text formatting for nested types |
[in] | serializable_end_pos | End position of current serializable type |
|
protected |
Function used to encode one field.
Field_type | Type of field |
field_size_defined | Defined field size in archive |
[in] | level | Level of the serializable tree, may be ignored, used mainly for text formatting |
[in] | field_id | Field id |
[in] | field_definition | Definition of the field |
|
protected |
Function used to encode serializable field, this function saves serializable metadata and calls serializable encode method.
Serializable_type | serializable data type |
[in] | level | Level of the serializable tree, may be ignored, used mainly for text formatting |
[in] | field_id | Field id |
[in] | serializable | Serializable object universal reference |
[in] | skip_id | Skip encoding of serializable id (for repeated fields) |
|
protected |
Function used to encode fields of specializations of Serializable class, iterates over constant fields allowing them to be saved into an archive.
Serializable_type | serializable data type |
[in] | serializable | Serializable object universal reference |
[in] | level | Serializable tree level, serializable may contain other serializable fields, level is used for informational purpose or additional text formatting for nested types |
Archive_type & mysql::serialization::Serializer< Serializer_derived_type, Archive_type >::get_archive |
Function for the API user to access reference of the archive.
|
inlineprotected |
Casts this to derived type.
|
inline |
|
inlinestaticconstexprprotected |
Function returns maximum size of the field written to an archive, based on its type.
Field_type | Type of field |
field_size_defined | Defined field size in archive |
|
inlinestaticconstexprprotected |
Function returns maximum size of the Serializable_concrete_type class object data written to an archive, based on its type.
Serializable_concrete_type | Type of serializable obj |
|
static |
|
staticprotected |
Function returns size of field object written to an archive.
Field_type | Type of field |
field_size_defined | Defined field size in archive |
[in] | field_id | Field id |
[in] | field_definition | Definition of the field |
|
staticprotected |
Function returns size of serializable object written to an archive.
Serializable_concrete_type | Type of serializable obj |
[in] | field_id | Field id |
[in] | serializable | Serializable universal reference for which size will be calculated |
[in] | skip_id | Skip serializable id (for repeated fields) |
|
inline |
|
inline |
Serializer_current_type & mysql::serialization::Serializer< Serializer_derived_type, Archive_type >::operator<< | ( | const T & | arg | ) |
Function for the API user to serialize data.
T | Serialized type, implementing Serializable interface |
[in] | arg | Data to be written into the archive |
Serializer< Serializer_derived_type, Archive_type > & mysql::serialization::Serializer< Serializer_derived_type, Archive_type >::operator<< | ( | const T & | arg | ) |
Serializer_current_type & mysql::serialization::Serializer< Serializer_derived_type, Archive_type >::operator>> | ( | T & | arg | ) |
Function for the API user to serialize data.
T | Serialized type, implementing Serializable interface |
[in] | arg | Deserialized data will be stored in arg |
Serializer< Serializer_derived_type, Archive_type > & mysql::serialization::Serializer< Serializer_derived_type, Archive_type >::operator>> | ( | T & | arg | ) |
|
friend |
|
friend |
|
protected |
Archive that stores the data.
|
protected |
Holds information about error.
|
protected |
Level of the serializable tree.