+ wxOutputStream& Write(wxInputStream& stream_in);
+
+protected:
+ /**
+ Internal function. It is called when the stream wants to write data of the
+ specified size @a bufsize into the given @a buffer.
+
+ It should return the size that was actually wrote (which maybe zero if
+ @a bufsize is zero or if an error occurred; in this last case the internal
+ variable @c m_lasterror should be appropriately set).
+ */
+ size_t OnSysWrite(const void* buffer, size_t bufsize);
+};
+
+
+/**
+ @class wxInputStream
+
+ wxInputStream is an abstract base class which may not be used directly.
+ It is the base class of all streams which provide a Read() function,
+ i.e. which can be used to read data from a source (e.g. a file, a socket, etc).
+
+ If you want to create your own input stream, you'll need to derive from this
+ class and implement the protected OnSysRead() function only.
+
+ @library{wxbase}
+ @category{streams}
+*/
+class wxInputStream : public wxStreamBase
+{
+public:
+ /**
+ Creates a dummy input stream.
+ */
+ wxInputStream();
+
+ /**
+ Destructor.
+ */
+ virtual ~wxInputStream();
+
+ /**
+ Returns @true if some data is available in the stream right now, so that
+ calling Read() wouldn't block.
+ */
+ virtual bool CanRead() const;
+
+ /**
+ Returns @true after an attempt has been made to read past the end of the
+ stream.
+ */
+ virtual bool Eof() const;
+
+ /**
+ Returns the first character in the input queue and removes it,
+ blocking until it appears if necessary.
+
+ On success returns a value between 0 - 255; on end of file returns @c wxEOF.
+ */
+ int GetC();
+
+ /**
+ Returns the last number of bytes read.
+ */
+ virtual size_t LastRead() const;
+
+ /**
+ Returns the first character in the input queue without removing it.
+ */
+ virtual char Peek();
+
+ /**
+ Reads the specified amount of bytes and stores the data in buffer.
+ To check if the call was successfull you must use LastRead() to check
+ if this call did actually read @a size bytes (if it didn't, GetLastError()
+ should return a meaningful value).
+
+ @warning
+ The buffer absolutely needs to have at least the specified size.
+
+ @return This function returns a reference on the current object, so the
+ user can test any states of the stream right away.
+ */
+ virtual wxInputStream& Read(void* buffer, size_t size);
+
+ /**
+ Reads data from the input queue and stores it in the specified output stream.
+ The data is read until an error is raised by one of the two streams.
+
+ @return This function returns a reference on the current object, so the
+ user can test any states of the stream right away.
+ */
+ wxInputStream& Read(wxOutputStream& stream_out);
+
+ /**
+ Changes the stream current position.
+
+ This operation in general is possible only for seekable streams
+ (see wxStreamBase::IsSeekable()); non-seekable streams support only
+ seeking positive amounts in mode @c wxFromCurrent (this is implemented
+ by reading data and simply discarding it).
+
+ @param pos
+ Offset to seek to.
+ @param mode
+ One of wxFromStart, wxFromEnd, wxFromCurrent.
+
+ @return The new stream position or ::wxInvalidOffset on error.
+ */
+ virtual wxFileOffset SeekI(wxFileOffset pos, wxSeekMode mode = wxFromStart);
+
+ /**
+ Returns the current stream position or ::wxInvalidOffset if it's not
+ available (e.g. socket streams do not have a size nor a current stream
+ position).
+ */
+ virtual wxFileOffset TellI() const;
+
+ /**
+ This function is only useful in read mode.
+ It is the manager of the "Write-Back" buffer. This buffer acts like a
+ temporary buffer where data which has to be read during the next read IO
+ call are put. This is useful when you get a big block of data which you
+ didn't want to read: you can replace them at the top of the input queue
+ by this way.
+
+ Be very careful about this call in connection with calling SeekI() on
+ the same stream. Any call to SeekI() will invalidate any previous call
+ to this method (otherwise you could SeekI() to one position, "unread" a
+ few bytes there, SeekI() to another position and data would be either
+ lost or corrupted).
+
+ @return Returns the amount of bytes saved in the Write-Back buffer.
+ */
+ size_t Ungetch(const void* buffer, size_t size);
+
+ /**
+ This function acts like the previous one except that it takes only one
+ character: it is sometimes shorter to use than the generic function.
+ */
+ bool Ungetch(char c);
+
+protected:
+
+ /**
+ Internal function. It is called when the stream wants to read data of the
+ specified size @a bufsize and wants it to be placed inside @a buffer.
+
+ It should return the size that was actually read or zero if EOF has been
+ reached or an error occurred (in this last case the internal @c m_lasterror
+ variable should be set accordingly as well).
+ */
+ size_t OnSysRead(void* buffer, size_t bufsize);