1 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2 // -*- Mode: C++ -*-
3 //
4 // Copyright (C) 2013-2020 Red Hat, Inc.
5 //
6 // Author: Dodji Seketeli
7
8 /// @file
9 ///
10 /// This file contains the declarations of the entry points to
11 /// de-serialize an instance of @ref abigail::translation_unit to an
12 /// ABI Instrumentation file in libabigail native XML format.
13
14 #ifndef __ABG_WRITER_H__
15 #define __ABG_WRITER_H__
16
17 #include "abg-fwd.h"
18
19 namespace abigail
20 {
21 namespace xml_writer
22 {
23
24 using namespace abigail::ir;
25
26 /// The style of type id the XML writer will output.
27 enum type_id_style_kind
28 {
29 SEQUENCE_TYPE_ID_STYLE,
30 HASH_TYPE_ID_STYLE
31 };
32
33 class write_context;
34
35 /// A convenience typedef for a shared pointer to write_context.
36 typedef shared_ptr<write_context> write_context_sptr;
37
38 write_context_sptr
39 create_write_context(const environment *env,
40 ostream& output_stream);
41
42 void
43 set_show_locs(write_context& ctxt, bool flag);
44
45 void
46 set_annotate(write_context& ctxt, bool flag);
47
48 void
49 set_write_architecture(write_context& ctxt, bool flag);
50
51 void
52 set_write_corpus_path(write_context& ctxt, bool flag);
53
54 void
55 set_write_comp_dir(write_context& ctxt, bool flag);
56
57 void
58 set_write_elf_needed(write_context& ctxt, bool flag);
59
60 void
61 set_write_default_sizes(write_context& ctxt, bool flag);
62
63 void
64 set_short_locs(write_context& ctxt, bool flag);
65
66 void
67 set_write_parameter_names(write_context& ctxt, bool flag);
68
69 void
70 set_type_id_style(write_context& ctxt, type_id_style_kind style);
71
72 /// A convenience generic function to set common options (usually used
73 /// by Libabigail tools) from a generic options carrying-object, into
74 /// a given @ref write_context.
75 ///
76 /// @param ctxt the @ref the write_context to consider.
77 ///
78 /// @param opts the option-carrying object to set the options from.
79 /// It must contain data members named: annotate, and show_locs, at
80 /// very least.
81 template <typename OPTS>
82 void
set_common_options(write_context & ctxt,const OPTS & opts)83 set_common_options(write_context& ctxt, const OPTS& opts)
84 {
85 set_annotate(ctxt, opts.annotate);
86 set_show_locs(ctxt, opts.show_locs);
87 set_write_architecture(ctxt, opts.write_architecture);
88 set_write_corpus_path(ctxt, opts.write_corpus_path);
89 set_write_comp_dir(ctxt, opts.write_comp_dir);
90 set_write_elf_needed(ctxt, opts.write_elf_needed);
91 set_write_parameter_names(ctxt, opts.write_parameter_names);
92 set_short_locs(ctxt, opts.short_locs);
93 set_write_default_sizes(ctxt, opts.default_sizes);
94 set_type_id_style(ctxt, opts.type_id_style);
95 }
96
97 void
98 set_ostream(write_context& ctxt, ostream& os);
99
100 bool
101 write_translation_unit(write_context& ctxt,
102 const translation_unit& tu,
103 const unsigned indent);
104
105 bool
106 write_corpus_to_archive(const corpus& corp,
107 const string& path,
108 const bool annotate = false);
109
110 bool
111 write_corpus_to_archive(const corpus& corp,
112 const bool annotate = false);
113
114 bool
115 write_corpus_to_archive(const corpus_sptr corp,
116 const bool annotate = false);
117
118 bool
119 write_corpus(write_context& ctxt,
120 const corpus_sptr& corpus,
121 unsigned indent,
122 bool member_of_group = false);
123
124 bool
125 write_corpus_group(write_context& ctx,
126 const corpus_group_sptr& group,
127 unsigned indent);
128
129 }// end namespace xml_writer
130 }// end namespace abigail
131
132 #endif // __ABG_WRITER_H__
133