8 template <
typename... Params>
11 template <
typename First,
typename... Remaining>
14 auto type = TYPEID<First>();
39 auto result = stream.
read<
char>();
41 auto error = stream.
read<std::string>();
45 throw std::runtime_error(
"Invalid reply from server");
47 auto type = stream.
read<int32_t>();
48 if (type != TYPEID<T>()) {
49 printf(
"trying to read type %d, got type %d\n", (
int) TYPEID<T>(), (
int) type);
52 return stream.
read<T>();
56 template<
typename RESULT_TYPE>
58 RESULT_TYPE result = fun();
59 int32_t result_type = TYPEID<RESULT_TYPE>();
60 stream.
write(result_type);
63 template<
typename RESULT_TYPE,
typename U0>
65 auto x0 = read_from_stream_with_typeid<typename std::decay<U0>::type>(stream);
67 RESULT_TYPE result = fun(x0);
68 int32_t result_type = TYPEID<RESULT_TYPE>();
69 stream.
write(result_type);
72 template<
typename RESULT_TYPE,
typename U0,
typename U1>
74 auto x0 = read_from_stream_with_typeid<typename std::decay<U0>::type>(stream);
75 auto x1 = read_from_stream_with_typeid<typename std::decay<U1>::type>(stream);
77 RESULT_TYPE result = fun(x0, x1);
78 int32_t result_type = TYPEID<RESULT_TYPE>();
79 stream.
write(result_type);
82 template<
typename RESULT_TYPE,
typename U0,
typename U1,
typename U2>
84 auto x0 = read_from_stream_with_typeid<typename std::decay<U0>::type>(stream);
85 auto x1 = read_from_stream_with_typeid<typename std::decay<U1>::type>(stream);
86 auto x2 = read_from_stream_with_typeid<typename std::decay<U2>::type>(stream);
88 RESULT_TYPE result = fun(x0, x1, x2);
89 int32_t result_type = TYPEID<RESULT_TYPE>();
90 stream.
write(result_type);
static void send(BinaryStream &stream)
void call(const std::function< RESULT_TYPE()> &fun, BinaryStream &stream)
const char RIS_REPLY_ERROR
void write(const char *buffer, size_t len)
const char RIS_REPLY_VALUE
static void send(BinaryStream &stream)
size_t read(char *buffer, size_t len)
T read_from_stream_with_typeid(BinaryStream &stream)
parameter_error_exception(const std::string &error)