#ifndef __ABG_WRITER_H__
#define __ABG_WRITER_H__
+#include "abg-fwd.h"
+
namespace abigail
{
namespace xml_writer
set_annotate(write_context& ctxt, bool flag);
bool
-write_translation_unit(const translation_unit& tu,
- unsigned indent,
- std::ostream& out,
- const bool annotate = false);
-
-bool
-write_translation_unit(const translation_unit& tu,
- unsigned indent,
- const string& path,
- const bool annotate = false);
+write_translation_unit(write_context& ctxt,
+ const translation_unit& tu,
+ const unsigned indent);
+
+bool ABG_DEPRECATED
+write_translation_unit(const translation_unit& tu,
+ unsigned indent,
+ std::ostream& out,
+ const bool annotate = false);
+
+bool ABG_DEPRECATED
+write_translation_unit(const translation_unit& tu,
+ unsigned indent,
+ const string& path,
+ const bool annotate = false);
bool
write_corpus_to_archive(const corpus& corp,
};//end write_context
-static bool write_translation_unit(const translation_unit&,
- write_context&, unsigned);
static void write_location(const location&, write_context&);
static void write_location(const decl_base_sptr&, write_context&);
static bool write_visibility(const decl_base_sptr&, ostream&);
/// Serialize a translation unit to an output stream.
///
-/// @param tu the translation unit to serialize.
-///
/// @param ctxt the context of the serialization. It contains e.g,
/// the output stream to serialize to.
///
+/// @param tu the translation unit to serialize.
+///
/// @param indent how many indentation spaces to use during the
/// serialization.
///
/// @return true upon successful completion, false otherwise.
-static bool
-write_translation_unit(const translation_unit& tu,
- write_context& ctxt,
- unsigned indent)
+bool
+write_translation_unit(write_context& ctxt,
+ const translation_unit& tu,
+ const unsigned indent)
{
ostream& o = ctxt.get_ostream();
const config& c = ctxt.get_config();
///
/// @param out the output stream to serialize the translation unit to.
///
+/// @param annotate whether to annotate the output with debug information
+///
+/// @deprecated use write_translation_unit(ctct, tu, indent)
+///
/// @return true upon successful completion, false otherwise.
-bool
-write_translation_unit(const translation_unit& tu,
- unsigned indent,
- std::ostream& out,
- const bool annotate)
+bool ABG_DEPRECATED
+write_translation_unit(const translation_unit& tu,
+ unsigned indent,
+ std::ostream& out,
+ const bool annotate)
{
write_context ctxt(tu.get_environment(), out);
set_annotate(ctxt, annotate);
- return write_translation_unit(tu, ctxt, indent);
+ return write_translation_unit(ctxt, tu, indent);
}
/// Serialize a translation unit to a file.
/// @param indent how many indentation spaces to use during the
/// serialization.
///
-/// @param out the file to serialize the translation unit to.
+/// @param path the file to serialize the translation unit to.
+///
+/// @param annotate whether to annotate the output with debug information
+///
+/// @deprecated use write_translation_unit(ctct, tu, indent)
///
/// @return true upon successful completion, false otherwise.
-bool
-write_translation_unit(const translation_unit& tu,
- unsigned indent,
- const string& path,
- const bool annotate)
+bool ABG_DEPRECATED
+write_translation_unit(const translation_unit& tu,
+ unsigned indent,
+ const string& path,
+ const bool annotate)
{
bool result = true;
return false;
}
- if (!write_translation_unit(tu, indent, of, annotate))
+ write_context ctxt(tu.get_environment(), of);
+ set_annotate(ctxt, annotate);
+ if (!write_translation_unit(ctxt, tu, indent))
{
cerr << "failed to access " << path << "\n";
result = false;
{
translation_unit& tu = **i;
if (!tu.is_empty())
- write_translation_unit(tu, ctxt, get_indent_to_level(ctxt, indent, 1));
+ write_translation_unit(ctxt, tu, get_indent_to_level(ctxt, indent, 1));
}
do_indent_to_level(ctxt, indent, 0);
{
xml_writer::write_context ctxt(t.get_environment(), o);
xml_writer::set_annotate(ctxt, annotate);
- write_translation_unit(t, ctxt, /*indent=*/0);
+ write_translation_unit(ctxt, t, /*indent=*/0);
o << "\n";
}
using abigail::xml_reader::read_corpus_from_native_xml_file;
using abigail::dwarf_reader::read_corpus_from_elf;
using abigail::xml_writer::write_translation_unit;
+using abigail::xml_writer::write_context_sptr;
+using abigail::xml_writer::create_write_context;
using abigail::xml_writer::write_corpus;
using abigail::xml_writer::write_corpus_to_archive;
}
if (!opts.noout)
- write_translation_unit(*tu, 0, cout);
+ {
+ const write_context_sptr& ctxt
+ = create_write_context(tu->get_environment(), cout);
+ write_translation_unit(*ctxt, *tu, 0);
+ }
return 0;
}
else
if (tu)
{
if (opts.diff)
- r = write_translation_unit(*tu, /*indent=*/0,
- tmp_file->get_stream());
+ {
+ const write_context_sptr& ctxt = create_write_context(
+ tu->get_environment(), tmp_file->get_stream());
+ r = write_translation_unit(*ctxt, *tu, 0);
+ }
if (!opts.noout && !opts.diff)
- r &= write_translation_unit(*tu, /*indent=*/0, cout);
+ {
+ const write_context_sptr& ctxt
+ = create_write_context(tu->get_environment(), cout);
+ r &= write_translation_unit(*ctxt, *tu, 0);
+ }
}
else
{