MySQL 8.4.2
Source Code Documentation
mysql::serialization::Archive< Archive_derived_type > Class Template Reference

Interface for archives (file archive, byte vector archive, string archive etc.), available only to instances implementing Serializable interface and Archive interface. More...

#include <archive.h>

Public Member Functions

template<typename Type >
Archive_derived_type & operator<< (Type &&arg)
 Ingests argument into this archive. More...
 
template<typename Type >
Archive_derived_type & operator>> (Type &&arg)
 Reads argument from this archive. More...
 
decltype(auto) get_raw_data ()
 Function for the API user to access data in the archive. More...
 
std::size_t get_size_written () const
 Returns archive size - size of data written to the archive. More...
 
virtual void put_field_separator ()
 This method needs to define field separator to be inserted after the field, note that some formats won't contain separators Used mainly for text formatters. More...
 
virtual void put_entry_separator ()
 This method needs to define field entry separator to be inserted after the field entry, note that some formats won't contain separators Used mainly for text formatters. More...
 
virtual void put_level_separator ()
 This method needs to define level separator to be inserted after the level, note that some formats won't contain separators Used mainly for text formatters. More...
 
virtual void process_field_separator ()
 This method needs to define how to process field separator during decoding. More...
 
virtual void process_entry_separator ()
 This method needs to define how to process field entry separator during decoding. More...
 
virtual void process_level_separator ()
 This method needs to define how to process level separator during decoding. More...
 

Static Public Member Functions

template<typename Type >
static std::size_t get_size (Type &&arg)
 Function returns size of serialized argument. More...
 
template<typename Type >
static constexpr std::size_t get_max_size ()
 Function returns maximum size of the Type. More...
 

Protected Member Functions

const Archive_derived_type * get_derived_const ()
 Casts this to derived type. More...
 
Archive_derived_type * get_derived ()
 Casts this to derived type. More...
 
Field_id_type peek_type_field_id ()
 This method decodes field id, without moving stream positions. More...
 
template<class Field_type >
void peek (Field_type &&field)
 Peeks selected field wrapper (reads data without updating read stream position) More...
 
void seek_to (std::size_t num_pos)
 Moves the current read position to current position + size. More...
 
std::size_t get_read_pos () const
 Gets current read pos. More...
 
bool is_error () const
 
bool is_good () const
 
const Serialization_errorget_error ()
 
void clear_error ()
 
virtual ~Archive ()=default
 Destructor. More...
 

Protected Attributes

Serialization_error m_error
 Holds information about error. More...
 

Friends

template<class Serializer_derived_current_type , class Archive_current_type >
class Serializer
 

Detailed Description

template<class Archive_derived_type>
class mysql::serialization::Archive< Archive_derived_type >

Interface for archives (file archive, byte vector archive, string archive etc.), available only to instances implementing Serializable interface and Archive interface.

Archive is responsible for primitive types byte-level formatting and data storage. It also provides implementation of separation between serializable types, serializable type fields, separate entries in containers (repeated fields). Derived class should implement all methods of provided interface (except methods for error handling).

Template Parameters
Archive_derived_typeArchive derived that is implementing Archive interface (CRTP)

Constructor & Destructor Documentation

◆ ~Archive()

template<class Archive_derived_type >
virtual mysql::serialization::Archive< Archive_derived_type >::~Archive ( )
protectedvirtualdefault

Destructor.

Note
Cannot create an object of 'abstract' Archive type

Member Function Documentation

◆ clear_error()

template<class Archive_derived_type >
void mysql::serialization::Archive< Archive_derived_type >::clear_error ( )
inlineprotected

◆ get_derived()

template<class Archive_derived_type >
Archive_derived_type * mysql::serialization::Archive< Archive_derived_type >::get_derived ( )
inlineprotected

Casts this to derived type.

Returns
Derived class pointer to this
Note
To be implemented in Archive_derived_type

◆ get_derived_const()

template<class Archive_derived_type >
const Archive_derived_type * mysql::serialization::Archive< Archive_derived_type >::get_derived_const ( )
inlineprotected

Casts this to derived type.

Returns
Derived class pointer to this
Note
To be implemented in Archive_derived_type

◆ get_error()

template<class Archive_derived_type >
const Serialization_error & mysql::serialization::Archive< Archive_derived_type >::get_error ( )
inlineprotected

◆ get_max_size()

template<class Archive_derived_type >
template<typename Type >
static constexpr std::size_t mysql::serialization::Archive< Archive_derived_type >::get_max_size ( )
inlinestaticconstexpr

Function returns maximum size of the Type.

Template Parameters
Typeserialized type
Returns
maximum size of the Type in the stream
Note
To be implemented in Archive_derived_type

◆ get_raw_data()

template<class Archive_derived_type >
decltype(auto) mysql::serialization::Archive< Archive_derived_type >::get_raw_data ( )
inline

Function for the API user to access data in the archive.

Returns
Archive data, defined in the Archive (e.g. pointer to bytes ...)
Note
To be implemented in Archive_derived_type

◆ get_read_pos()

template<class Archive_derived_type >
std::size_t mysql::serialization::Archive< Archive_derived_type >::get_read_pos ( ) const
inlineprotected

Gets current read pos.

Returns
Current read pos
Note
To be implemented in Archive_derived_type

◆ get_size()

template<class Archive_derived_type >
template<typename Type >
static std::size_t mysql::serialization::Archive< Archive_derived_type >::get_size ( Type &&  arg)
inlinestatic

Function returns size of serialized argument.

Template Parameters
Typetype of the argument
Parameters
[in]argserialized argument
Returns
size of serialized argument
Note
To be implemented in Archive_derived_type

◆ get_size_written()

template<class Archive_derived_type >
std::size_t mysql::serialization::Archive< Archive_derived_type >::get_size_written ( ) const
inline

Returns archive size - size of data written to the archive.

Returns
archive size - size of data written to the archive
Note
To be implemented in Archive_derived_type

◆ is_error()

template<class Archive_derived_type >
bool mysql::serialization::Archive< Archive_derived_type >::is_error ( ) const
inlineprotected

◆ is_good()

template<class Archive_derived_type >
bool mysql::serialization::Archive< Archive_derived_type >::is_good ( ) const
inlineprotected

◆ operator<<()

template<class Archive_derived_type >
template<typename Type >
Archive_derived_type & mysql::serialization::Archive< Archive_derived_type >::operator<< ( Type &&  arg)
inline

Ingests argument into this archive.

Template Parameters
Typetype of the argument
Parameters
[in]argArgument to read data from
Returns
This archive reference
Note
To be implemented in Archive_derived_type

◆ operator>>()

template<class Archive_derived_type >
template<typename Type >
Archive_derived_type & mysql::serialization::Archive< Archive_derived_type >::operator>> ( Type &&  arg)
inline

Reads argument from this archive.

Template Parameters
Typetype of the argument
Parameters
[in]argArgument to store data into
Returns
This archive reference
Note
To be implemented in Archive_derived_type

◆ peek()

template<class Archive_derived_type >
template<class Field_type >
void mysql::serialization::Archive< Archive_derived_type >::peek ( Field_type &&  field)
inlineprotected

Peeks selected field wrapper (reads data without updating read stream position)

Note
To be implemented in Archive_derived_type

◆ peek_type_field_id()

template<class Archive_derived_type >
Field_id_type mysql::serialization::Archive< Archive_derived_type >::peek_type_field_id ( )
inlineprotected

This method decodes field id, without moving stream positions.

Returns
Serialized field id
Note
To be implemented in Archive_derived_type

◆ process_entry_separator()

template<class Archive_derived_type >
virtual void mysql::serialization::Archive< Archive_derived_type >::process_entry_separator ( )
inlinevirtual

This method needs to define how to process field entry separator during decoding.

Used mainly for text formatters

Each field may have a several entries (e.g. vector)

◆ process_field_separator()

template<class Archive_derived_type >
virtual void mysql::serialization::Archive< Archive_derived_type >::process_field_separator ( )
inlinevirtual

This method needs to define how to process field separator during decoding.

Used mainly for text formatters

Field is defined a a single field in object of serializable class

◆ process_level_separator()

template<class Archive_derived_type >
virtual void mysql::serialization::Archive< Archive_derived_type >::process_level_separator ( )
inlinevirtual

This method needs to define how to process level separator during decoding.

Used mainly for text formatters

Each field that is an object of serializable class creates a new level

◆ put_entry_separator()

template<class Archive_derived_type >
virtual void mysql::serialization::Archive< Archive_derived_type >::put_entry_separator ( )
inlinevirtual

This method needs to define field entry separator to be inserted after the field entry, note that some formats won't contain separators Used mainly for text formatters.

Each field may have a several entries (e.g. vector)

Reimplemented in mysql::serialization::Archive_text.

◆ put_field_separator()

template<class Archive_derived_type >
virtual void mysql::serialization::Archive< Archive_derived_type >::put_field_separator ( )
inlinevirtual

This method needs to define field separator to be inserted after the field, note that some formats won't contain separators Used mainly for text formatters.

Field is defined a a single field in object of serializable class

Reimplemented in mysql::serialization::Archive_text.

◆ put_level_separator()

template<class Archive_derived_type >
virtual void mysql::serialization::Archive< Archive_derived_type >::put_level_separator ( )
inlinevirtual

This method needs to define level separator to be inserted after the level, note that some formats won't contain separators Used mainly for text formatters.

Each field that is an object of serializable class creates a new level

Reimplemented in mysql::serialization::Archive_text.

◆ seek_to()

template<class Archive_derived_type >
void mysql::serialization::Archive< Archive_derived_type >::seek_to ( std::size_t  num_pos)
inlineprotected

Moves the current read position to current position + size.

Parameters
[in]num_posNumber of positions to be skipped
Note
To be implemented in Archive_derived_type

Friends And Related Function Documentation

◆ Serializer

template<class Archive_derived_type >
template<class Serializer_derived_current_type , class Archive_current_type >
friend class Serializer
friend

Member Data Documentation

◆ m_error

template<class Archive_derived_type >
Serialization_error mysql::serialization::Archive< Archive_derived_type >::m_error
protected

Holds information about error.


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