34
34
void convertTo(ToVariantConverter&, const Type&)
35
35
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
36
36
// ------------------------------------------------------------------------------
37
- #define CPPWAMP_CONVERSION_SPLIT_FREE (Type ) \
38
- void convert (FromVariantConverter& c, Type& obj) \
39
- { \
40
- convertFrom (c, obj); \
41
- } \
42
- \
43
- void convert (ToVariantConverter& c, Type& obj) \
44
- { \
45
- convertTo (c, const_cast <const Type&>(obj)); \
37
+ #define CPPWAMP_CONVERSION_SPLIT_FREE (Type ) \
38
+ inline void convert (::wamp:: FromVariantConverter& c, Type& obj) \
39
+ { \
40
+ convertFrom (c, obj); \
41
+ } \
42
+ \
43
+ inline void convert (::wamp:: ToVariantConverter& c, Type& obj) \
44
+ { \
45
+ convertTo (c, const_cast <const Type&>(obj)); \
46
46
}
47
47
48
48
// ------------------------------------------------------------------------------
@@ -63,16 +63,16 @@ void convert(ToVariantConverter& c, Type& obj) \
63
63
void CustomType::convertTo(ToVariantConverter&) const
64
64
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
65
65
// ------------------------------------------------------------------------------
66
- #define CPPWAMP_CONVERSION_SPLIT_MEMBER (Type ) \
67
- void convert (FromVariantConverter& c, Type& obj) \
68
- { \
69
- ConversionAccess::convertFrom (c, obj); \
70
- } \
71
- \
72
- void convert (ToVariantConverter& c, Type& obj) \
73
- { \
74
- const auto & constObj = obj; \
75
- ConversionAccess::convertTo (c, constObj); \
66
+ #define CPPWAMP_CONVERSION_SPLIT_MEMBER (Type ) \
67
+ inline void convert (::wamp:: FromVariantConverter& c, Type& obj) \
68
+ { \
69
+ wamp:: ConversionAccess::convertFrom (c, obj); \
70
+ } \
71
+ \
72
+ inline void convert (::wamp:: ToVariantConverter& c, Type& obj) \
73
+ { \
74
+ const auto & constObj = obj; \
75
+ wamp:: ConversionAccess::convertTo (c, constObj); \
76
76
}
77
77
78
78
namespace wamp
@@ -115,6 +115,10 @@ class ToVariantConverter
115
115
template <typename T>
116
116
ToVariantConverter& operator ()(String key, T&& value);
117
117
118
+ /* * Appends an object member to the variant. */
119
+ template <typename T, typename U>
120
+ ToVariantConverter& operator ()(String key, T&& value, U&& ignored);
121
+
118
122
/* * Returns a reference to the wrapped variant. */
119
123
Variant& variant ();
120
124
@@ -160,6 +164,11 @@ class FromVariantConverter
160
164
template <typename T>
161
165
FromVariantConverter& operator ()(const String& key, T& value);
162
166
167
+ /* * Retrieves a member from an Object variant, with a fallback value
168
+ if the member is not found. */
169
+ template <typename T, typename U>
170
+ FromVariantConverter& operator ()(const String& key, T& value, U&& fallback);
171
+
163
172
/* * Returns a constant reference to the wrapped variant. */
164
173
const Variant& variant () const ;
165
174
0 commit comments