#include <wx/stream.h>
wxOutputStream is an abstract base class which may not be used directly.
It is the base class of all streams which provide a Write() function, i.e. which can be used to output data (e.g. to a file, to a socket, etc).
If you want to create your own output stream, you'll need to derive from this class and implement the protected OnSysWrite() function only.
Public Member Functions | |
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 | SeekO (wxFileOffset pos, wxSeekMode mode=wxFromStart) |
Changes the stream current position. | |
virtual wxFileOffset | TellO () const |
Returns the current stream position. | |
virtual wxOutputStream & | Write (const void *buffer, size_t size) |
Writes up to the specified amount of bytes using the data of buffer. | |
wxOutputStream & | Write (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(). | |
Protected Member Functions | |
size_t | OnSysWrite (const void *buffer, size_t bufsize) |
Internal function. | |
Protected Member Functions inherited from wxStreamBase | |
virtual wxFileOffset | OnSysSeek (wxFileOffset pos, wxSeekMode mode) |
Internal function. | |
virtual wxFileOffset | OnSysTell () const |
Internal function. | |
wxOutputStream::wxOutputStream | ( | ) |
Creates a dummy wxOutputStream object.
|
virtual |
Destructor.
|
virtual |
Closes the stream, returning false if an error occurs.
The stream is closed implicitly in the destructor if Close() is not called explicitly.
If this stream wraps another stream or some other resource such as a file, then the underlying resource is closed too if it is owned by this stream, or left open otherwise.
Reimplemented in wxZipOutputStream, wxTarOutputStream, and wxArchiveOutputStream.
|
virtual |
Returns the number of bytes written during the last Write().
It may return 0 even if there is no error on the stream if it is only temporarily impossible to write to it.
|
protected |
Internal function.
It is called when the stream wants to write data of the specified size bufsize into the given buffer.
It should return the size that was actually wrote (which maybe zero if bufsize is zero or if an error occurred; in this last case the internal variable m_lasterror
should be appropriately set).
void wxOutputStream::PutC | ( | char | c | ) |
Puts the specified character in the output queue and increments the stream position.
|
virtual |
Changes the stream current position.
pos | Offset to seek to. |
mode | One of wxFromStart, wxFromEnd, wxFromCurrent. |
Reimplemented in wxBufferedOutputStream.
|
virtual |
Returns the current stream position.
|
virtual |
Writes up to the specified amount of bytes using the data of buffer.
Note that not all data can always be written so you must check the number of bytes really written to the stream using LastWrite() when this function returns.
In some cases (for example a write end of a pipe which is currently full) it is even possible that there is no errors and zero bytes have been written. This function returns a reference on the current object, so the user can test any states of the stream right away.
wxOutputStream& wxOutputStream::Write | ( | wxInputStream & | stream_in | ) |
Reads data from the specified input stream and stores them in the current stream.
The data is read until an error is raised by one of the two streams.
bool wxOutputStream::WriteAll | ( | const void * | buffer, |
size_t | size | ||
) |
Writes exactly the specified number of bytes from the buffer.
Returns true if exactly size bytes were written. Otherwise, returns false and LastWrite() should be used to retrieve the exact amount of the data written if necessary.
This method uses repeated calls to Write() (which may return writing only part of the data) if necessary.