xtd - Reference Guide  0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
ostream_trace_listener.h
Go to the documentation of this file.
1 #pragma once
5 #include <ostream>
6 #include "trace_listener.h"
7 
9 namespace xtd {
11  namespace diagnostics {
19  public:
23  ostream_trace_listener(const std::ostream& ostream);
27 
30  virtual const std::ostream& ostream() const;
33  virtual void ostream(const std::ostream& ostream);
34 
35  void close() override;
36  void flush() override {
37 #if !defined(NDEBUG) || defined(DEBUG) || defined(TRACE)
38  flush_();
39 #endif
40  }
41 
43  void write(const xtd::ustring& message) override {
44 #if !defined(NDEBUG) || defined(DEBUG) || defined(TRACE)
45  write_(message);
46 #endif
47  }
48 
50  void write_line(const xtd::ustring& message) override {
51 #if !defined(NDEBUG) || defined(DEBUG) || defined(TRACE)
52  write_line_(message);
53 #endif
54  }
55 
56  private:
57  void flush_();
58  void write_(const xtd::ustring& message);
59  void write_line_(const xtd::ustring& message);
60  std::ostream ostream_ {nullptr};
61  };
62  }
63 }
Provides the abstract base class for the listeners who monitor trace and debug output.
Definition: trace_listener.h:28
void close() override
When overridden in a derived class, closes the output stream so it no longer receives tracing or debu...
void write(const object &o)
Writes the value of the object&#39;s ToString method to the listener you create when you implement the Tr...
Definition: trace_listener.h:242
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
void flush() override
When overridden in a derived class, flushes the output buffer.
Definition: ostream_trace_listener.h:36
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:50
Directs tracing or debugging output to a std::ostream, such as std::fstream, std::stream...
Definition: ostream_trace_listener.h:18
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:43
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_line(const object &o)
Writes the value of the object&#39;s ToString method to the listener you create when you implement the Tr...
Definition: trace_listener.h:265
Contains xtd::diagnostics::trace_listener listener.
virtual const std::ostream & ostream() const
Gets the underlying stream.