]>
Commit | Line | Data |
---|---|---|
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 | #include "wx/filefn.h" // for off_t and wxSeekMode | |
23 | ||
24 | /* | |
25 | * wxStream: base classes | |
26 | */ | |
27 | class wxOutputStream; | |
28 | class wxInputStream: virtual public wxObject { | |
29 | DECLARE_ABSTRACT_CLASS(wxInputStream) | |
30 | public: | |
31 | wxInputStream(); | |
32 | virtual ~wxInputStream(); | |
33 | ||
34 | virtual wxInputStream& Read(void *buffer, size_t size) = 0; | |
35 | wxInputStream& Read(wxOutputStream& stream_out); | |
36 | ||
37 | virtual off_t SeekI(off_t pos, wxSeekMode mode = wxFromStart) = 0; | |
38 | virtual off_t TellI() const = 0; | |
39 | ||
40 | virtual bool Eof() const = 0; | |
41 | virtual size_t LastRead() const = 0; | |
42 | ||
43 | wxInputStream& operator>>(wxOutputStream& out) { return Read(out); } | |
44 | }; | |
45 | ||
46 | class wxOutputStream: virtual public wxObject { | |
47 | DECLARE_ABSTRACT_CLASS(wxOutputStream) | |
48 | public: | |
49 | wxOutputStream(); | |
50 | virtual ~wxOutputStream(); | |
51 | ||
52 | virtual wxOutputStream& Write(const void *buffer, size_t size) = 0; | |
53 | wxOutputStream& Write(wxInputStream& stream_in); | |
54 | ||
55 | virtual off_t SeekO(off_t pos, wxSeekMode mode = wxFromStart) = 0; | |
56 | virtual off_t TellO() const = 0; | |
57 | ||
58 | virtual bool Bad() const = 0; | |
59 | virtual size_t LastWrite() const = 0; | |
60 | ||
61 | virtual void Sync() {} | |
62 | }; | |
63 | ||
64 | /* | |
65 | * "Filter" streams | |
66 | */ | |
67 | ||
68 | class wxFilterInputStream: public wxInputStream { | |
69 | DECLARE_CLASS(wxFilterInputStream) | |
70 | public: | |
71 | wxFilterInputStream(wxInputStream& stream); | |
72 | virtual ~wxFilterInputStream(); | |
73 | ||
74 | virtual wxInputStream& Read(void *buffer, size_t size) | |
75 | { return m_parent_i_stream->Read(buffer, size); } | |
76 | virtual off_t SeekI(off_t pos, wxSeekMode mode = wxFromStart) | |
77 | { return m_parent_i_stream->SeekI(pos, mode); } | |
78 | virtual off_t TellI() const | |
79 | { return m_parent_i_stream->TellI(); } | |
80 | ||
81 | virtual bool Eof() const { return m_parent_i_stream->Eof(); } | |
82 | virtual size_t LastRead() const { return m_parent_i_stream->LastRead(); } | |
83 | ||
84 | protected: | |
85 | wxInputStream *m_parent_i_stream; | |
86 | }; | |
87 | ||
88 | class wxFilterOutputStream: public wxOutputStream { | |
89 | DECLARE_CLASS(wxFilterOutputStream) | |
90 | public: | |
91 | wxFilterOutputStream(wxOutputStream& stream); | |
92 | virtual ~wxFilterOutputStream(); | |
93 | ||
94 | virtual wxOutputStream& Write(const void *buffer, size_t size) | |
95 | { return m_parent_o_stream->Write(buffer, size); } | |
96 | virtual off_t SeekO(off_t pos, wxSeekMode mode = wxFromStart) | |
97 | { return m_parent_o_stream->SeekO(pos, mode); } | |
98 | virtual off_t TellO() const | |
99 | { return m_parent_o_stream->TellO(); } | |
100 | ||
101 | virtual bool Bad() const { return m_parent_o_stream->Bad(); } | |
102 | virtual size_t LastWrite() const { return m_parent_o_stream->LastWrite(); } | |
103 | ||
104 | protected: | |
105 | wxOutputStream *m_parent_o_stream; | |
106 | }; | |
107 | ||
108 | #endif |