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
@@ -162,3 +163,29 @@ void class_hierarchyt::output_dot(std::ostream &ostr) const
162
163
}
163
164
ostr << " }\n " ;
164
165
}
166
+
167
+ // / Output the class hierarchy in JSON format
168
+ // / \param json_stream: the output JSON stream array
169
+ // / \param children_only: print the children only and do not print the parents
170
+ void class_hierarchyt::output (
171
+ json_stream_arrayt &json_stream,
172
+ bool children_only) const
173
+ {
174
+ for (const auto &c : class_map)
175
+ {
176
+ json_stream_objectt &json_class = json_stream.push_back_stream_object ();
177
+ json_class[" name" ] = json_stringt (c.first );
178
+ json_class[" isAbstract" ] = jsont::json_boolean (c.second .is_abstract );
179
+ if (!children_only)
180
+ {
181
+ json_stream_arrayt &json_parents =
182
+ json_class.push_back_stream_array (" parents" );
183
+ for (const auto &pa : c.second .parents )
184
+ json_parents.push_back (json_stringt (pa));
185
+ }
186
+ json_stream_arrayt &json_children =
187
+ json_class.push_back_stream_array (" children" );
188
+ for (const auto &ch : c.second .children )
189
+ json_children.push_back (json_stringt (ch));
190
+ }
191
+ }
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