From c6b1d1dd870b3370d0a09fb4600e3a6b03326f35 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 23 Nov 2022 08:57:45 +0200 Subject: Rework diag_buffer interface to facilitate correct destruction order --- libbuild2/diagnostics.ixx | 63 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'libbuild2/diagnostics.ixx') diff --git a/libbuild2/diagnostics.ixx b/libbuild2/diagnostics.ixx index a082290..273dfad 100644 --- a/libbuild2/diagnostics.ixx +++ b/libbuild2/diagnostics.ixx @@ -3,6 +3,8 @@ namespace build2 { + // print_diag() + // LIBBUILD2_SYMEXPORT void print_diag_impl (const char*, target_key*, target_key&&, const char*); @@ -60,4 +62,65 @@ namespace build2 { print_diag (p, l, path_name (&r), c); } + + // diag_buffer + // + inline diag_buffer:: + diag_buffer (context& ctx) + : is (ifdstream::badbit), ctx_ (ctx) + { + } + + inline diag_buffer:: + diag_buffer (context& ctx, vector&& b) + : is (ifdstream::badbit), buf (move (b)), ctx_ (ctx) + { + buf.clear (); + } + + inline diag_buffer:: + diag_buffer (context& ctx, const char* args0, auto_fd&& fd, fdstream_mode m) + : diag_buffer (ctx) + { + open (args0, move (fd), m); + } + + inline diag_buffer:: + diag_buffer (context& ctx, const char* args0, process& pr, fdstream_mode m) + : diag_buffer (ctx) + { + open (args0, move (pr.in_efd), m); + } + + inline diag_buffer:: + diag_buffer (context& ctx, + vector&& b, + const char* args0, + auto_fd&& fd, + fdstream_mode m) + : diag_buffer (ctx, move (b)) + { + open (args0, move (fd), m); + } + + inline diag_buffer:: + diag_buffer (context& ctx, + vector&& b, + const char* args0, + process& pr, + fdstream_mode m) + : diag_buffer (ctx, move (b)) + { + open (args0, move (pr.in_efd), m); + } + + inline void diag_buffer:: + close (const cstrings& args, + const process_exit& pe, + uint16_t verbosity, + bool omit_normal, + const location& loc) + { + close (args.data (), pe, verbosity, omit_normal, loc); + } } -- cgit v1.1