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