]>
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 | ||
219f895a RR |
14 | #include "wx/object.h" |
15 | #include "wx/stream.h" | |
32fc4afb GL |
16 | |
17 | class wxMemoryStreamBase: public wxStream { | |
3cacae09 | 18 | DECLARE_CLASS(wxMemoryStreamBase) |
32fc4afb GL |
19 | public: |
20 | wxMemoryStreamBase(char *data, size_t length, int iolimit); | |
21 | virtual ~wxMemoryStreamBase(); | |
22 | ||
23 | // Input part | |
24 | wxInputStream& Read(void *buffer, size_t size); | |
25 | size_t SeekI(int pos, wxWhenceType whence = wxBeginPosition); | |
26 | size_t TellI() const { return m_position_i; } | |
27 | ||
28 | bool Eof() const { return m_eof; } | |
29 | size_t LastRead() const { return m_lastread; } | |
30 | ||
31 | // Output part | |
32 | wxOutputStream& Write(const void *buffer, size_t size); | |
33 | size_t SeekO(int pos, wxWhenceType whence = wxBeginPosition); | |
34 | size_t TellO() const { return m_position_o; } | |
35 | ||
36 | bool Bad() const { return m_bad; } | |
37 | size_t LastWrite() const { return m_lastwrite; } | |
38 | void Sync() {} | |
39 | ||
40 | protected: | |
41 | bool ChangeBufferSize(size_t new_length); | |
42 | ||
43 | protected: | |
44 | bool m_bad, m_eof, m_persistent; | |
45 | size_t m_lastread, m_lastwrite; | |
46 | size_t m_length; | |
47 | size_t m_position_i, m_position_o; | |
48 | char *m_buffer; | |
49 | int m_iolimit; | |
50 | }; | |
51 | ||
52 | ||
53 | class wxMemoryInputStream: public wxMemoryStreamBase { | |
3cacae09 | 54 | DECLARE_CLASS(wxMemoryInputStream) |
32fc4afb GL |
55 | public: |
56 | wxMemoryInputStream(char *data, size_t length) | |
57 | : wxMemoryStreamBase(data, length, 1) | |
58 | {} | |
59 | }; | |
60 | ||
61 | class wxMemoryOutputStream: public wxMemoryStreamBase { | |
3cacae09 | 62 | DECLARE_DYNAMIC_CLASS(wxMemoryOutputStream) |
32fc4afb GL |
63 | public: |
64 | wxMemoryOutputStream(char *data = NULL, size_t length = 0) | |
65 | : wxMemoryStreamBase(data, length, 2) | |
66 | {} | |
67 | }; | |
68 | ||
69 | class wxMemoryStream: public wxMemoryStreamBase { | |
3cacae09 | 70 | DECLARE_DYNAMIC_CLASS(wxMemoryStream) |
32fc4afb GL |
71 | public: |
72 | wxMemoryStream(char *data = NULL, size_t length = 0) | |
73 | : wxMemoryStreamBase(data, length, 0) | |
74 | {} | |
75 | }; | |
76 | ||
77 | #endif |