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