Version: 3.1.1
wxBufferedOutputStream Class Reference

#include <wx/stream.h>

+ Inheritance diagram for wxBufferedOutputStream:

Detailed Description

This stream acts as a cache.

It caches the bytes to be written to the specified output stream (See wxFilterOutputStream). The data is only written when the cache is full, when the buffered stream is destroyed or when calling SeekO().

This class may not be used without some other stream to write the data to (such as a file stream or a memory stream).

Library:  wxBase
Category:  Streams
See also
wxStreamBuffer, wxOutputStream

Public Member Functions

 wxBufferedOutputStream (wxOutputStream &stream, wxStreamBuffer *buffer=NULL)
 Constructor using the provided buffer or default. More...
 
 wxBufferedOutputStream (wxOutputStream &stream, size_t bufsize)
 Constructor allowing to specify the size of the buffer. More...
 
virtual ~wxBufferedOutputStream ()
 Destructor. More...
 
virtual wxFileOffset SeekO (wxFileOffset pos, wxSeekMode mode=wxFromStart)
 Calls Sync() and changes the stream position. More...
 
virtual void Sync ()
 Flushes the buffer and calls Sync() on the parent stream. More...
 
- Public Member Functions inherited from wxFilterOutputStream
 wxFilterOutputStream (wxOutputStream &stream)
 Initializes a "filter" stream. More...
 
 wxFilterOutputStream (wxOutputStream *stream)
 Initializes a "filter" stream. 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 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

wxBufferedOutputStream::wxBufferedOutputStream ( wxOutputStream stream,
wxStreamBuffer buffer = NULL 
)

Constructor using the provided buffer or default.

Parameters
streamThe associated low-level stream.
bufferThe buffer to use if non-NULL. Notice that the ownership of this buffer is taken by the stream, i.e. it will delete it. If this parameter is NULL a default 1KB buffer is used.
wxBufferedOutputStream::wxBufferedOutputStream ( wxOutputStream stream,
size_t  bufsize 
)

Constructor allowing to specify the size of the buffer.

This is just a more convenient alternative to creating a wxStreamBuffer of the given size and using the other overloaded constructor of this class.

Parameters
streamThe associated low-level stream.
bufsizeThe size of the buffer, in bytes.
Since
2.9.0
virtual wxBufferedOutputStream::~wxBufferedOutputStream ( )
virtual

Destructor.

Calls Sync() and destroys the internal buffer.

Member Function Documentation

virtual wxFileOffset wxBufferedOutputStream::SeekO ( wxFileOffset  pos,
wxSeekMode  mode = wxFromStart 
)
virtual

Calls Sync() and changes the stream position.

Reimplemented from wxOutputStream.

virtual void wxBufferedOutputStream::Sync ( )
virtual

Flushes the buffer and calls Sync() on the parent stream.