@@ -24,6 +24,7 @@ namespace jsonrpccxx {
24
24
constexpr json::value_t GetType (type<T>) {
25
25
return json::value_t ::object;
26
26
}
27
+ constexpr json::value_t GetType (type<void >) { return json::value_t ::null; }
27
28
constexpr json::value_t GetType (type<std::string>) { return json::value_t ::string; }
28
29
constexpr json::value_t GetType (type<bool >) { return json::value_t ::boolean; }
29
30
constexpr json::value_t GetType (type<float >) { return json::value_t ::number_float; }
@@ -148,6 +149,22 @@ namespace jsonrpccxx {
148
149
//
149
150
// Mapping for classes
150
151
//
152
+ template <typename T, typename ReturnType, typename ... ParamTypes>
153
+ MethodHandle methodHandle (ReturnType (T::*method)(ParamTypes...), T &instance) {
154
+ std::function<ReturnType (ParamTypes...)> function = [&instance, method](ParamTypes &&... params) -> ReturnType {
155
+ return (instance.*method)(std::forward<ParamTypes>(params)...);
156
+ };
157
+ return methodHandle (function);
158
+ }
159
+
160
+ template <typename T, typename ... ParamTypes>
161
+ NotificationHandle notificationHandle (void (T::*method)(ParamTypes...), T &instance) {
162
+ std::function<void (ParamTypes...)> function = [&instance, method](ParamTypes &&... params) -> void {
163
+ return (instance.*method)(std::forward<ParamTypes>(params)...);
164
+ };
165
+ return notificationHandle (function);
166
+ }
167
+
151
168
template <typename T, typename ReturnType, typename ... ParamTypes>
152
169
MethodHandle GetHandle (ReturnType (T::*method)(ParamTypes...), T &instance) {
153
170
std::function<ReturnType (ParamTypes...)> function = [&instance, method](ParamTypes &&... params) -> ReturnType {
0 commit comments