// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
-#ifndef __WXSTREAM_H__
-#define __WXSTREAM_H__
+#ifndef _WX_WXSTREAM_H__
+#define _WX_WXSTREAM_H__
#ifdef __GNUG__
#pragma interface
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);
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);
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); }
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;
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); }
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;
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