Version: 3.0.3
wxStringOutputStream Class Reference

#include <wx/sstream.h>

+ Inheritance diagram for wxStringOutputStream:

Detailed Description

This class implements an output stream which writes data either to a user-provided or internally allocated string.

Note that currently this stream does not support seeking but can tell its current position.

Library:  wxBase
Category:  Streams

Public Member Functions

 wxStringOutputStream (wxString *pString=0, wxMBConv &conv=wxConvUTF8)
 Construct a new stream object writing the data to a string. More...
 
const wxStringGetString () const
 Returns the string containing all the data written to the stream so far. More...
 
- Public Member Functions inherited from wxOutputStream
 wxOutputStream ()
 Creates a dummy wxOutputStream object. More...
 
virtual ~wxOutputStream ()
 Destructor. More...
 
virtual bool Close ()
 Closes the stream, returning false if an error occurs. More...
 
virtual size_t LastWrite () const
 Returns the number of bytes written during the last Write(). More...
 
void PutC (char c)
 Puts the specified character in the output queue and increments the stream position. More...
 
virtual wxFileOffset SeekO (wxFileOffset pos, wxSeekMode mode=wxFromStart)
 Changes the stream current position. More...
 
virtual wxFileOffset TellO () const
 Returns the current stream position. More...
 
virtual wxOutputStreamWrite (const void *buffer, size_t size)
 Writes up to the specified amount of bytes using the data of buffer. More...
 
wxOutputStreamWrite (wxInputStream &stream_in)
 Reads data from the specified input stream and stores them in the current stream. More...
 
bool WriteAll (const void *buffer, size_t size)
 Writes exactly the specified number of bytes from the buffer. More...
 
- Public Member Functions inherited from wxStreamBase
 wxStreamBase ()
 Creates a dummy stream object. More...
 
virtual ~wxStreamBase ()
 Destructor. More...
 
wxStreamError GetLastError () const
 This function returns the last error. More...
 
virtual wxFileOffset GetLength () const
 Returns the length of the stream in bytes. More...
 
virtual size_t GetSize () const
 This function returns the size of the stream. More...
 
virtual bool IsOk () const
 Returns true if no error occurred on the stream. More...
 
virtual bool IsSeekable () const
 Returns true if the stream supports seeking to arbitrary offsets. More...
 
void Reset (wxStreamError error=wxSTREAM_NO_ERROR)
 Resets the stream state. More...
 
bool operator! () const
 Returns the opposite of IsOk(). More...
 

Additional Inherited Members

- Protected Member Functions inherited from wxOutputStream
size_t OnSysWrite (const void *buffer, size_t bufsize)
 Internal function. More...
 
- Protected Member Functions inherited from wxStreamBase
virtual wxFileOffset OnSysSeek (wxFileOffset pos, wxSeekMode mode)
 Internal function. More...
 
virtual wxFileOffset OnSysTell () const
 Internal function. More...
 

Constructor & Destructor Documentation

wxStringOutputStream::wxStringOutputStream ( wxString pString = 0,
wxMBConv conv = wxConvUTF8 
)

Construct a new stream object writing the data to a string.

If the provided pointer is non-NULL, data will be written to it. Otherwise, an internal string is used for the data written to this stream, use GetString() to get access to it.

If str is used, data written to the stream is appended to the current contents of it, i.e. the string is not cleared here. However if it is not empty, the positions returned by wxOutputStream::TellO will be offset by the initial string length, i.e. initial stream position will be the initial length of the string and not 0.

Notice that the life time of conv must be greater than the life time of this object itself as it stores a reference to it. Also notice that with default value of this argument the data written to the stream must be valid UTF-8, pass wxConvISO8859_1 to deal with arbitrary 8 bit data.

Member Function Documentation

const wxString& wxStringOutputStream::GetString ( ) const

Returns the string containing all the data written to the stream so far.