]> git.saurik.com Git - wxWidgets.git/blob - include/wx/stream.h
8ee9d1b8df49f8dd225b5c4078d1558bacb8ca79
[wxWidgets.git] / include / wx / stream.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: stream.h
3 // Purpose: "wxWindows stream" base classes
4 // Author: Guilhem Lavaux
5 // Modified by:
6 // Created: 11/07/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Guilhem Lavaux
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef __WXSTREAM_H__
13 #define __WXSTREAM_H__
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include <stdio.h>
20 #include <wx/object.h>
21 #include <wx/string.h>
22
23 /*
24 * wxStream: base classes
25 */
26
27 typedef enum {
28 wxBeginPosition = 0, wxCurrentPosition = 1, wxEndPosition = 2
29 } wxWhenceType;
30
31 class wxOutputStream;
32 class wxInputStream: public wxObject {
33 DECLARE_ABSTRACT_CLASS(wxInputStream)
34 public:
35 wxInputStream();
36 virtual ~wxInputStream();
37
38 virtual wxInputStream& Read(void *buffer, size_t size) = 0;
39 wxInputStream& Read(wxOutputStream& stream_out);
40
41 virtual size_t SeekI(int pos, wxWhenceType whence = wxBeginPosition) = 0;
42 virtual size_t TellI() const = 0;
43
44 virtual bool Eof() const = 0;
45 virtual size_t LastRead() const = 0;
46 };
47
48 class wxOutputStream: public wxObject {
49 DECLARE_ABSTRACT_CLASS(wxOutputStream)
50 public:
51 wxOutputStream();
52 virtual ~wxOutputStream();
53
54 virtual wxOutputStream& Write(const void *buffer, size_t size) = 0;
55 wxOutputStream& Write(wxInputStream& stream_in);
56
57 virtual size_t SeekO(int pos, wxWhenceType whence = wxBeginPosition) = 0;
58 virtual size_t TellO() const = 0;
59
60 virtual bool Bad() const = 0;
61 virtual size_t LastWrite() const = 0;
62
63 virtual void Sync() {}
64 };
65
66 class wxStream: public wxInputStream, public wxOutputStream {
67 DECLARE_ABSTRACT_CLASS(wxStream)
68 public:
69 wxStream() : wxInputStream(), wxOutputStream() {}
70 virtual ~wxStream() {}
71 };
72
73 /*
74 * "Filter" streams
75 */
76
77 class wxFilterInputStream: public wxInputStream {
78 DECLARE_CLASS(wxFilterInputStream)
79 public:
80 wxFilterInputStream(wxInputStream& stream);
81 virtual ~wxFilterInputStream();
82
83 virtual wxInputStream& Read(void *buffer, size_t size)
84 { return m_parent_i_stream->Read(buffer, size); }
85 virtual size_t SeekI(int pos, wxWhenceType whence = wxBeginPosition)
86 { return m_parent_i_stream->SeekI(pos, whence); }
87
88 virtual bool Eof() const { return m_parent_i_stream->Eof(); }
89 virtual size_t LastRead() const { return m_parent_i_stream->LastRead(); }
90 protected:
91 wxInputStream *m_parent_i_stream;
92 };
93
94 class wxFilterOutputStream: public wxOutputStream {
95 DECLARE_CLASS(wxFilterOutputStream)
96 public:
97 wxFilterOutputStream(wxOutputStream& stream);
98 virtual ~wxFilterOutputStream();
99
100 virtual wxOutputStream& Write(const void *buffer, size_t size)
101 { return m_parent_o_stream->Write(buffer, size); }
102 virtual size_t SeekO(int pos, wxWhenceType whence = wxBeginPosition)
103 { return m_parent_o_stream->SeekO(pos, whence); }
104
105 virtual bool Bad() const { return m_parent_o_stream->Bad(); }
106 virtual size_t LastWrite() const { return m_parent_o_stream->LastWrite(); }
107
108 protected:
109 wxOutputStream *m_parent_o_stream;
110 };
111
112 #endif