]>
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(); | |
34 | ||
35 | wxInputStream& Read(void *buffer, size_t size); | |
36 | off_t SeekI(off_t pos, wxSeekMode mode); | |
37 | off_t TellI() const { return m_position_i; } | |
38 | ||
39 | bool Eof() const { return m_eof; } | |
40 | size_t LastRead() const { return m_lastread; } | |
41 | ||
42 | protected: | |
43 | bool m_eof; | |
44 | off_t m_position_i; | |
45 | size_t m_lastread; | |
32fc4afb GL |
46 | }; |
47 | ||
79c3e0e1 | 48 | class wxMemoryOutputStream: virtual public wxMemoryStreamBase, public wxOutputStream { |
32fc4afb | 49 | public: |
79c3e0e1 GL |
50 | wxMemoryOutputStream(char *data = NULL, size_t length = 0); |
51 | virtual ~wxMemoryOutputStream(); | |
52 | ||
53 | wxOutputStream& Write(const void *buffer, size_t size); | |
54 | off_t SeekO(off_t pos, wxSeekMode mode); | |
55 | off_t TellO() const { return m_position_o; } | |
56 | ||
57 | bool Bad() const { return m_bad; } | |
58 | size_t LastWrite() const { return m_lastwrite; } | |
59 | ||
60 | char *GetData() { return m_buffer; } | |
61 | size_t GetLength() { return m_length; } | |
62 | ||
63 | protected: | |
64 | bool m_bad; | |
65 | off_t m_position_o; | |
66 | size_t m_lastwrite; | |
32fc4afb GL |
67 | }; |
68 | ||
79c3e0e1 | 69 | class wxMemoryStream: public wxMemoryInputStream, public wxMemoryOutputStream { |
32fc4afb | 70 | public: |
79c3e0e1 GL |
71 | wxMemoryStream(char *data = NULL, size_t length = 0); |
72 | virtual ~wxMemoryStream(); | |
32fc4afb GL |
73 | }; |
74 | ||
75 | #endif |