wxWidgets: wxTextOutputStream Class Reference

| Version: 3.2.2

Public Member Functions | List of all members
wxTextOutputStream Class Reference
Class List by Category » Streams

`#include <wx/txtstrm.h>`

## Detailed Description

This class provides functions that write text data using an output stream, allowing you to write text, floats, and integers.

You can also simulate the C++ `std::cout` class:

wxFFileOutputStream output( stderr );
wxTextOutputStream cout( output );
cout << "This is a text line" << endl;
cout << 1234;
cout << 1.23456;
wxFFileOutputStream
This class represents data written to a file.
Definition: wfstream.h:118
wxTextOutputStream
This class provides functions that write text data using an output stream, allowing you to write text...
Definition: txtstrm.h:304
endl
wxTextOutputStream & endl(wxTextOutputStream &stream)
Writes '\n' to stream.

The wxTextOutputStream writes text files (or streams) on Windows or Unix in their native formats (concerning the line ending).

##

Library: wxBase
Category: Streams

See also
  wxTextInputStream

## Public Member Functions
| wxTextOutputStream (wxOutputStream &stream, wxEOL mode=wxEOL_NATIVE, const wxMBConv &conv=wxConvAuto())
| Constructs a text stream object associated to the given output stream. More...
virtual | ~wxTextOutputStream ()
| Destroys the wxTextOutputStream object. More...
void | Flush ()
| Flushes the stream. More...
const wxOutputStream & | GetOutputStream () const
| Returns a pointer to the underlying output stream object. More...
wxEOL | GetMode ()
| Returns the end-of-line mode. More...
wxTextOutputStream & | PutChar (wxChar c)
| Writes a character to the stream. More...
void | SetMode (wxEOL mode=wxEOL_NATIVE)
| Set the end-of-line mode. More...
template<typename T >
void | Write (const T &i)
| Writes i to the stream using wxString::operator<<(). More...
void | Write64 (wxUint64 i64)
| Writes the 64 bit unsigned integer i64 to the stream. More...
void | Write32 (wxUint32 i32)
| Writes the 32 bit unsigned integer i32 to the stream. More...
void | Write16 (wxUint16 i16)
| Writes the 16 bit unsigned integer i16 to the stream. More...
void | Write8 (wxUint8 i8)
| Writes the single unsigned byte i8 to the stream. More...
virtual void | WriteDouble (double f)
| Writes the double f to the stream using the IEEE format. More...
virtual void | WriteString (const wxString &string)
| Writes string as a line. More...
wxTextOutputStream & | operator<< (const wxString &string)
| Uses WriteString() to insert string. More...
wxTextOutputStream & | operator<< (char c)
| Uses WriteString() to insert c as ASCII. More...
wxTextOutputStream & | operator<< (wchar_t wc)
| Uses PutChar() to insert wc. More...
wxTextOutputStream & | operator<< (wxInt16 c)
| Uses Write() to insert c. More...
wxTextOutputStream & | operator<< (wxInt32 c)
| Uses Write() to insert c. More...
wxTextOutputStream & | operator<< (wxInt64 c)
| Uses Write() to insert c. More...
wxTextOutputStream & | operator<< (wxUint16 c)
| Uses Write() to insert c. More...
wxTextOutputStream & | operator<< (wxUint32 c)
| Uses Write() to insert c. More...
wxTextOutputStream & | operator<< (wxUint64 c)
| Uses Write() to insert c. More...
wxTextOutputStream & | operator<< (double f)
| Uses Write() to insert f. More...
wxTextOutputStream & | operator<< (float f)
| Uses Write() to insert f. More...
wxTextOutputStream & | operator<< (__wxTextOutputManip func)
| Calls `func(*this)`. More...

## Constructor & Destructor Documentation

## ◆ wxTextOutputStream()

wxTextOutputStream::wxTextOutputStream | ( | wxOutputStream & | stream,
|  | wxEOL | mode = `wxEOL_NATIVE`,
|  | const wxMBConv & | conv = `wxConvAuto()`
| ) |  |

Constructs a text stream object associated to the given output stream.

Parameters

  stream | The output stream.
  mode | The end-of-line mode. One of wxEOL_NATIVE, wxEOL_DOS, wxEOL_MAC and wxEOL_UNIX.
  conv | In Unicode build only: The object used to convert Unicode text into ASCII characters written to the output stream.

## ◆ ~wxTextOutputStream()

virtual wxTextOutputStream::~wxTextOutputStream | ( |  | ) |
| virtual

Destroys the wxTextOutputStream object.

Also calls Flush().

## Member Function Documentation

## ◆ Flush()

void wxTextOutputStream::Flush | ( |  | ) |

Flushes the stream.

This method should be called when using stateful encodings (currently the only example of such encoding in wxWidgets is wxMBConvUTF7) to write the end of the encoded data to the stream.

Since
  2.9.0

## ◆ GetMode()

wxEOL wxTextOutputStream::GetMode | ( |  | ) |

Returns the end-of-line mode.

One of wxEOL_DOS, wxEOL_MAC and wxEOL_UNIX.

## ◆ GetOutputStream()

const wxOutputStream& wxTextOutputStream::GetOutputStream | ( |  | ) | const

Returns a pointer to the underlying output stream object.

Since
  2.9.2

## ◆ operator<<() [1/12]

wxTextOutputStream& wxTextOutputStream::operator<< | ( | __wxTextOutputManip | func | ) |

Calls `func(*this)`.

## ◆ operator<<() [2/12]

wxTextOutputStream& wxTextOutputStream::operator<< | ( | char | c | ) |

Uses WriteString() to insert c as ASCII.

## ◆ operator<<() [3/12]

wxTextOutputStream& wxTextOutputStream::operator<< | ( | const wxString & | string | ) |

Uses WriteString() to insert string.

## ◆ operator<<() [4/12]

wxTextOutputStream& wxTextOutputStream::operator<< | ( | double | f | ) |

Uses Write() to insert f.

## ◆ operator<<() [5/12]

wxTextOutputStream& wxTextOutputStream::operator<< | ( | float | f | ) |

Uses Write() to insert f.

## ◆ operator<<() [6/12]

wxTextOutputStream& wxTextOutputStream::operator<< | ( | wchar_t | wc | ) |

Uses PutChar() to insert wc.

Note
  Only available in Unicode builds.

## ◆ operator<<() [7/12]

wxTextOutputStream& wxTextOutputStream::operator<< | ( | wxInt16 | c | ) |

Uses Write() to insert c.

## ◆ operator<<() [8/12]

wxTextOutputStream& wxTextOutputStream::operator<< | ( | wxInt32 | c | ) |

Uses Write() to insert c.

## ◆ operator<<() [9/12]

wxTextOutputStream& wxTextOutputStream::operator<< | ( | wxInt64 | c | ) |

Uses Write() to insert c.

## ◆ operator<<() [10/12]

wxTextOutputStream& wxTextOutputStream::operator<< | ( | wxUint16 | c | ) |

Uses Write() to insert c.

## ◆ operator<<() [11/12]

wxTextOutputStream& wxTextOutputStream::operator<< | ( | wxUint32 | c | ) |

Uses Write() to insert c.

## ◆ operator<<() [12/12]

wxTextOutputStream& wxTextOutputStream::operator<< | ( | wxUint64 | c | ) |

Uses Write() to insert c.

## ◆ PutChar()

wxTextOutputStream& wxTextOutputStream::PutChar | ( | wxChar | c | ) |

Writes a character to the stream.

## ◆ SetMode()

void wxTextOutputStream::SetMode | ( | wxEOL | mode = `wxEOL_NATIVE` | ) |

Set the end-of-line mode.

One of wxEOL_NATIVE, wxEOL_DOS, wxEOL_MAC and wxEOL_UNIX.

## ◆ Write()

template<typename T >

void wxTextOutputStream::Write | ( | const T & | i | ) |

Writes i to the stream using wxString::operator<<().

Since
  3.1.0

## ◆ Write16()

void wxTextOutputStream::Write16 | ( | wxUint16 | i16 | ) |

Writes the 16 bit unsigned integer i16 to the stream.

## ◆ Write32()

void wxTextOutputStream::Write32 | ( | wxUint32 | i32 | ) |

Writes the 32 bit unsigned integer i32 to the stream.

## ◆ Write64()

void wxTextOutputStream::Write64 | ( | wxUint64 | i64 | ) |

Writes the 64 bit unsigned integer i64 to the stream.

Since
  3.1.0

## ◆ Write8()

void wxTextOutputStream::Write8 | ( | wxUint8 | i8 | ) |

Writes the single unsigned byte i8 to the stream.

## ◆ WriteDouble()

virtual void wxTextOutputStream::WriteDouble | ( | double | f | ) |
| virtual

Writes the double f to the stream using the IEEE format.

## ◆ WriteString()

virtual void wxTextOutputStream::WriteString | ( | const wxString & | string | ) |
| virtual

Writes string as a line.

Depending on the end-of-line mode the end of line ('\n') characters in the string are converted to the correct line ending terminator.