wamp_call_result.hpp
1 //
3 // Copyright (c) Crossbar.io Technologies GmbH and contributors
4 //
5 // Boost Software License - Version 1.0 - August 17th, 2003
6 //
7 // Permission is hereby granted, free of charge, to any person or organization
8 // obtaining a copy of the software and accompanying documentation covered by
9 // this license (the "Software") to use, reproduce, display, distribute,
10 // execute, and transmit the Software, and to prepare derivative works of the
11 // Software, and to permit third-parties to whom the Software is furnished to
12 // do so, all subject to the following:
13 //
14 // The copyright notices in the Software and this entire statement, including
15 // the above license grant, this restriction and the following disclaimer,
16 // must be included in all copies of the Software, in whole or in part, and
17 // all derivative works of the Software, unless such copies or derivative
18 // works are solely in the form of machine-executable object code generated by
19 // a source language processor.
20 //
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
24 // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
25 // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
26 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 // DEALINGS IN THE SOFTWARE.
28 //
30 
31 #ifndef AUTOBAHN_WAMP_CALL_RESULT_HPP
32 #define AUTOBAHN_WAMP_CALL_RESULT_HPP
33 
34 #include <msgpack.hpp>
35 #include <string>
36 
37 namespace autobahn {
38 
40 {
41 public:
43  wamp_call_result(msgpack::zone&& zone);
44 
45  wamp_call_result(const wamp_call_result& other) = delete;
47 
48  wamp_call_result& operator=(const wamp_call_result& other) = delete;
49  wamp_call_result& operator=(wamp_call_result&& other);
50 
54  std::size_t number_of_arguments() const;
55 
59  std::size_t number_of_kw_arguments() const;
60 
70  template <typename T>
71  T argument(std::size_t index) const;
72 
81  template <typename List>
82  List arguments() const;
83 
95  template <typename List>
96  void get_arguments(List& args) const;
97 
114  template <typename... T>
115  inline void get_each_argument(T&... args) const;
116 
134  template <typename T>
135  T kw_argument(const std::string& key) const;
136 
137  template <typename T>
138  T kw_argument(const char* key) const;
139 
157  template <typename T>
158  T kw_argument_or(const std::string& key, const T& fallback) const;
159 
160  template <typename T>
161  T kw_argument_or(const char* key, const T& fallback) const;
162 
171  template <typename Map>
172  Map kw_arguments() const;
173 
185  template <typename Map>
186  void get_kw_arguments(Map& kw_args) const;
187 
188  //
189  // functions only called internally by wamp_session
190 
191  void set_arguments(const msgpack::object& arguments);
192  void set_kw_arguments(const msgpack::object& kw_arguments);
193 
194 private:
195  msgpack::zone m_zone;
196  msgpack::object m_arguments;
197  msgpack::object m_kw_arguments;
198 };
199 
200 } // namespace autobahn
201 
202 #include "wamp_call_result.ipp"
203 
204 #endif // AUTOBAHN_WAMP_CALL_RESULT_HPP
Map kw_arguments() const
The keyword arguments returned from the call, converted to a map type.
void get_kw_arguments(Map &kw_args) const
Convert and assign the keyword arguments returned from the call to the given kw_args map...
std::size_t number_of_arguments() const
The number of positional arguments returned from the call.
T argument(std::size_t index) const
The positional argument returned from the call with the given index, converted to type T...
void get_each_argument(T &...args) const
Convert and assign the positional arguments to a given list of individual parameters.
T kw_argument_or(const std::string &key, const T &fallback) const
The keyword argument returned from the call with the given key, converted to type T...
void get_arguments(List &args) const
Convert and assign the positional arguments returned from the call to the given args list...
std::size_t number_of_kw_arguments() const
The number of keyword arguments returned from the call.
List arguments() const
The positional arguments returned from the call, converted to a list type.
T kw_argument(const std::string &key) const
The keyword argument returned from the call with the given key, converted to type T...