9 #ifndef POLY_ACCESS_JSON_PACK_H
10 #define POLY_ACCESS_JSON_PACK_H
26 json_pack_smart_ptr(
json_pack_t& x,
const string& d, T& a,
38 typename enable_if<Not<is_base_of<PolyJsonBase, typename T::element_type> >,
void>::T
43 json_pack_smart_ptr(json_pack_t& x,
const string& d, T& a,
53 typename enable_if<is_base_of<PolyJsonBase, typename T::element_type>,
55 json_unpack_smart_ptr(json_unpack_t& x,
const string& d, T& a,
58 if (x.type()==json_spirit::obj_type && x.get_obj().count(
"type"))
60 typename T::element_type::Type type;
61 ::json_unpack(x,d+
".type",type);
62 a.reset(T::element_type::create(type));
71 typename enable_if<Not<is_base_of<PolyJsonBase, typename T::element_type> >,
77 json_unpack_smart_ptr(json_pack_t& x,
const string& d, T& a,
80 ResetThrowOnErrorOnExit r(x);
81 a.reset(
new typename T::element_type);
84 ::json_unpack(x,d,*a);
86 catch (
const std::exception&)
95 namespace classdesc_access
97 namespace cd=classdesc;
102 cd::shared_ptr<T>& a)
103 {json_pack_smart_ptr(x,d,a);}
110 cd::shared_ptr<T>& a)
111 {json_unpack_smart_ptr(x,d,a);}
119 {json_pack_smart_ptr(x,d,a);}
127 {json_unpack_smart_ptr(x,d,a);}
130 #if defined(__cplusplus) && __cplusplus >= 201103L
131 template <
class T,
class D>
135 std::unique_ptr<T,D>& a)
136 {json_pack_smart_ptr(x,d,a);}
139 template <
class T,
class D>
140 struct access_json_unpack<std::unique_ptr<T,D> >
143 std::unique_ptr<T,D>& a)
144 {json_unpack_smart_ptr(x,d,a);}
Definition: json_pack_base.h:37
Definition: polyAccessJsonPack.h:14
bool throw_on_error
enable exceptions on error conditions
Definition: json_pack_base.h:40
Definition: classdesc_access.h:26
void json_pack(json_pack_t &o, const string &d, T &a)
forward declare generic json operations
Definition: json_pack_epilogue.h:53
Definition: classdesc_access.h:25
controlled template specialisation: stolen from boost::enable_if.
Definition: classdesc.h:274
Definition: classdesc.h:291