9#ifndef CLASSDESC_POLY_ACCESS_JSON_PACK_H
10#define CLASSDESC_POLY_ACCESS_JSON_PACK_H
14 struct ResetThrowOnErrorOnExit
18 ResetThrowOnErrorOnExit(
json_pack_t& x): x(x), prev(x.throw_on_error) {}
19 ~ResetThrowOnErrorOnExit() {x.throw_on_error=prev;}
22#ifdef CLASSDESC_POLYJSONBASE_H
26 json_pack_smart_ptr(
json_pack_t& x,
const string& d,
T& a,
43 json_pack_smart_ptr(
json_pack_t& x,
const string& d,
T& a,
50#ifdef CLASSDESC_POLYJSONBASE_H
53 public is_base_of<PolyJsonBase, typename T::element_type> {};
62 json_unpack_smart_ptr(json_unpack_t& x,
const string& d,
T& a,
65 if (x.type()==RESTProcessType::object && x.get_obj().count(
"type"))
67 typename T::element_type::Type type;
68 ::json_unpack(x,d+
".type",type);
69 a.reset(T::element_type::create(type));
82 json_unpack_smart_ptr(
json_pack_t& x,
const string& d,
T& a,
86 a.reset(
new typename T::element_type);
89 ::json_unpack(x,d,*a);
91 catch (
const std::exception&)
102 json_unpack_smart_ptr(
json_pack_t& x,
const string& d,
T& a,
117 void operator()(cd::json_pack_t& x,
const cd::string& d, U& a)
118 {json_pack_smart_ptr(x,d,a);}
125 void operator()(cd::json_unpack_t& x,
const cd::string& d, U& a)
126 {json_unpack_smart_ptr(x,d,a);}
133 void operator()(cd::json_pack_t& x,
const cd::string& d, U& a)
135 if (cd::shared_ptr<T> sp=a.lock())
136 json_pack_smart_ptr(x,d,sp);
144 void operator()(cd::json_unpack_t& x,
const cd::string& d, U& a)
146 if (cd::shared_ptr<T> sp=a.lock())
147 json_unpack_smart_ptr(x,d,sp);
151#if defined(__cplusplus) && __cplusplus<=201402
152#if defined(__GNUC__) && !defined(__ICC) && !defined(__clang__)
153#pragma GCC diagnostic push
154#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
159 void operator()(cd::json_pack_t& x,
const cd::string& d,
161 {json_pack_smart_ptr(x,d,a);}
167 void operator()(cd::json_unpack_t& x,
const cd::string& d,
169 {json_unpack_smart_ptr(x,d,a);}
171#if defined(__GNUC__) && !defined(__ICC) && !defined(__clang__)
172#pragma GCC diagnostic pop
176#if defined(__cplusplus) && __cplusplus >= 201103L
177 template <
class T,
class D>
180 void operator()(cd::json_pack_t& x,
const cd::string& d,
181 std::unique_ptr<T,D>& a)
182 {json_pack_smart_ptr(x,d,a);}
185 template <
class T,
class D>
188 void operator()(cd::json_unpack_t& x,
const cd::string& d,
189 std::unique_ptr<T,D>& a)
190 {json_unpack_smart_ptr(x,d,a);}
Definition json_pack_base.h:99
Contains access_* structs, and nothing else. These structs are used to gain access to private members...
Definition classdesc_access.h:20
Contains definitions related to classdesc functionality.
void json_pack(json_pack_t &o, const string &d, T &a)
forward declare generic json operations
Definition json_pack_epilogue.h:61
Definition classdesc.h:420
Definition classdesc.h:405
Definition polyAccessJsonPack.h:15
Definition classdesc.h:299
controlled template specialisation: stolen from boost::enable_if.
Definition classdesc.h:282
Definition polyAccessJsonPack.h:56
Definition json_pack_epilogue.h:92
Definition json_pack_epilogue.h:104