31 template<
typename T,
size_t POS>
33 static int get(
const std::vector<Variant> & args) {
36 if (POS < args.size()) {
37 value = args[POS].value<
int>();
43 template<
typename T,
size_t POS>
44 struct CPPEXPOSE_TEMPLATE_API
ArgValue<const T &, POS> {
45 static T
get(
const std::vector<Variant> & args) {
51 struct CPPEXPOSE_TEMPLATE_API
ArgValue<float, POS> {
52 static float get(
const std::vector<Variant> & args) {
54 if (POS < args.size()) {
55 value = (float)args[POS].value<double>();
62 struct CPPEXPOSE_TEMPLATE_API
ArgValue<double, POS> {
63 static double get(
const std::vector<Variant> & args) {
65 if (POS < args.size()) {
66 value = args[POS].value<
double>();
73 struct CPPEXPOSE_TEMPLATE_API
ArgValue<bool, POS> {
74 static bool get(
const std::vector<Variant> & args) {
76 if (POS < args.size()) {
77 value = args[POS].value<
bool>();
84 struct CPPEXPOSE_TEMPLATE_API ArgValue<std::string, POS> {
85 static std::string
get(
const std::vector<Variant> & args) {
87 if (POS < args.size()) {
88 value = args[POS].value<std::string>();
95 struct CPPEXPOSE_TEMPLATE_API ArgValue<Variant, POS> {
96 static Variant
get(
const std::vector<Variant> & args) {
98 if (POS < args.size()) {
106 struct CPPEXPOSE_TEMPLATE_API ArgValue<const Variant &, POS> {
107 static Variant
get(
const std::vector<Variant> & args) {
112 template<
typename T,
size_t POS>
113 struct CPPEXPOSE_TEMPLATE_API ArgValue<const std::vector<T> &, POS> {
114 static std::vector<T>
get(
const std::vector<Variant> & args) {
115 if (POS < args.size()) {
116 return args[POS].toVector<T>();
118 return std::vector<T>();
124 struct CPPEXPOSE_TEMPLATE_API ArgValue<const std::vector<Variant> &, POS> {
125 static std::vector<Variant>
get(
const std::vector<Variant> & args) {
126 std::vector<Variant> list;
127 for (
size_t i=POS; i<args.size(); i++) {
128 list.push_back(args[i]);
138 if (POS < args.size()) {
157 template<
size_t... I>
158 struct CPPEXPOSE_TEMPLATE_API
Seq {};
164 template<
int N,
size_t... I>
167 template<
size_t... I>
168 struct CPPEXPOSE_TEMPLATE_API GenSeq<0, I...> {
typedef Seq<I...>
Type; };
174 template<
size_t N,
typename T,
typename... Arguments>
177 template<
typename T,
typename... Arguments>
178 struct CPPEXPOSE_TEMPLATE_API PickType<0, T, Arguments...> {
typedef T
Type; };
184 template<
size_t I,
typename... Arguments>
187 typedef typename PickType<I, Arguments...>
::Type T;
195 template <
typename RET,
typename... Arguments>
199 typedef std::function<RET (Arguments...)>
FuncPtr;
201 static Variant
call(FuncPtr func, Arguments... args) {
202 return Variant( func(args...) );
210 template <
typename... Arguments>
214 typedef std::function<void (Arguments...)>
FuncPtr;
216 static Variant
call(FuncPtr func, Arguments... args) {
226 template <
typename T,
typename RET,
typename... Arguments>
230 typedef RET (T::*MethodPtr) (Arguments...);
232 static Variant
call(T * obj, MethodPtr method, Arguments... args) {
233 return Variant((obj->*method)(args...));
241 template <
typename T,
typename... Arguments>
242 class CPPEXPOSE_TEMPLATE_API
CallMethod<T, void, Arguments...>
245 typedef void (T::*MethodPtr) (Arguments...);
247 static Variant
call(T * obj, MethodPtr method, Arguments... args) {
248 (obj->*method)(args...);
257 template <
typename T,
typename RET,
typename... Arguments>
261 typedef RET (T::*MethodPtr) (Arguments...)
const;
263 static Variant
call(
const T * obj, MethodPtr method, Arguments... args) {
264 return Variant((obj->*method)(args...));
272 template <
typename T,
typename... Arguments>
276 typedef void (T::*MethodPtr) (Arguments...)
const;
278 static Variant
call(
const T * obj, MethodPtr method, Arguments... args) {
279 (obj->*method)(args...);
Generate ArgValue class for types and index (e.g., ArgValueGen<2, float, int, double>::Type = ArgValu...
Definition: function_helpers.h:185
static Variant call(T *obj, MethodPtr method, Arguments...args)
Definition: function_helpers.h:247
static Variant call(FuncPtr func, Arguments...args)
Definition: function_helpers.h:201
static Variant call(const T *obj, MethodPtr method, Arguments...args)
Definition: function_helpers.h:278
Pick type by index (e.g., PickType<1, void, int, float>::Type = int)
Definition: function_helpers.h:175
Definition: function_helpers.h:12
ArgValue< T, I > Type
Definition: function_helpers.h:188
static Variant call(const T *obj, MethodPtr method, Arguments...args)
Definition: function_helpers.h:263
Template for parsing typed arguments from a list of variants.
Definition: function_helpers.h:32
Generate a sequence of numbers (e.g., Seq<0, 1, 2>)
Definition: function_helpers.h:158
PickType< I, Arguments... >::Type T
Definition: function_helpers.h:187
Template for calling a static function with a return value.
Definition: function_helpers.h:196
Sequence generator (e.g., GenSec<3>::Type = Seq<0, 1, 2>)
Definition: function_helpers.h:165
static Variant call(FuncPtr func, Arguments...args)
Definition: function_helpers.h:216
std::function< void(Arguments...)> FuncPtr
Definition: function_helpers.h:214
Seq< I... > Type
Definition: function_helpers.h:168
T Type
Definition: function_helpers.h:178
Template for calling a const member function with a return value.
Definition: function_helpers.h:258
std::function< RET(Arguments...)> FuncPtr
Definition: function_helpers.h:199
static int get(const std::vector< Variant > &args)
Definition: function_helpers.h:33
Base class for reflection-enabled objects.
Definition: Object.h:24
Template for calling a member function with a return value.
Definition: function_helpers.h:227
static Variant call(T *obj, MethodPtr method, Arguments...args)
Definition: function_helpers.h:232