xtd - Reference Guide 0.2.0
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 {
24  public:
26 
31  explicit ostream_trace_listener(const std::ostream& ostream);
36 
38 
42  virtual const std::ostream& ostream() const;
45  virtual void ostream(const std::ostream& ostream);
47 
49 
51  void close() override;
52  void flush() override {
53  #if !defined(NDEBUG) || defined(DEBUG) || defined(TRACE)
54  flush_();
55  #endif
56  }
57 
59  void write(const xtd::ustring& message) override {
60  #if !defined(NDEBUG) || defined(DEBUG) || defined(TRACE)
61  write_(message);
62  #endif
63  }
64 
66  void write_line(const xtd::ustring& message) override {
67  #if !defined(NDEBUG) || defined(DEBUG) || defined(TRACE)
68  write_line_(message);
69  #endif
70  }
72 
73  private:
74  void flush_();
75  void write_(const xtd::ustring& message);
76  void write_line_(const xtd::ustring& message);
77  std::ostream ostream_ {nullptr};
78  };
79  }
80 }
Provides the abstract base class for the listeners who monitor trace and debug output.
Definition: trace_listener.h:33
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:258
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:50
void flush() override
When overridden in a derived class, flushes the output buffer.
Definition: ostream_trace_listener.h:52
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:66
Directs tracing or debugging output to a std::ostream, such as std::fstream, std::stream...
Definition: ostream_trace_listener.h:23
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:59
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:281
Contains xtd::diagnostics::trace_listener listener.