10 #ifndef CPROVER_UTIL_JSON_H
11 #define CPROVER_UTIL_JSON_H
30 typedef std::map<std::string, jsont>
objectt;
116 objectt::const_iterator it=
object.find(key);
123 void output_rec(std::ostream &,
unsigned indent)
const;
127 static void output_key(std::ostream &out,
const std::string &key);
138 static void escape_string(
const std::string &, std::ostream &);
171 explicit json_arrayt(std::initializer_list<jsont> &&initializer_list)
176 template <
typename begin_iteratort,
typename end_iteratort>
177 json_arrayt(begin_iteratort &&begin_iterator, end_iteratort &&end_iterator)
181 std::forward<begin_iteratort>(begin_iterator),
182 std::forward<end_iteratort>(end_iterator)))
186 typename std::decay<begin_iteratort>::type,
187 typename std::decay<end_iteratort>::type>::
value,
188 "The iterators must be of the same type.");
191 template <
typename iteratort>
209 return array.empty();
230 template <
typename... argumentst>
233 array.emplace_back(std::forward<argumentst>(arguments)...);
238 return array.begin();
241 arrayt::const_iterator
begin()
const
243 return array.begin();
248 return array.cbegin();
256 arrayt::const_iterator
end()
const
261 arrayt::const_iterator
cend()
const
309 std::initializer_list<typename objectt::value_type> &&initializer_list)
314 template <
typename begin_iteratort,
typename end_iteratort>
315 json_objectt(begin_iteratort &&begin_iterator, end_iteratort &&end_iterator)
319 std::forward<begin_iteratort>(begin_iterator),
320 std::forward<end_iteratort>(end_iterator)))
324 typename std::decay<begin_iteratort>::type,
325 typename std::decay<end_iteratort>::type>::
value,
326 "The iterators must be of the same type.");
329 template <
typename iteratort>
351 return object.insert(it, std::move(
value));
356 return object.find(key);
361 return object.find(key);
366 return object.size();
371 return object.begin();
376 return object.begin();
381 return object.cbegin();
396 return object.cend();
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
jsont & push_back(jsont &&json)
jsont & push_back(const jsont &json)
void resize(std::size_t size)
json_arrayt(ranget< iteratort > &&range)
arrayt::const_iterator end() const
arrayt::const_iterator begin() const
arrayt::const_iterator cbegin() const
void emplace_back(argumentst &&... arguments)
json_arrayt(begin_iteratort &&begin_iterator, end_iteratort &&end_iterator)
arrayt::const_iterator cend() const
json_arrayt(std::initializer_list< jsont > &&initializer_list)
json_numbert(const std::string &_value)
json_objectt(ranget< iteratort > &&range)
const_iterator cend() const
json_objectt(begin_iteratort &&begin_iterator, end_iteratort &&end_iterator)
const_iterator cbegin() const
const_iterator find(const std::string &key) const
objectt::const_iterator const_iterator
iterator find(const std::string &key)
objectt::value_type value_type
iterator insert(const_iterator it, value_type value)
const_iterator begin() const
const_iterator end() const
const jsont & operator[](const std::string &key) const
jsont & operator[](const std::string &key)
json_objectt(std::initializer_list< typename objectt::value_type > &&initializer_list)
objectt::iterator iterator
json_stringt(const char *_value)
Constructon from string literal.
json_stringt(std::string _value)
json_stringt(const irep_idt &_value)
static void escape_string(const std::string &, std::ostream &)
void output_rec(std::ostream &, unsigned indent) const
Recursive printing of the json object.
jsont(kindt _kind, arrayt &&entries)
json_arrayt & make_array()
json_objectt & make_object()
static void output_key(std::ostream &out, const std::string &key)
const jsont & operator[](const std::string &key) const
std::vector< jsont > arrayt
void output(std::ostream &out) const
jsont(kindt _kind, objectt &&objects)
static jsont json_boolean(bool value)
std::map< std::string, jsont > objectt
static const jsont null_json_object
jsont(kindt _kind, std::string _value)
static void output_object(std::ostream &out, const objectt &object, unsigned indent)
Basic handling of the printing of a JSON object.
A way of representing nested key/value data.
const std::string & id2string(const irep_idt &d)
json_arrayt & to_json_array(jsont &json)
jsont to_json(const structured_datat &data)
Convert the structured_datat into an json object.
json_objectt & to_json_object(jsont &json)
std::ostream & operator<<(std::ostream &out, const jsont &src)
json_stringt & to_json_string(jsont &json)
bool operator==(const jsont &left, const jsont &right)
static void json(json_objectT &result, const irep_idt &property_id, const property_infot &property_info)
Ranges: pair of begin and end iterators, which can be initialized from containers,...
#define PRECONDITION(CONDITION)
A range is a pair of a begin and an end iterators.