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