wxStreamToTextRedirector Class Reference | wxWidgets

| Version: 3.2.11

Loading...
Searching...
No Matches
Public Member Functions | List of all members
wxStreamToTextRedirector Class Reference
Class List by Category » Logging

`#include </cygdrive/c/Users/Hamis/Cygwin-packaging/wxWidgets3.2/wxWidgets3.2-3.2.11-1.x86_64/src/wxWidgets-3.2.11/interface/wx/textctrl.h>`

## Detailed Description

This class can be used to (temporarily) redirect all output sent to a C++ ostream object to a wxTextCtrl instead.

Note
  Some compilers and/or build configurations don't support multiply inheriting wxTextCtrl from `std::streambuf` in which case this class is not compiled in. You also must have `wxUSE_STD_IOSTREAM` option on (i.e. set to 1) in your `setup.h` to be able to use it. Under Unix, specify `--enable-std_iostreams` switch when running configure for this.

Example of usage:

using namespace std;
wxTextCtrl* text = new wxTextCtrl(...);
{
wxStreamToTextRedirector redirect(text);
// this goes to the text control
cout << "Hello, text!" << endl;
}
// this goes somewhere else, presumably to stdout
cout << "Hello, console!" << endl;
wxStreamToTextRedirector::wxStreamToTextRedirector
wxStreamToTextRedirector(wxTextCtrl *text, ostream *ostr)
The constructor starts redirecting output sent to ostr or cout for the default parameter value to the...
wxTextCtrl
A text control allows text to be displayed and edited.
Definition textctrl.h:1436
endl
wxTextOutputStream & endl(wxTextOutputStream &stream)
Writes '\n' to stream.

##

Library: wxCore
Category: Logging

See also
  wxTextCtrl

## Public Member Functions
| wxStreamToTextRedirector (wxTextCtrl *text, ostream *ostr)
| The constructor starts redirecting output sent to ostr or cout for the default parameter value to the text control text.
| ~wxStreamToTextRedirector ()
| When a wxStreamToTextRedirector object is destroyed, the redirection is ended and any output sent to the C++ ostream which had been specified at the time of the object construction will go to its original destination.

## Constructor & Destructor Documentation

## ◆ wxStreamToTextRedirector()

wxStreamToTextRedirector::wxStreamToTextRedirector | ( | wxTextCtrl * | text,
|  | ostream * | ostr )

The constructor starts redirecting output sent to ostr or cout for the default parameter value to the text control text.

Parameters

  text | The text control to append output too, must be non-NULL
  ostr | The C++ stream to redirect, cout is used if it is NULL

## ◆ ~wxStreamToTextRedirector()

wxStreamToTextRedirector::~wxStreamToTextRedirector | ( |  | ) |

When a wxStreamToTextRedirector object is destroyed, the redirection is ended and any output sent to the C++ ostream which had been specified at the time of the object construction will go to its original destination.