]>
Commit | Line | Data |
---|---|---|
32fc4afb GL |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: mstream.h | |
3 | // Purpose: Memory stream 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 licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | #ifndef __WXMMSTREAM_H__ | |
12 | #define __WXMMSTREAM_H__ | |
13 | ||
79c3e0e1 | 14 | #include <wx/stream.h> |
32fc4afb | 15 | |
79c3e0e1 GL |
16 | class wxMemoryStreamBase { |
17 | protected: | |
18 | wxMemoryStreamBase(); | |
32fc4afb GL |
19 | virtual ~wxMemoryStreamBase(); |
20 | ||
32fc4afb GL |
21 | bool ChangeBufferSize(size_t new_length); |
22 | ||
23 | protected: | |
79c3e0e1 | 24 | bool m_persistent; |
32fc4afb | 25 | size_t m_length; |
32fc4afb GL |
26 | char *m_buffer; |
27 | int m_iolimit; | |
28 | }; | |
29 | ||
79c3e0e1 | 30 | class wxMemoryInputStream: virtual public wxMemoryStreamBase, public wxInputStream { |
32fc4afb | 31 | public: |
79c3e0e1 GL |
32 | wxMemoryInputStream(const char *data, size_t length); |
33 | virtual ~wxMemoryInputStream(); | |
79c3e0e1 | 34 | |
1678ad78 GL |
35 | protected: |
36 | ||
37 | size_t DoRead(void *buffer, size_t size); | |
38 | off_t DoSeekInput(off_t pos, wxSeekMode mode); | |
39 | off_t DoTellInput() const { return m_position_i; } | |
79c3e0e1 GL |
40 | |
41 | protected: | |
79c3e0e1 | 42 | off_t m_position_i; |
32fc4afb GL |
43 | }; |
44 | ||
79c3e0e1 | 45 | class wxMemoryOutputStream: virtual public wxMemoryStreamBase, public wxOutputStream { |
32fc4afb | 46 | public: |
79c3e0e1 GL |
47 | wxMemoryOutputStream(char *data = NULL, size_t length = 0); |
48 | virtual ~wxMemoryOutputStream(); | |
49 | ||
1678ad78 GL |
50 | char *GetData() { Sync(); return m_buffer; } |
51 | size_t GetLength() { Sync(); return m_length; } | |
79c3e0e1 | 52 | |
1678ad78 | 53 | protected: |
79c3e0e1 | 54 | |
1678ad78 GL |
55 | size_t DoWrite(const void *buffer, size_t size); |
56 | off_t DoSeekOutput(off_t pos, wxSeekMode mode); | |
57 | off_t DoTellOutput() const { return m_position_o; } | |
79c3e0e1 GL |
58 | |
59 | protected: | |
79c3e0e1 | 60 | off_t m_position_o; |
32fc4afb GL |
61 | }; |
62 | ||
79c3e0e1 | 63 | class wxMemoryStream: public wxMemoryInputStream, public wxMemoryOutputStream { |
32fc4afb | 64 | public: |
79c3e0e1 GL |
65 | wxMemoryStream(char *data = NULL, size_t length = 0); |
66 | virtual ~wxMemoryStream(); | |
32fc4afb GL |
67 | }; |
68 | ||
69 | #endif |