xtd 0.2.0
Loading...
Searching...
No Matches
ostream_trace_listener.h
Go to the documentation of this file.
1
4#pragma once
5#include <ostream>
6#include "trace_listener.h"
7
9namespace xtd {
11 namespace diagnostics {
26 public:
28
33 explicit ostream_trace_listener(const std::ostream& ostream);
38
40
44 virtual const std::ostream& ostream() const;
47 virtual void ostream(const std::ostream& ostream);
49
51
53 void close() override;
54 void flush() override {
55 #if !defined(NDEBUG) || defined(DEBUG) || defined(TRACE)
56 flush_();
57 #endif
58 }
59
61 void write(const xtd::ustring& message) override {
62 #if !defined(NDEBUG) || defined(DEBUG) || defined(TRACE)
63 write_(message);
64 #endif
65 }
66
68 void write_line(const xtd::ustring& message) override {
69 #if !defined(NDEBUG) || defined(DEBUG) || defined(TRACE)
70 write_line_(message);
71 #endif
72 }
74
75 private:
76 void flush_();
77 void write_(const xtd::ustring& message);
78 void write_line_(const xtd::ustring& message);
79 std::ostream ostream_ {nullptr};
80 };
81 }
82}
Directs tracing or debugging output to a std::ostream, such as std::fstream, std::stream....
Definition ostream_trace_listener.h:25
void flush() override
When overridden in a derived class, flushes the output buffer.
Definition ostream_trace_listener.h:54
virtual const std::ostream & ostream() const
Gets the underlying stream.
void close() override
When overridden in a derived class, closes the output stream so it no longer receives tracing or debu...
ostream_trace_listener(const std::ostream &ostream)
Initializes a new instance of the xtd::diagnostics::ostream_trace_listener class with a specified ost...
void write(const xtd::ustring &message) override
Writes the message to the listener you create when you implement the trace_listener class.
Definition ostream_trace_listener.h:61
virtual void ostream(const std::ostream &ostream)
Sets the underlying stream.
void write_line(const xtd::ustring &message) override
Writes the message to the listener you create when you implement the trace_listener class followed by...
Definition ostream_trace_listener.h:68
Provides the abstract base class for the listeners who monitor trace and debug output.
Definition trace_listener.h:35
void write_line(const object &o)
Writes the value of the object's ToString method to the listener you create when you implement the Tr...
Definition trace_listener.h:283
void write(const object &o)
Writes the value of the object's ToString method to the listener you create when you implement the Tr...
Definition trace_listener.h:260
Represents text as a sequence of UTF-8 code units.
Definition ustring.h:47
#define core_export_
Define shared library export.
Definition core_export.h:13
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Contains xtd::diagnostics::trace_listener listener.