5#include "system/shared_ptr.h"
17template<
typename S,
typename T>
31template <
typename G,
typename S>
46template <
typename G,
typename S>
61template <
typename G,
typename S>
76template <
typename G,
typename S>
92template <
typename G,
typename S,
typename T>
106#define PROP_ASSIGN_LAMBDA_WRAP(name, op) \
107 template <typename G, typename S, typename T> \
108 auto setter_##name##_wrap(G&& getter, S&& setter, T value) \
110 auto tmp = getter(); \
111 tmp = tmp op value; \
116PROP_ASSIGN_LAMBDA_WRAP(add, + )
117PROP_ASSIGN_LAMBDA_WRAP(sub, - )
118PROP_ASSIGN_LAMBDA_WRAP(mul, * )
119PROP_ASSIGN_LAMBDA_WRAP(div, / )
120PROP_ASSIGN_LAMBDA_WRAP(mod, % )
121PROP_ASSIGN_LAMBDA_WRAP(shl, << )
122PROP_ASSIGN_LAMBDA_WRAP(shr, >> )
123PROP_ASSIGN_LAMBDA_WRAP(and, & )
124PROP_ASSIGN_LAMBDA_WRAP(or, | )
125PROP_ASSIGN_LAMBDA_WRAP(exor, ^ )
130#define SETTER_LVAL_LAMBDA(capture, prop) \
131 [obj = capture](const auto& v){ obj->set_##prop(v); }
135#define GETTER_LVAL_LAMBDA(capture, prop) \
136 [obj = capture]{ return obj->get_##prop(); }
140#if __GNUC__ > 5 && __GNUC__ < 7
141#define SETTER_LAMBDA(capture, prop) \
142 SETTER_LVAL_LAMBDA(capture, prop)
144#define SETTER_LAMBDA(capture, prop) \
145 [&obj = capture](const auto& v){ obj->set_##prop(v); }
150#if __GNUC__ > 5 && __GNUC__ < 7
151#define GETTER_LAMBDA(capture, prop) \
152 GETTER_LVAL_LAMBDA(capture, prop)
154#define GETTER_LAMBDA(capture, prop) \
155 [&obj = capture]{ return obj->get_##prop(); }
160#define SETTER_REF_LAMBDA(capture, prop) \
161 [&obj = capture](const auto& v){ obj.set_##prop(v); }
165#define GETTER_REF_LAMBDA(capture, prop) \
166 [&obj = capture]{ return obj.get_##prop(); }
169#define SETTER_THIS_LAMBDA(prop) \
170 [this](const auto& v){ this->set_##prop(v); }
173#define GETTER_THIS_LAMBDA(prop) \
174 [this]{ return this->get_##prop(); }
178#define STATIC_SETTER_LAMBDA(T, prop) \
179 [](const auto& v){ T::set_##prop(v); }
183#define STATIC_GETTER_LAMBDA(T, prop) \
184 []{ return T::get_##prop(); }
188#define GETTER_SETTER_LAMBDA_ARGS(capture, prop) \
189 GETTER_LAMBDA(capture, prop), SETTER_LAMBDA(capture, prop)
192#define GETTER_SETTER_THIS_LAMBDA_ARGS(prop) \
193 GETTER_THIS_LAMBDA(prop), SETTER_THIS_LAMBDA(prop)
197#define GETTER_SETTER_REF_LAMBDA_ARGS(capture, prop) \
198 GETTER_REF_LAMBDA(capture, prop), SETTER_REF_LAMBDA(capture, prop)
202#define GETTER_SETTER_LVAL_LAMBDA_ARGS(capture, prop) \
203 GETTER_LVAL_LAMBDA(capture, prop), SETTER_LVAL_LAMBDA(capture, prop)
207#define STATIC_GETTER_SETTER_LAMBDA_ARGS(T, prop) \
208 STATIC_GETTER_LAMBDA(T, prop), STATIC_SETTER_LAMBDA(T, prop)
215#define SETTER_LAMBDA_OP_WRAP(T, obj, prop, op, val) \
216 setter_##op##_wrap(GETTER_SETTER_LAMBDA_ARGS(obj, prop), val)
220#define INDEXED_SETTER_LAMBDA(capture) \
221 [&obj = capture](auto&& index, auto&& value){ obj->idx_set(index, value); }
224#define INDEXED_GETTER_LAMBDA(capture) \
225 [&obj = capture](auto&& index){ return obj->idx_get(index); }
229#define INDEXED_GETTER_SETTER_ARGS(capture, arg) \
230 INDEXED_GETTER_LAMBDA(capture), INDEXED_SETTER_LAMBDA(capture), [&](){ return arg; }
234#define INDEXED_ASSIGN_LAMBDA_WRAP(name, op) \
235 template <typename G, typename S, typename I, typename T> \
236 void indexed_##name##_wrap(G&& getter, S&& setter, I&& indexer, T&& value) \
238 const auto index = indexer(); \
239 auto tmp = getter(index); \
241 setter(index, tmp); \
244INDEXED_ASSIGN_LAMBDA_WRAP(add, +=)
245INDEXED_ASSIGN_LAMBDA_WRAP(sub, -=)
246INDEXED_ASSIGN_LAMBDA_WRAP(mul, *=)
247INDEXED_ASSIGN_LAMBDA_WRAP(div, /=)
248INDEXED_ASSIGN_LAMBDA_WRAP(mod, %=)
249INDEXED_ASSIGN_LAMBDA_WRAP(shl, <<=)
250INDEXED_ASSIGN_LAMBDA_WRAP(shr, >>=)
251INDEXED_ASSIGN_LAMBDA_WRAP(and, &=)
252INDEXED_ASSIGN_LAMBDA_WRAP(or , |=)
253INDEXED_ASSIGN_LAMBDA_WRAP(exor, ^=)
262template <typename T, typename T2>
278template <
typename T,
typename T2,
typename Host,
typename HostSet>
279inline typename std::enable_if<std::is_base_of<HostSet, Host>::value, T>::type
280 setter_wrap(Host*
const host,
void (HostSet::*pSetter)(T2), T value)
282 (host->*pSetter)(value);
311template <
typename T,
typename Host,
typename HostGet,
typename HostSet>
312inline typename std::enable_if<std::is_base_of<HostGet, Host>::value && std::is_base_of<HostSet, Host>::value, T>::type
315 T tmp = (host->*pGetter)();
316 (host->*pSetter)(++tmp);
330template <
typename T,
typename Host,
typename HostGet,
typename HostSet>
331inline typename std::enable_if<std::is_base_of<HostGet, Host>::value && std::is_base_of<HostSet, Host>::value, T>::type
334 T tmp = (host->*pGetter)();
335 (host->*pSetter)(++tmp);
349 T tmp = pGetter(), rv = tmp;
365template <
typename T,
typename Host,
typename HostGet,
typename HostSet>
366inline typename std::enable_if<std::is_base_of<HostGet, Host>::value && std::is_base_of<HostSet, Host>::value, T>::type
369 T tmp = (host->*pGetter)(), rv = tmp;
371 (host->*pSetter)(tmp);
385template <
typename T,
typename Host,
typename HostConstGet,
typename HostSet>
386inline typename std::enable_if<std::is_base_of<HostConstGet, Host>::value && std::is_base_of<HostSet, Host>::value, T>::type
389 T tmp = (host->*pGetter)(), rv = tmp;
391 (host->*pSetter)(tmp);
419template <
typename T,
typename Host,
typename HostGet,
typename HostSet>
420inline typename std::enable_if<std::is_base_of<HostGet, Host>::value && std::is_base_of<HostSet, Host>::value, T>::type
423 T tmp = (host->*pGetter)();
424 (host->*pSetter)(--tmp);
437template <
typename T,
typename Host,
typename HostConstGet,
typename HostSet>
438inline typename std::enable_if<std::is_base_of<HostConstGet, Host>::value && std::is_base_of<HostSet, Host>::value, T>::type
441 T tmp = (host->*pGetter)();
442 (host->*pSetter)(--tmp);
456 T tmp = pGetter(), rv = tmp;
471template <
typename T,
typename Host,
typename HostGet,
typename HostSet>
472inline typename std::enable_if<std::is_base_of<HostGet, Host>::value && std::is_base_of<HostSet, Host>::value, T>::type
475 T tmp = (host->*pGetter)(), rv = tmp;
477 (host->*pSetter)(tmp);
490template <
typename T,
typename Host,
typename HostConstGet,
typename HostSet>
491inline typename std::enable_if<std::is_base_of<HostConstGet, Host>::value && std::is_base_of<HostSet, Host>::value, T>::type
494 T tmp = (host->*pGetter)(), rv = tmp;
496 (host->*pSetter)(tmp);
504#define PROP_ASSIGN_WRAP(name, op) \
505 template <typename PropT, typename PropValT> \
506 inline PropT setter_##name##_wrap(PropT (*pGetter)(), void (*pSetter)(PropT), PropValT value) \
508 PropT tmp = pGetter(); \
509 tmp = tmp op value; \
513 template <typename PropT, typename PropValT> \
514 inline PropT setter_##name##_wrap(PropT (*pGetter)(), void (*pSetter)(const PropT&), PropValT value) \
516 PropT tmp = pGetter(); \
517 tmp = tmp op value; \
521 template <typename PropT, typename HostT, typename HostGetT, typename HostSetT, typename PropValT> \
522 inline typename std::enable_if<std::is_base_of<HostGetT, HostT>::value && std::is_base_of<HostSetT, HostT>::value, PropT>::type \
523 setter_##name##_wrap(HostT* const host, PropT (HostGetT::*pGetter)(), void (HostSetT::*pSetter)(PropT), PropValT value) \
525 PropT tmp = (host->*pGetter)(); \
526 tmp = tmp op value; \
527 (host->*pSetter)(tmp); \
530 template <typename PropT, typename HostT, typename HostGetT, typename HostSetT, typename PropValT> \
531 inline typename std::enable_if<std::is_base_of<HostGetT, HostT>::value && std::is_base_of<HostSetT, HostT>::value, PropT>::type \
532 setter_##name##_wrap(HostT* const host, PropT (HostGetT::*pGetter)(), void (HostSetT::*pSetter)(const PropT &), PropValT value) \
534 PropT tmp = (host->*pGetter)(); \
535 tmp = tmp op value; \
536 (host->*pSetter)(tmp); \
539 template <typename PropT, typename HostT, typename HostGetT, typename HostSetT, typename PropValT> \
540 inline typename std::enable_if<std::is_base_of<HostGetT, HostT>::value && std::is_base_of<HostSetT, HostT>::value, PropT>::type \
541 setter_##name##_wrap(HostT* const host, PropT (HostGetT::*pGetter)() const, void (HostSetT::*pSetter)(PropT), PropValT value) \
543 PropT tmp = (host->*pGetter)(); \
544 tmp = tmp op value; \
545 (host->*pSetter)(tmp); \
548 template <typename PropT, typename HostT, typename HostGetT, typename HostSetT, typename PropValT> \
549 inline typename std::enable_if<std::is_base_of<HostGetT, HostT>::value && std::is_base_of<HostSetT, HostT>::value, PropT>::type \
550 setter_##name##_wrap(HostT* const host, PropT (HostGetT::*pGetter)() const, void (HostSetT::*pSetter)(const PropT &), PropValT value) \
552 PropT tmp = (host->*pGetter)(); \
553 tmp = tmp op value; \
554 (host->*pSetter)(tmp); \
558PROP_ASSIGN_WRAP(add, + )
559PROP_ASSIGN_WRAP(sub, - )
560PROP_ASSIGN_WRAP(mul, * )
561PROP_ASSIGN_WRAP(div, / )
562PROP_ASSIGN_WRAP(mod, % )
563PROP_ASSIGN_WRAP(shl, << )
564PROP_ASSIGN_WRAP(shr, >> )
565PROP_ASSIGN_WRAP(and, & )
566PROP_ASSIGN_WRAP(or, | )
567PROP_ASSIGN_WRAP(exor, ^ )
575#define SETTER_OP_WRAP(T, obj, prop, op, val) \
576 setter_##op##_wrap(obj, &T::get_##prop, &T::set_##prop, val)
auto setter_coalesce_wrap(G &&getter, S &&setter, T &&value)
Wrapper function to wrap calling of coalsesce assignment.
Definition: setters_wrap.h:93
auto setter_decrement_wrap(G &&getter, S &&setter)
Translator translates C#'s decrement expressions targeting class' property that has setter and getter...
Definition: setters_wrap.h:62
T setter_wrap(S &&setter, T value)
Wrapper function to wrap calling setter method and returning set value (normally, set methods do not ...
Definition: setters_wrap.h:18
auto setter_post_decrement_wrap(G &&getter, S &&setter)
Translator translates C#'s post-decrement expressions targeting a class' property that has a setter a...
Definition: setters_wrap.h:77
auto setter_increment_wrap(G &&getter, S &&setter)
Translator translates C#'s increment expressions targeting class' property that has setter and getter...
Definition: setters_wrap.h:32
auto setter_post_increment_wrap(G &&getter, S &&setter)
Translator translates C#'s post-increment expressions targeting class' property that has setter and g...
Definition: setters_wrap.h:47
Definition: db_command.h:9