File tree 2 files changed +29
-0
lines changed 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ Date: April 2016
15
15
16
16
#include < ostream>
17
17
18
+ #include < util/json_stream.h>
18
19
#include < util/std_types.h>
19
20
#include < util/symbol_table.h>
20
21
@@ -165,3 +166,29 @@ void class_hierarchyt::output_dot(std::ostream &ostr) const
165
166
}
166
167
ostr << " }\n " ;
167
168
}
169
+
170
+ // / Output the class hierarchy in JSON format
171
+ // / \param json_stream: the output JSON stream array
172
+ // / \param children_only: print the children only and do not print the parents
173
+ void class_hierarchyt::output (
174
+ json_stream_arrayt &json_stream,
175
+ bool children_only) const
176
+ {
177
+ for (const auto &c : class_map)
178
+ {
179
+ json_stream_objectt &json_class = json_stream.push_back_stream_object ();
180
+ json_class[" name" ] = json_stringt (c.first );
181
+ json_class[" isAbstract" ] = jsont::json_boolean (c.second .is_abstract );
182
+ if (!children_only)
183
+ {
184
+ json_stream_arrayt &json_parents =
185
+ json_class.push_back_stream_array (" parents" );
186
+ for (const auto &pa : c.second .parents )
187
+ json_parents.push_back (json_stringt (pa));
188
+ }
189
+ json_stream_arrayt &json_children =
190
+ json_class.push_back_stream_array (" children" );
191
+ for (const auto &ch : c.second .children )
192
+ json_children.push_back (json_stringt (ch));
193
+ }
194
+ }
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ Date: April 2016
22
22
#include < util/irep.h>
23
23
24
24
class symbol_tablet ;
25
+ class json_stream_arrayt ;
25
26
26
27
class class_hierarchyt
27
28
{
@@ -58,6 +59,7 @@ class class_hierarchyt
58
59
59
60
void output (std::ostream &, bool children_only) const ;
60
61
void output_dot (std::ostream &) const ;
62
+ void output (json_stream_arrayt &, bool children_only) const ;
61
63
62
64
protected:
63
65
void get_children_trans_rec (const irep_idt &, idst &) const ;
You can’t perform that action at this time.
0 commit comments