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.
Go to the documentation of this file.
1 #pragma once
6 #include "icontrol_trace.h"
9 namespace xtd {
11  namespace forms {
20  public:
27  control_trace_listener(xtd::forms::icontrol_trace& control_trace) : control_trace_(&control_trace) {}
39  virtual xtd::forms::icontrol_trace& control_trace() {return *control_trace_;}
50  static std::shared_ptr<xtd::diagnostics::trace_listener> create(xtd::forms::icontrol_trace& control_trace) {return std::make_shared<control_trace_listener>(control_trace);}
52  void close() override { }
54  void flush() override {
55 #if !defined(NDEBUG) || defined(DEBUG) || defined(TRACE)
56  if (control_trace_) control_trace_->flush();
57 #endif
58  }
60  using trace_listener::write;
63  void write(const xtd::ustring& message) override {
64 #if !defined(NDEBUG) || defined(DEBUG) || defined(TRACE)
65  if (need_indent()) write_indent();
66  if (control_trace_) control_trace_->write(message);
67 #endif
68  }
70  using trace_listener::write_line;
73  void write_line(const xtd::ustring& message) override {
74 #if !defined(NDEBUG) || defined(DEBUG) || defined(TRACE)
75  //write(message + "\n");
76  if (need_indent()) write_indent();
77  if (control_trace_) control_trace_->write_line(message);
78  need_indent(true);
79 #endif
80  }
83  private:
84  xtd::forms::icontrol_trace* control_trace_ = nullptr;
85  };
86  }
87 }
Provides the abstract base class for the listeners who monitor trace and debug output.
Definition: trace_listener.h:33
virtual void write_line(const xtd::ustring &message)=0
Write debug or trace message on this instance control followed by line terminator.
void close() override
When overridden in a derived class, closes the output stream so it no longer receives tracing or debu...
Definition: control_trace_listener.h:52
virtual void control_trace(xtd::forms::icontrol_trace &control_trace)
Set icontroll_trace object.
Definition: control_trace_listener.h:42
void write(const xtd::ustring &message) override
Writes the message to the listener you create when you implement the trace_listener class...
Definition: control_trace_listener.h:63
Directs tracing or debugging output to a icontrol_trace object.
Definition: control_trace_listener.h:19
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
control_trace_listener(xtd::forms::icontrol_trace &control_trace)
Initializes a new instance of the control_trace_listener class with specified control_trace.
Definition: control_trace_listener.h:27
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
virtual xtd::forms::icontrol_trace & control_trace()
Get icontroll_trace object.
Definition: control_trace_listener.h:39
virtual void write_indent()
Writes the indent to the listener you create when you implement this class, and resets the NeedIndent...
Definition: trace_listener.h:333
Contains xtd::forms::icontrol_trace interface.
void write_line(const xtd::ustring &message) override
Writes the message to the listener you create when you implement the trace_listener class...
Definition: control_trace_listener.h:73
Allow a control to be called by control_trace_listener for writing debug or trace message...
Definition: icontrol_trace.h:18
virtual void write(const xtd::ustring &message)=0
Write debug or trace message on this instance control.
virtual void flush()=0
Flushes the output buffer and causes buffered data to write to the control.
static std::shared_ptr< xtd::diagnostics::trace_listener > create(xtd::forms::icontrol_trace &control_trace)
Create new control_trace_listener.
Definition: control_trace_listener.h:50
Implements a Windows message.
Definition: message.h:25
bool need_indent() const
Gets a value indicating whether to indent the output.
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
Contains xtd::diagnostics::trace_listener listener.
void flush() override
When overridden in a derived class, flushes the output buffer.
Definition: control_trace_listener.h:54