Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
variant.hpp
Go to the documentation of this file.
1#pragma once
4
5namespace fc
6{
7 template<typename T>
8 void to_variant( const T& o, variant& v );
9 template<typename T>
10 void from_variant( const variant& v, T& o );
11
12
13 template<typename T>
15 {
16 public:
18 :vo(mvo),val(v){}
19
20 template<typename Member, class Class, Member (Class::*member)>
21 void operator()( const char* name )const
22 {
23 this->add(vo,name,(val.*member));
24 }
25
26 private:
27 template<typename M>
28 void add( mutable_variant_object& vo, const char* name, const std::optional<M>& v )const
29 {
30 if( v )
31 vo(name,*v);
32 }
33 template<typename M>
34 void add( mutable_variant_object& vo, const char* name, const M& v )const
35 { vo(name,v); }
36
37 mutable_variant_object& vo;
38 const T& val;
39 };
40
41 template<typename T>
43 {
44 public:
47 ,vo(_vo){}
48
49 template<typename Member, class Class, Member (Class::*member)>
50 void operator()( const char* name )const
51 {
52 auto itr = vo.find(name);
53 if( itr != vo.end() )
54 from_variant( itr->value(), this->obj.*member );
55 }
56
58 };
59
60 template<typename IsReflected=fc::false_type>
61 struct if_enum
62 {
63 template<typename T>
64 static inline void to_variant( const T& v, fc::variant& vo )
65 {
68 vo = fc::move(mvo);
69 }
70 template<typename T>
71 static inline void from_variant( const fc::variant& v, T& o )
72 {
73 const variant_object& vo = v.get_object();
75 }
76 };
77
78 template<>
80 {
81 template<typename T>
82 static inline void to_variant( const T& o, fc::variant& v )
83 {
85 }
86 template<typename T>
87 static inline void from_variant( const fc::variant& v, T& o )
88 {
89 if( v.is_string() )
91 else
93 }
94 };
95
96
97 template<typename T>
98 void to_variant( const T& o, variant& v )
99 {
101 }
102
103 template<typename T>
108
109}
std::string name
void operator()(const char *name) const
Definition variant.hpp:50
from_variant_visitor(const variant_object &_vo, T &v)
Definition variant.hpp:45
const variant_object & vo
Definition variant.hpp:57
An order-preserving dictionary of variants.
void operator()(const char *name) const
Definition variant.hpp:21
to_variant_visitor(mutable_variant_object &mvo, const T &v)
Definition variant.hpp:17
An order-preserving dictionary of variants.
iterator end() const
iterator find(const string &key) const
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
Definition variant.hpp:191
variant_object & get_object()
Definition variant.cpp:554
const string & get_string() const
Definition variant.cpp:606
int64_t as_int64() const
Definition variant.cpp:377
bool is_string() const
Definition variant.cpp:314
namespace sysio::chain
Definition authority.cpp:3
void from_variant(const fc::variant &v, sysio::chain::chain_id_type &cid)
void to_variant(const sysio::chain::shared_public_key &var, fc::variant &vo)
Definition authority.cpp:4
#define T(meth, val, expected)
static void to_variant(const T &o, fc::variant &v)
Definition variant.hpp:82
static void from_variant(const fc::variant &v, T &o)
Definition variant.hpp:87
static void from_variant(const fc::variant &v, T &o)
Definition variant.hpp:71
static void to_variant(const T &v, fc::variant &vo)
Definition variant.hpp:64
defines visit functions for T Unless this is specialized, visit() will not be defined for T.
Definition reflect.hpp:33