@@ -15,6 +15,8 @@ Author: Daniel Kroening, kroening@kroening.com
15
15
#include < iosfwd>
16
16
#include < string>
17
17
18
+ #include " irep.h"
19
+
18
20
class json_objectt ;
19
21
class json_arrayt ;
20
22
@@ -117,7 +119,7 @@ class jsont
117
119
{
118
120
}
119
121
120
- jsont (kindt _kind, const std::string & _value): kind(_kind), value(_value)
122
+ jsont (kindt _kind, std::string _value) : kind(_kind), value(std::move( _value) )
121
123
{
122
124
}
123
125
@@ -169,13 +171,63 @@ class json_arrayt:public jsont
169
171
array.push_back (jsont ());
170
172
return array.back ();
171
173
}
174
+
175
+ template <typename ... argumentst>
176
+ void emplace_back (argumentst &&... arguments)
177
+ {
178
+ array.emplace_back (std::forward<argumentst>(arguments)...);
179
+ }
180
+
181
+ std::vector<jsont>::iterator begin ()
182
+ {
183
+ return array.begin ();
184
+ }
185
+
186
+ std::vector<jsont>::const_iterator begin () const
187
+ {
188
+ return array.begin ();
189
+ }
190
+
191
+ std::vector<jsont>::const_iterator cbegin () const
192
+ {
193
+ return array.cbegin ();
194
+ }
195
+
196
+ std::vector<jsont>::iterator end ()
197
+ {
198
+ return array.end ();
199
+ }
200
+
201
+ std::vector<jsont>::const_iterator end () const
202
+ {
203
+ return array.end ();
204
+ }
205
+
206
+ std::vector<jsont>::const_iterator cend () const
207
+ {
208
+ return array.cend ();
209
+ }
210
+
211
+ typedef jsont value_type; // NOLINT(readability/identifiers)
172
212
};
173
213
174
214
class json_stringt :public jsont
175
215
{
176
216
public:
177
- explicit json_stringt (const std::string &_value):
178
- jsont(kindt::J_STRING, _value)
217
+ explicit json_stringt (std::string _value)
218
+ : jsont(kindt::J_STRING, std::move(_value))
219
+ {
220
+ }
221
+
222
+ #ifndef USE_STD_STRING
223
+ explicit json_stringt (const irep_idt &_value)
224
+ : jsont(kindt::J_STRING, id2string(_value))
225
+ {
226
+ }
227
+ #endif
228
+
229
+ // / Constructon from string literal.
230
+ explicit json_stringt (const char *_value) : jsont(kindt::J_STRING, _value)
179
231
{
180
232
}
181
233
};
0 commit comments