libabigail
abg-writer.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2 // -*- Mode: C++ -*-
3 //
4 // Copyright (C) 2013-2023 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.
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 
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_undefined_symbols(write_context& ctxt, bool flag);
62 
63 void
64 set_write_default_sizes(write_context& ctxt, bool flag);
65 
66 void
67 set_short_locs(write_context& ctxt, bool flag);
68 
69 void
70 set_write_parameter_names(write_context& ctxt, bool flag);
71 
72 void
73 set_type_id_style(write_context& ctxt, type_id_style_kind style);
74 
75 /// A convenience generic function to set common options (usually used
76 /// by Libabigail tools) from a generic options carrying-object, into
77 /// a given @ref write_context.
78 ///
79 /// @param ctxt the @ref the write_context to consider.
80 ///
81 /// @param opts the option-carrying object to set the options from.
82 /// It must contain data members named: annotate, and show_locs, at
83 /// very least.
84 template <typename OPTS>
85 void
86 set_common_options(write_context& ctxt, const OPTS& opts)
87 {
88  set_annotate(ctxt, opts.annotate);
89  set_show_locs(ctxt, opts.show_locs);
90  set_write_architecture(ctxt, opts.write_architecture);
91  set_write_corpus_path(ctxt, opts.write_corpus_path);
92  set_write_comp_dir(ctxt, opts.write_comp_dir);
93  set_write_elf_needed(ctxt, opts.write_elf_needed);
94  set_write_undefined_symbols(ctxt, opts.load_undefined_interfaces);
95  set_write_parameter_names(ctxt, opts.write_parameter_names);
96  set_short_locs(ctxt, opts.short_locs);
97  set_write_default_sizes(ctxt, opts.default_sizes);
98  set_type_id_style(ctxt, opts.type_id_style);
99 }
100 
101 void
102 set_ostream(write_context& ctxt, ostream& os);
103 
104 bool
105 write_translation_unit(write_context& ctxt,
106  const translation_unit& tu,
107  const unsigned indent,
108  bool last = true);
109 
110 bool
111 write_corpus_to_archive(const corpus& corp,
112  const string& path,
113  const bool annotate = false);
114 
115 bool
116 write_corpus_to_archive(const corpus& corp,
117  const bool annotate = false);
118 
119 bool
120 write_corpus_to_archive(const corpus_sptr corp,
121  const bool annotate = false);
122 
123 bool
124 write_corpus(write_context& ctxt,
125  const corpus_sptr& corpus,
126  unsigned indent,
127  bool member_of_group = false);
128 
129 bool
130 write_corpus_group(write_context& ctx,
131  const corpus_group_sptr& group,
132  unsigned indent);
133 
134 }// end namespace xml_writer
135 
136 #ifdef WITH_DEBUG_SELF_COMPARISON
137 void
138 write_canonical_type_ids(xml_writer::write_context&, ostream&);
139 
140 bool
141 write_canonical_type_ids(xml_writer::write_context&,
142  const string &);
143 #endif
144 
145 }// end namespace abigail
146 
147 #endif // __ABG_WRITER_H__
This is the abstraction of a set of translation units (themselves seen as bundles of unitary abi arte...
Definition: abg-corpus.h:25
This is an abstraction of the set of resources necessary to manage several aspects of the internal re...
Definition: abg-ir.h:140
This is the abstraction of the set of relevant artefacts (types, variable declarations,...
Definition: abg-ir.h:686
The namespace of the internal representation of ABI artifacts like types and decls.
void set_write_undefined_symbols(write_context &ctxt, bool flag)
Set the 'undefined-symbols' flag.
Definition: abg-writer.cc:2334
void set_short_locs(write_context &ctxt, bool flag)
Set the 'short-locs' flag.
Definition: abg-writer.cc:2298
write_context_sptr create_write_context(const environment &env, ostream &default_output_stream)
Create a write_context object that can be used to emit abixml files.
Definition: abg-writer.cc:2210
void set_write_parameter_names(write_context &ctxt, bool flag)
Set the 'parameter-names' flag.
Definition: abg-writer.cc:2310
void set_ostream(write_context &ctxt, ostream &os)
Set the new ostream.
Definition: abg-writer.cc:2250
shared_ptr< write_context > write_context_sptr
A convenience typedef for a shared pointer to write_context.
Definition: abg-writer.h:33
bool write_corpus_group(write_context &ctxt, const corpus_group_sptr &group, unsigned indent)
Serialize an ABI corpus group to a single native xml document. The root note of the resulting XML doc...
Definition: abg-writer.cc:4904
void set_annotate(write_context &ctxt, bool flag)
Set the 'annotate' flag.
Definition: abg-writer.cc:2239
bool write_translation_unit(write_context &ctxt, const translation_unit &tu, const unsigned indent, bool is_last)
Serialize a translation unit to an output stream.
Definition: abg-writer.cc:2555
void set_write_default_sizes(write_context &ctxt, bool flag)
Set the 'default-sizes' flag.
Definition: abg-writer.cc:2349
void set_write_elf_needed(write_context &ctxt, bool flag)
Set the 'elf-needed' flag.
Definition: abg-writer.cc:2322
bool write_corpus(write_context &ctxt, const corpus_sptr &corpus, unsigned indent, bool member_of_group)
Serialize an ABI corpus to a single native xml document. The root note of the resulting XML document ...
Definition: abg-writer.cc:4756
void set_write_corpus_path(write_context &ctxt, bool flag)
Set the 'write-corpus-path' flag.
Definition: abg-writer.cc:2274
void set_write_architecture(write_context &ctxt, bool flag)
Set the 'write-architecture' flag.
Definition: abg-writer.cc:2262
void set_common_options(write_context &ctxt, const OPTS &opts)
A convenience generic function to set common options (usually used by Libabigail tools) from a generi...
Definition: abg-writer.h:86
type_id_style_kind
The style of type id the XML writer will output.
Definition: abg-writer.h:28
void set_show_locs(write_context &ctxt, bool flag)
Set the "show-locs" flag.
Definition: abg-writer.cc:2227
void set_type_id_style(write_context &ctxt, type_id_style_kind style)
Set the 'type-id-style' property.
Definition: abg-writer.cc:2360
void set_write_comp_dir(write_context &ctxt, bool flag)
Set the 'write-comp-dir' flag.
Definition: abg-writer.cc:2286
Toplevel namespace for libabigail.
Datum consolidating style preferences.