]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/stream.h
Tried to find a non-existing bug in the cursor-code
[wxWidgets.git] / include / wx / stream.h
index 13ee1dce4289e75cbc0190a62e63bd4a17e2dbad..b467990588641fa6b0c43d9b558a80328a4b7299 100644 (file)
@@ -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,10 @@ typedef wxOutputStream& (*__wxOutputManip)(wxOutputStream&);
 
 wxOutputStream& WXDLLEXPORT wxEndL(wxOutputStream& o_stream);
 
+// ---------------------------------------------------------------------------
+// Stream buffer
+// ---------------------------------------------------------------------------
+
 class WXDLLEXPORT wxStreamBuffer {
  public:
   wxStreamBuffer(wxInputStream& stream);
@@ -63,16 +67,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);
@@ -91,8 +96,17 @@ class WXDLLEXPORT wxInputStream {
   wxInputStream& operator>>(wxString& line);
   wxInputStream& operator>>(char& c);
   wxInputStream& operator>>(short& i);
+  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& operator>>(unsigned int& i) { return operator>>((int&)i); }
+  wxInputStream& operator>>(unsigned long& i) { return operator>>((long&)i); }
   wxInputStream& operator>>( __wxInputManip func) { return func(*this); }
 
  protected:
@@ -101,9 +115,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;
@@ -136,13 +153,15 @@ 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); }
   wxOutputStream& operator<<(unsigned short i) { return operator<<((short)i); }
   wxOutputStream& operator<<(unsigned int i) { return operator<<((int)i); }
   wxOutputStream& operator<<(unsigned long i) { return operator<<((long)i); }
-
   wxOutputStream& operator<<( __wxOutputManip func) { return func(*this); }
 
  protected:
@@ -151,9 +170,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;
@@ -161,48 +183,65 @@ 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();
+};
+
 #endif