Kagome
Polkadot Runtime Engine in C++17
kagome::common::VariantBuilder< Variant, Types > Class Template Reference

#include <variant_builder.hpp>

Collaboration diagram for kagome::common::VariantBuilder< Variant, Types >:

Public Member Functions

 VariantBuilder (Variant &v)
 
void init (size_t index)
 

Private Attributes

Variant & v_
 
std::vector< std::function< void(Variant &)> > funcs_
 

Detailed Description

template<typename Variant, typename Types = typename Variant::types>
class kagome::common::VariantBuilder< Variant, Types >

Constructs a value inside boost::variant by type index from variant's definition at runtime.

Allows operating with variants as easy as converting an int to enum value but with more complex types than in enums.

No need to explicitly specify types below, compiler infers them from constructor

Template Parameters
Varianttype defenition of boost::variant
Typestypes held inside Variant

Definition at line 75 of file variant_builder.hpp.

Constructor & Destructor Documentation

template<typename Variant , typename Types = typename Variant::types>
kagome::common::VariantBuilder< Variant, Types >::VariantBuilder ( Variant &  v)
inlineexplicit
Parameters
vboost::variant variable to initialize

Definition at line 81 of file variant_builder.hpp.

Member Function Documentation

template<typename Variant , typename Types = typename Variant::types>
void kagome::common::VariantBuilder< Variant, Types >::init ( size_t  index)
inline

Initializes the referenced variant with default constructed instance of object of type at

Parameters
indexwithin
Template Parameters
Variant::types
Parameters
indexindex of type

Definition at line 93 of file variant_builder.hpp.

Member Data Documentation

template<typename Variant , typename Types = typename Variant::types>
std::vector<std::function<void(Variant &)> > kagome::common::VariantBuilder< Variant, Types >::funcs_
private

Definition at line 77 of file variant_builder.hpp.

template<typename Variant , typename Types = typename Variant::types>
Variant& kagome::common::VariantBuilder< Variant, Types >::v_
private

Definition at line 76 of file variant_builder.hpp.


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