Botcraft 26.3
Loading...
Searching...
No Matches
ProtocolCraft::Internal::DynamicType< BaseType, TypeField, Factory > Struct Template Reference

A dynamic field that can hold different data inheriting a common BaseType (derived from NetworkType). More...

#include <DynamicType.hpp>

Static Public Member Functions

template<typename C >
static std::shared_ptr< BaseType > Read (const C *c, std::vector< unsigned char >::const_iterator &iter, size_t &length)
 
template<typename C >
static void Write (const C *c, const std::shared_ptr< BaseType > &val, std::vector< unsigned char > &container)
 
template<typename C >
static std::optional< Json::Value > Serialize (const C *c, const std::shared_ptr< BaseType > &val)
 

Detailed Description

template<typename BaseType, auto TypeField, auto Factory>
struct ProtocolCraft::Internal::DynamicType< BaseType, TypeField, Factory >

A dynamic field that can hold different data inheriting a common BaseType (derived from NetworkType).

Cannot be used inside a container like a vector

Template Parameters
BaseTypeCommon base class of every possible data type
TypeFieldPointer to the type field (e.g. &MyNetworkClass::Type)
FactoryFunction pointer. Should have a signature std::shared_ptr<Base>(TypeValue)

Definition at line 19 of file DynamicType.hpp.

Member Function Documentation

◆ Read()

template<typename BaseType , auto TypeField, auto Factory>
template<typename C >
static std::shared_ptr< BaseType > ProtocolCraft::Internal::DynamicType< BaseType, TypeField, Factory >::Read ( const C *  c,
std::vector< unsigned char >::const_iterator &  iter,
size_t &  length 
)
inlinestatic

Definition at line 22 of file DynamicType.hpp.

◆ Serialize()

template<typename BaseType , auto TypeField, auto Factory>
template<typename C >
static std::optional< Json::Value > ProtocolCraft::Internal::DynamicType< BaseType, TypeField, Factory >::Serialize ( const C *  c,
const std::shared_ptr< BaseType > &  val 
)
inlinestatic

Definition at line 69 of file DynamicType.hpp.

◆ Write()

template<typename BaseType , auto TypeField, auto Factory>
template<typename C >
static void ProtocolCraft::Internal::DynamicType< BaseType, TypeField, Factory >::Write ( const C *  c,
const std::shared_ptr< BaseType > &  val,
std::vector< unsigned char > &  container 
)
inlinestatic

Definition at line 55 of file DynamicType.hpp.


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