xtd 0.2.0
Loading...
Searching...
No Matches
ostream_trace_listener.hpp
Go to the documentation of this file.
1
4#pragma once
5#include <ostream>
6#include "trace_listener.hpp"
7
9namespace xtd {
11 namespace diagnostics {
28 public:
30
35 explicit ostream_trace_listener(const std::ostream& ostream);
40
42
46 virtual const std::ostream& ostream() const;
49 virtual void ostream(const std::ostream& ostream);
51
53
55 void close() override;
56 void flush() override {
57 #if DEBUG || TRACE
58 flush_();
59 #endif
60 }
61
63 void write(const xtd::string& message) override {
64 #if DEBUG || TRACE
65 write_(message);
66 #endif
67 }
68
70 void write_line(const xtd::string& message) override {
71 #if DEBUG || TRACE
72 write_line_(message);
73 #endif
74 }
75
76
77 private:
78 void flush_();
79 void write_(const xtd::string& message);
80 void write_line_(const xtd::string& message);
81 std::ostream ostream_ {nullptr};
82 };
83 }
84}
void flush() override
When overridden in a derived class, flushes the output buffer.
Definition ostream_trace_listener.hpp:56
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_line(const xtd::string &message) override
Writes the message to the listener you create when you implement the trace_listener class followed by...
Definition ostream_trace_listener.hpp:70
void write(const xtd::string &message) override
Writes the message to the listener you create when you implement the trace_listener class.
Definition ostream_trace_listener.hpp:63
virtual void ostream(const std::ostream &ostream)
Sets the underlying stream.
Provides the abstract base class for the listeners who monitor trace and debug output.
Definition trace_listener.hpp:42
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.hpp:290
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.hpp:267
#define core_export_
Define shared library export.
Definition core_export.hpp:13
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
The xtd::diagnostics namespace provides classes that allow you to interact with system processes,...
Definition assert_dialog_result.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Contains xtd::diagnostics::trace_listener listener.