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
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_default_sizes(write_context& ctxt, bool flag);
62
63void
64set_short_locs(write_context& ctxt, bool flag);
65
66void
67set_write_parameter_names(write_context& ctxt, bool flag);
68
69void
70set_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.
81template <typename OPTS>
82void
83set_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
97void
98set_ostream(write_context& ctxt, ostream& os);
99
100bool
101write_translation_unit(write_context& ctxt,
102 const translation_unit& tu,
103 const unsigned indent,
104 bool last = true);
105
106bool
107write_corpus_to_archive(const corpus& corp,
108 const string& path,
109 const bool annotate = false);
110
111bool
112write_corpus_to_archive(const corpus& corp,
113 const bool annotate = false);
114
115bool
116write_corpus_to_archive(const corpus_sptr corp,
117 const bool annotate = false);
118
119bool
120write_corpus(write_context& ctxt,
121 const corpus_sptr& corpus,
122 unsigned indent,
123 bool member_of_group = false);
124
125bool
126write_corpus_group(write_context& ctx,
127 const corpus_group_sptr& group,
128 unsigned indent);
129
130}// end namespace xml_writer
131
132#ifdef WITH_DEBUG_SELF_COMPARISON
133void
134write_canonical_type_ids(xml_writer::write_context&, ostream&);
135
136bool
137write_canonical_type_ids(xml_writer::write_context&,
138 const string &);
139#endif
140
141}// end namespace abigail
142
143#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_short_locs(write_context &ctxt, bool flag)
Set the 'short-locs' flag.
Definition: abg-writer.cc:2231
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:2143
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:83
void set_write_parameter_names(write_context &ctxt, bool flag)
Set the 'parameter-names' flag.
Definition: abg-writer.cc:2243
void set_ostream(write_context &ctxt, ostream &os)
Set the new ostream.
Definition: abg-writer.cc:2183
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:4766
void set_annotate(write_context &ctxt, bool flag)
Set the 'annotate' flag.
Definition: abg-writer.cc:2172
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:2476
void set_write_default_sizes(write_context &ctxt, bool flag)
Set the 'default-sizes' flag.
Definition: abg-writer.cc:2270
void set_write_elf_needed(write_context &ctxt, bool flag)
Set the 'elf-needed' flag.
Definition: abg-writer.cc:2255
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:4647
void set_write_corpus_path(write_context &ctxt, bool flag)
Set the 'write-corpus-path' flag.
Definition: abg-writer.cc:2207
void set_write_architecture(write_context &ctxt, bool flag)
Set the 'write-architecture' flag.
Definition: abg-writer.cc:2195
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:2160
void set_type_id_style(write_context &ctxt, type_id_style_kind style)
Set the 'type-id-style' property.
Definition: abg-writer.cc:2281
void set_write_comp_dir(write_context &ctxt, bool flag)
Set the 'write-comp-dir' flag.
Definition: abg-writer.cc:2219
Toplevel namespace for libabigail.
Datum consolidating style preferences.