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-2025 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
19namespace abigail
20{
21namespace xml_writer
22{
23
24using 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
33class write_context;
34
35/// A convenience typedef for a shared pointer to write_context.
36typedef shared_ptr<write_context> write_context_sptr;
37
40 ostream& output_stream);
41
42void
43set_show_locs(write_context& ctxt, bool flag);
44
45void
46set_annotate(write_context& ctxt, bool flag);
47
48void
49set_write_architecture(write_context& ctxt, bool flag);
50
51void
52set_write_corpus_path(write_context& ctxt, bool flag);
53
54void
55set_write_comp_dir(write_context& ctxt, bool flag);
56
57void
58set_write_elf_needed(write_context& ctxt, bool flag);
59
60void
61set_write_undefined_symbols(write_context& ctxt, bool flag);
62
63void
64set_write_default_sizes(write_context& ctxt, bool flag);
65
66void
67set_short_locs(write_context& ctxt, bool flag);
68
69void
70set_write_parameter_names(write_context& ctxt, bool flag);
71
72void
73set_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.
84template <typename OPTS>
85void
86set_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
101void
102set_ostream(write_context& ctxt, ostream& os);
103
104bool
105write_translation_unit(write_context& ctxt,
106 const translation_unit& tu,
107 const unsigned indent,
108 bool last = true);
109
110bool
111write_corpus_to_archive(const corpus& corp,
112 const string& path,
113 const bool annotate = false);
114
115bool
116write_corpus_to_archive(const corpus& corp,
117 const bool annotate = false);
118
119bool
120write_corpus_to_archive(const corpus_sptr corp,
121 const bool annotate = false);
122
123bool
124write_corpus(write_context& ctxt,
125 const corpus_sptr& corpus,
126 unsigned indent,
127 bool member_of_group = false);
128
129bool
130write_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
137void
138write_canonical_type_ids(xml_writer::write_context&, ostream&);
139
140bool
141write_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:148
This is the abstraction of the set of relevant artefacts (types, variable declarations,...
Definition: abg-ir.h:695
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:2336
void set_short_locs(write_context &ctxt, bool flag)
Set the 'short-locs' flag.
Definition: abg-writer.cc:2300
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:2212
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
void set_write_parameter_names(write_context &ctxt, bool flag)
Set the 'parameter-names' flag.
Definition: abg-writer.cc:2312
void set_ostream(write_context &ctxt, ostream &os)
Set the new ostream.
Definition: abg-writer.cc:2252
shared_ptr< write_context > write_context_sptr
A convenience typedef for a shared pointer to write_context.
Definition: abg-writer.h:36
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:4823
void set_annotate(write_context &ctxt, bool flag)
Set the 'annotate' flag.
Definition: abg-writer.cc:2241
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:2557
void set_write_default_sizes(write_context &ctxt, bool flag)
Set the 'default-sizes' flag.
Definition: abg-writer.cc:2351
void set_write_elf_needed(write_context &ctxt, bool flag)
Set the 'elf-needed' flag.
Definition: abg-writer.cc:2324
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:4675
void set_write_corpus_path(write_context &ctxt, bool flag)
Set the 'write-corpus-path' flag.
Definition: abg-writer.cc:2276
void set_write_architecture(write_context &ctxt, bool flag)
Set the 'write-architecture' flag.
Definition: abg-writer.cc:2264
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:2229
void set_type_id_style(write_context &ctxt, type_id_style_kind style)
Set the 'type-id-style' property.
Definition: abg-writer.cc:2362
void set_write_comp_dir(write_context &ctxt, bool flag)
Set the 'write-comp-dir' flag.
Definition: abg-writer.cc:2288
Toplevel namespace for libabigail.
Datum consolidating style preferences.