wxTextOutputStream& PutChar(wxChar c);
+ void Flush();
+
wxTextOutputStream& operator<<(const wxString& string);
wxTextOutputStream& operator<<(char c);
#if wxUSE_UNICODE && wxWCHAR_T_IS_REAL_TYPE
@class wxTextOutputStream
@wxheader{txtstrm.h}
- This class provides functions that writes text data using an output stream,
+ 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++ cout class:
+ You can also simulate the C++ @c std::cout class:
@code
wxFFileOutputStream output( stderr );
/**
Destroys the wxTextOutputStream object.
+
+ Also calls Flush().
*/
~wxTextOutputStream();
+ /**
+ 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
+ */
+ void Flush();
+
/**
Returns the end-of-line mode. One of ::wxEOL_DOS, ::wxEOL_MAC and
::wxEOL_UNIX.
return *this;
}
+void wxTextOutputStream::Flush()
+{
+#if wxUSE_UNICODE
+ const size_t len = m_conv->FromWChar(NULL, 0, L"", 1);
+ if ( len > m_conv->GetMBNulLen() )
+ {
+ wxCharBuffer buf(len);
+ m_conv->FromWChar(buf.data(), len, L"", 1);
+ m_output.Write(buf, len - m_conv->GetMBNulLen());
+ }
+#endif // wxUSE_UNICODE
+}
+
wxTextOutputStream& wxTextOutputStream::operator<<(const wxString& string)
{
WriteString( string );
{
textOutputStream.PutChar( wideBuffer[i] );
}
+
+ textOutputStream.Flush();
+
CPPUNIT_ASSERT_EQUAL( (wxFileOffset)multiBytes, memoryOutputStream.TellO() );
wxCharBuffer copy( memoryOutputStream.TellO() );
memoryOutputStream.CopyTo( copy.data(), memoryOutputStream.TellO());