]>
Commit | Line | Data |
---|---|---|
32fc4afb GL |
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__ | |
79c3e0e1 | 16 | #pragma interface |
32fc4afb GL |
17 | #endif |
18 | ||
19 | #include <stdio.h> | |
45ea509a VZ |
20 | #include "wx/object.h" |
21 | #include "wx/string.h" | |
22 | #include "wx/filefn.h" // for off_t and wxSeekMode | |
eda3efe2 | 23 | |
32fc4afb GL |
24 | /* |
25 | * wxStream: base classes | |
26 | */ | |
32fc4afb | 27 | class wxOutputStream; |
e49f47aa | 28 | class wxInputStream { |
32fc4afb GL |
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 | ||
79c3e0e1 GL |
36 | virtual off_t SeekI(off_t pos, wxSeekMode mode = wxFromStart) = 0; |
37 | virtual off_t TellI() const = 0; | |
32fc4afb GL |
38 | |
39 | virtual bool Eof() const = 0; | |
40 | virtual size_t LastRead() const = 0; | |
0cd9bfe8 GL |
41 | |
42 | wxInputStream& operator>>(wxOutputStream& out) { return Read(out); } | |
32fc4afb GL |
43 | }; |
44 | ||
e49f47aa | 45 | class wxOutputStream { |
32fc4afb GL |
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 | ||
79c3e0e1 GL |
53 | virtual off_t SeekO(off_t pos, wxSeekMode mode = wxFromStart) = 0; |
54 | virtual off_t TellO() const = 0; | |
32fc4afb GL |
55 | |
56 | virtual bool Bad() const = 0; | |
57 | virtual size_t LastWrite() const = 0; | |
58 | ||
59 | virtual void Sync() {} | |
60 | }; | |
61 | ||
32fc4afb GL |
62 | /* |
63 | * "Filter" streams | |
64 | */ | |
65 | ||
66 | class wxFilterInputStream: public wxInputStream { | |
32fc4afb GL |
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); } | |
79c3e0e1 GL |
73 | virtual off_t SeekI(off_t pos, wxSeekMode mode = wxFromStart) |
74 | { return m_parent_i_stream->SeekI(pos, mode); } | |
0cd9bfe8 GL |
75 | virtual off_t TellI() const |
76 | { return m_parent_i_stream->TellI(); } | |
32fc4afb GL |
77 | |
78 | virtual bool Eof() const { return m_parent_i_stream->Eof(); } | |
79 | virtual size_t LastRead() const { return m_parent_i_stream->LastRead(); } | |
79c3e0e1 | 80 | |
32fc4afb GL |
81 | protected: |
82 | wxInputStream *m_parent_i_stream; | |
83 | }; | |
84 | ||
219f895a | 85 | class wxFilterOutputStream: public wxOutputStream { |
32fc4afb GL |
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); } | |
79c3e0e1 GL |
92 | virtual off_t SeekO(off_t pos, wxSeekMode mode = wxFromStart) |
93 | { return m_parent_o_stream->SeekO(pos, mode); } | |
0cd9bfe8 GL |
94 | virtual off_t TellO() const |
95 | { return m_parent_o_stream->TellO(); } | |
32fc4afb | 96 | |
219f895a RR |
97 | virtual bool Bad() const { return m_parent_o_stream->Bad(); } |
98 | virtual size_t LastWrite() const { return m_parent_o_stream->LastWrite(); } | |
32fc4afb GL |
99 | |
100 | protected: | |
101 | wxOutputStream *m_parent_o_stream; | |
102 | }; | |
103 | ||
104 | #endif |