write_context: allow mutating the ostream used
authorMatthias Maennich <maennich@google.com>
Tue, 21 May 2019 04:39:18 +0000 (05:39 +0100)
committerDodji Seketeli <dodji@redhat.com>
Wed, 22 May 2019 12:33:45 +0000 (14:33 +0200)
commit6c07e829335060e434804fb7d7353cd64aac70a2
tree85aa7abf442532a7f8a091fe70169fab1ad932b5
parent6aeed171c1ae4775b96666f17bb4f82a7ac80ea1
write_context: allow mutating the ostream used

Allowing the mutation of the ostream, allows heavy reuse of the
write_context as this is the distinction in most places where
write_context is used.

Hence, fixup various users of write_context and use common objects where
applicable.

* include/abg-writer.h (set_ostream): Declare new function.
* src/abg-writer.cc (write_context::m_ostream): Make this data
member be a pointer rather than a reference.
(write_context::{write_context, get_ostream): Adjust.  member.
(write_context::set_ostream): Define new member function.
(set_ostream): Define new free-form function.
* tools/abidw.cc (load_corpus_and_write_abixml)
(load_kernel_corpus_group_and_write_abixml): Use the feature of
mutating the ostream and reuse the write_context in most cases.

Signed-off-by: Matthias Maennich <maennich@google.com>
include/abg-writer.h
src/abg-writer.cc
tools/abidw.cc