1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Memory stream classes
4 // Author: Guilhem Lavaux
8 // Copyright: (c) Guilhem Lavaux
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11 #ifndef __WXMMSTREAM_H__
12 #define __WXMMSTREAM_H__
14 #include <wx/stream.h>
16 class wxMemoryStreamBase
: public wxStream
{
17 DECLARE_CLASS(wxMemoryStreamBase
)
19 wxMemoryStreamBase(char *data
, size_t length
, int iolimit
);
20 virtual ~wxMemoryStreamBase();
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
; }
27 bool Eof() const { return m_eof
; }
28 size_t LastRead() const { return m_lastread
; }
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
; }
35 bool Bad() const { return m_bad
; }
36 size_t LastWrite() const { return m_lastwrite
; }
40 bool ChangeBufferSize(size_t new_length
);
43 bool m_bad
, m_eof
, m_persistent
;
44 size_t m_lastread
, m_lastwrite
;
46 size_t m_position_i
, m_position_o
;
52 class wxMemoryInputStream
: public wxMemoryStreamBase
{
53 DECLARE_CLASS(wxMemoryInputStream
)
55 wxMemoryInputStream(char *data
, size_t length
)
56 : wxMemoryStreamBase(data
, length
, 1)
60 class wxMemoryOutputStream
: public wxMemoryStreamBase
{
61 DECLARE_DYNAMIC_CLASS(wxMemoryOutputStream
)
63 wxMemoryOutputStream(char *data
= NULL
, size_t length
= 0)
64 : wxMemoryStreamBase(data
, length
, 2)
68 class wxMemoryStream
: public wxMemoryStreamBase
{
69 DECLARE_DYNAMIC_CLASS(wxMemoryStream
)
71 wxMemoryStream(char *data
= NULL
, size_t length
= 0)
72 : wxMemoryStreamBase(data
, length
, 0)