X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/123a7fddb89d0d39f8c280aea95182d054c8887b..cb43b372fb1567caf7ccfa523aca10c676ceaec4:/include/wx/stream.h diff --git a/include/wx/stream.h b/include/wx/stream.h index a2f1c0f89b..3013273cba 100644 --- a/include/wx/stream.h +++ b/include/wx/stream.h @@ -9,8 +9,8 @@ // Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// -#ifndef __WXSTREAM_H__ -#define __WXSTREAM_H__ +#ifndef _WX_WXSTREAM_H__ +#define _WX_WXSTREAM_H__ #ifdef __GNUG__ #pragma interface @@ -29,6 +29,17 @@ typedef wxOutputStream& (*__wxOutputManip)(wxOutputStream&); wxOutputStream& WXDLLEXPORT wxEndL(wxOutputStream& o_stream); +// Disable warnings such as +// 'wxFilterStream' : inherits 'wxFilterInputStream::Peek' via dominance + +#ifdef _MSC_VER +#pragma warning(disable:4250) +#endif + +// --------------------------------------------------------------------------- +// Stream buffer +// --------------------------------------------------------------------------- + class WXDLLEXPORT wxStreamBuffer { public: wxStreamBuffer(wxInputStream& stream); @@ -63,16 +74,17 @@ class WXDLLEXPORT wxStreamBuffer { wxOutputStream *m_ostream; }; -/* - * wxStream: base classes - */ +// --------------------------------------------------------------------------- +// wxStream: base classes +// --------------------------------------------------------------------------- + class WXDLLEXPORT wxInputStream { public: wxInputStream(); virtual ~wxInputStream(); // IO functions - virtual char Peek() = 0; + virtual char Peek() { return 0; } virtual char GetC(); virtual wxInputStream& Read(void *buffer, size_t size); wxInputStream& Read(wxOutputStream& stream_out); @@ -94,7 +106,9 @@ class WXDLLEXPORT wxInputStream { wxInputStream& operator>>(int& i); wxInputStream& operator>>(long& i); wxInputStream& operator>>(float& i); +#if USE_SERIAL wxInputStream& operator>>(wxObject *& obj); +#endif wxInputStream& operator>>(unsigned char& c) { return operator>>((char&)c); } wxInputStream& operator>>(unsigned short& i) { return operator>>((short&)i); } @@ -108,9 +122,12 @@ class WXDLLEXPORT wxInputStream { wxInputStream(wxStreamBuffer *buffer); - virtual size_t DoRead(void *buffer, size_t size) = 0; - virtual off_t DoSeekInput(off_t pos, wxSeekMode mode) = 0; - virtual off_t DoTellInput() const = 0; + virtual size_t DoRead(void *WXUNUSED(buffer), size_t WXUNUSED(size) ) + { return 0; } + virtual off_t DoSeekInput( off_t WXUNUSED(pos), wxSeekMode WXUNUSED(mode) ) + { return wxInvalidOffset; } + virtual off_t DoTellInput() const + { return wxInvalidOffset; } protected: bool m_eof, m_i_destroybuf; @@ -143,7 +160,9 @@ class WXDLLEXPORT wxOutputStream { wxOutputStream& operator<<(int i); wxOutputStream& operator<<(long i); wxOutputStream& operator<<(double f); +#if USE_SERIAL wxOutputStream& operator<<(wxObject& obj); +#endif wxOutputStream& operator<<(float f) { return operator<<((double)f); } wxOutputStream& operator<<(unsigned char c) { return operator<<((char)c); } @@ -158,9 +177,12 @@ class WXDLLEXPORT wxOutputStream { wxOutputStream(wxStreamBuffer *buffer); - virtual size_t DoWrite(const void *buffer, size_t size) = 0; - virtual off_t DoSeekOutput(off_t pos, wxSeekMode mode) = 0; - virtual off_t DoTellOutput() const = 0; + virtual size_t DoWrite( const void *WXUNUSED(buffer), size_t WXUNUSED(size) ) + { return 0; } + virtual off_t DoSeekOutput( off_t WXUNUSED(pos), wxSeekMode WXUNUSED(mode) ) + { return wxInvalidOffset; } + virtual off_t DoTellOutput() const + { return wxInvalidOffset; } protected: bool m_bad, m_o_destroybuf; @@ -168,48 +190,69 @@ class WXDLLEXPORT wxOutputStream { wxStreamBuffer *m_o_streambuf; }; -/* - * "Filter" streams - */ +class wxStream: public virtual wxInputStream, + public virtual wxOutputStream +{ + public: + wxStream(); +}; + +// --------------------------------------------------------------------------- +// "Filter" streams +// --------------------------------------------------------------------------- -class WXDLLEXPORT wxFilterInputStream: public wxInputStream { +class WXDLLEXPORT wxFilterInputStream: public virtual wxInputStream { public: + wxFilterInputStream(); wxFilterInputStream(wxInputStream& stream); - virtual ~wxFilterInputStream(); + ~wxFilterInputStream(); - virtual char Peek() { return m_parent_i_stream->Peek(); } + char Peek() { return m_parent_i_stream->Peek(); } - virtual bool Eof() const { return m_parent_i_stream->Eof(); } - virtual size_t LastRead() const { return m_parent_i_stream->LastRead(); } - virtual off_t TellI() const { return m_parent_i_stream->TellI(); } + bool Eof() const { return m_parent_i_stream->Eof(); } + size_t LastRead() const { return m_parent_i_stream->LastRead(); } + off_t TellI() const { return m_parent_i_stream->TellI(); } protected: - virtual size_t DoRead(void *buffer, size_t size); - virtual off_t DoSeekInput(off_t pos, wxSeekMode mode); - virtual off_t DoTellInput() const; + size_t DoRead(void *buffer, size_t size); + off_t DoSeekInput(off_t pos, wxSeekMode mode); + off_t DoTellInput() const; protected: wxInputStream *m_parent_i_stream; }; -class WXDLLEXPORT wxFilterOutputStream: public wxOutputStream { +class WXDLLEXPORT wxFilterOutputStream: public virtual wxOutputStream { public: + wxFilterOutputStream(); wxFilterOutputStream(wxOutputStream& stream); virtual ~wxFilterOutputStream(); - virtual bool Bad() const { return m_parent_o_stream->Bad(); } - virtual size_t LastWrite() const { return m_parent_o_stream->LastWrite(); } - virtual off_t TellO() const { return m_parent_o_stream->TellO(); } + bool Bad() const { return m_parent_o_stream->Bad(); } + size_t LastWrite() const { return m_parent_o_stream->LastWrite(); } + off_t TellO() const { return m_parent_o_stream->TellO(); } protected: // The forward is implicitely done by wxStreamBuffer. - virtual size_t DoWrite(const void *buffer, size_t size); - virtual off_t DoSeekOutput(off_t pos, wxSeekMode mode); - virtual off_t DoTellOutput() const; + size_t DoWrite(const void *buffer, size_t size); + off_t DoSeekOutput(off_t pos, wxSeekMode mode); + off_t DoTellOutput() const; protected: wxOutputStream *m_parent_o_stream; }; +class WXDLLEXPORT wxFilterStream: public wxStream, + public virtual wxFilterInputStream, + public virtual wxFilterOutputStream { + public: + wxFilterStream(wxStream& stream); + wxFilterStream(); +}; + +#ifdef _MSC_VER +#pragma warning(default:4250) +#endif + #endif