Version: 3.1.0
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.
 
 wxBufferedOutputStream (wxOutputStream &stream, size_t bufsize)
 Constructor allowing to specify the size of the buffer.
 
virtual ~wxBufferedOutputStream ()
 Destructor.
 
virtual wxFileOffset SeekO (wxFileOffset pos, wxSeekMode mode=wxFromStart)
 Calls Sync() and changes the stream position.
 
virtual void Sync ()
 Flushes the buffer and calls Sync() on the parent stream.
 
- Public Member Functions inherited from wxFilterOutputStream
 wxFilterOutputStream (wxOutputStream &stream)
 Initializes a "filter" stream.
 
 wxFilterOutputStream (wxOutputStream *stream)
 Initializes a "filter" stream.
 
- Public Member Functions inherited from wxOutputStream
 wxOutputStream ()
 Creates a dummy wxOutputStream object.
 
virtual ~wxOutputStream ()
 Destructor.
 
virtual bool Close ()
 Closes the stream, returning false if an error occurs.
 
virtual size_t LastWrite () const
 Returns the number of bytes written during the last Write().
 
void PutC (char c)
 Puts the specified character in the output queue and increments the stream position.
 
virtual wxFileOffset TellO () const
 Returns the current stream position.
 
virtual wxOutputStreamWrite (const void *buffer, size_t size)
 Writes up to the specified amount of bytes using the data of buffer.
 
wxOutputStreamWrite (wxInputStream &stream_in)
 Reads data from the specified input stream and stores them in the current stream.
 
bool WriteAll (const void *buffer, size_t size)
 Writes exactly the specified number of bytes from the buffer.
 
- Public Member Functions inherited from wxStreamBase
 wxStreamBase ()
 Creates a dummy stream object.
 
virtual ~wxStreamBase ()
 Destructor.
 
wxStreamError GetLastError () const
 This function returns the last error.
 
virtual wxFileOffset GetLength () const
 Returns the length of the stream in bytes.
 
virtual size_t GetSize () const
 This function returns the size of the stream.
 
virtual bool IsOk () const
 Returns true if no error occurred on the stream.
 
virtual bool IsSeekable () const
 Returns true if the stream supports seeking to arbitrary offsets.
 
void Reset (wxStreamError error=wxSTREAM_NO_ERROR)
 Resets the stream state.
 
bool operator! () const
 Returns the opposite of IsOk().
 

Additional Inherited Members

- Protected Member Functions inherited from wxOutputStream
size_t OnSysWrite (const void *buffer, size_t bufsize)
 Internal function.
 

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.