@@ -12,7 +12,7 @@ namespace signalr
1212 /* *
1313 * An enum defining the types a signalr::value may be.
1414 */
15- enum class type
15+ enum class value_type
1616 {
1717 map,
1818 array,
@@ -28,20 +28,88 @@ namespace signalr
2828 class value
2929 {
3030 public:
31+ /* *
32+ * Create an object representing a value_type::null value.
33+ */
3134 value ();
32- value (int val);
35+
36+ /* *
37+ * Create an object representing a default value for the given value_type.
38+ */
39+ value (value_type t);
40+
41+ /* *
42+ * Create an object representing a value_type::boolean with the given bool value.
43+ */
44+ value (bool val);
45+
46+ /* *
47+ * Create an object representing a value_type::float64 with the given double value.
48+ */
3349 value (double val);
50+
51+ /* *
52+ * Create an object representing a value_type::string with the given string value.
53+ */
3454 value (const std::string& val);
55+
56+ /* *
57+ * Create an object representing a value_type::string with the given string value.
58+ */
59+ value (std::string&& val);
60+
61+ /* *
62+ * Create an object representing a value_type::array with the given vector of value's.
63+ */
3564 value (const std::vector<value>& val);
65+
66+ /* *
67+ * Create an object representing a value_type::array with the given vector of value's.
68+ */
69+ value (std::vector<value>&& val);
70+
71+ /* *
72+ * Create an object representing a value_type::map with the given map of string-value's.
73+ */
3674 value (const std::map<std::string, value>& map);
3775
76+ /* *
77+ * Create an object representing a value_type::map with the given map of string-value's.
78+ */
79+ value (std::map<std::string, value>&& map);
80+
81+ /* *
82+ * Copies an existing value.
83+ */
84+ value (const value& rhs);
85+
86+ /* *
87+ * Moves an existing value.
88+ */
89+ value (value&& rhs) noexcept ;
90+
91+ /* *
92+ * Cleans up the resources associated with the value.
93+ */
94+ ~value ();
95+
96+ /* *
97+ * Copies an existing value.
98+ */
99+ value& operator =(const value& rhs);
100+
101+ /* *
102+ * Moves an existing value.
103+ */
104+ value& operator =(value&& rhs) noexcept ;
105+
38106 /* *
39107 * True if the object stored is a Key-Value pair.
40108 */
41109 bool is_map () const ;
42110
43111 /* *
44- * True if the object stored is double.
112+ * True if the object stored is a double.
45113 */
46114 bool is_double () const ;
47115
@@ -83,16 +151,33 @@ namespace signalr
83151 /* *
84152 * Returns the stored object as an array of signalr::value's. This will throw if the underlying object is not a signalr::type::array.
85153 */
86- std::vector<value> as_array () const ;
154+ const std::vector<value>& as_array () const ;
87155
88156 /* *
89157 * Returns the stored object as a map of property name to signalr::value. This will throw if the underlying object is not a signalr::type::map.
90158 */
91- std::map<std::string, value> as_map () const ;
159+ const std::map<std::string, value>& as_map () const ;
92160
93161 /* *
94162 * Returns the signalr::type that represents the stored object.
95163 */
96- type type () const ;
164+ value_type type () const ;
165+
166+ private:
167+ value_type mType ;
168+
169+ union storage
170+ {
171+ bool boolean;
172+ std::string string;
173+ std::vector<value> array;
174+ double number;
175+ std::map<std::string, value> map;
176+
177+ storage () {}
178+ ~storage () {}
179+ };
180+
181+ storage mStorage ;
97182 };
98183}
0 commit comments