1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Memory stream classes
4 // Author: Guilhem Lavaux
8 // Copyright: (c) Guilhem Lavaux
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_WXMMSTREAM_H__
13 #define _WX_WXMMSTREAM_H__
15 #include "wx/stream.h"
19 class WXDLLIMPEXP_BASE wxMemoryInputStream
: public wxInputStream
22 wxMemoryInputStream(const void *data
, size_t length
);
23 virtual ~wxMemoryInputStream();
24 virtual wxFileOffset
GetLength() const { return m_length
; }
25 virtual bool Eof() const;
26 virtual bool IsSeekable() const { return true; }
30 wxStreamBuffer
*GetInputStreamBuffer() const { return m_i_streambuf
; }
32 // deprecated, compatibility only
33 wxStreamBuffer
*InputStreamBuffer() const { return m_i_streambuf
; }
36 wxStreamBuffer
*m_i_streambuf
;
38 size_t OnSysRead(void *buffer
, size_t nbytes
);
39 wxFileOffset
OnSysSeek(wxFileOffset pos
, wxSeekMode mode
);
40 wxFileOffset
OnSysTell() const;
45 DECLARE_NO_COPY_CLASS(wxMemoryInputStream
)
48 class WXDLLIMPEXP_BASE wxMemoryOutputStream
: public wxOutputStream
51 // if data is !NULL it must be allocated with malloc()
52 wxMemoryOutputStream(void *data
= NULL
, size_t length
= 0);
53 virtual ~wxMemoryOutputStream();
54 virtual wxFileOffset
GetLength() const { return m_o_streambuf
->GetLastAccess(); }
55 virtual bool IsSeekable() const { return true; }
57 size_t CopyTo(void *buffer
, size_t len
) const;
59 wxStreamBuffer
*GetOutputStreamBuffer() const { return m_o_streambuf
; }
61 // deprecated, compatibility only
62 wxStreamBuffer
*OutputStreamBuffer() const { return m_o_streambuf
; }
65 wxStreamBuffer
*m_o_streambuf
;
68 size_t OnSysWrite(const void *buffer
, size_t nbytes
);
69 wxFileOffset
OnSysSeek(wxFileOffset pos
, wxSeekMode mode
);
70 wxFileOffset
OnSysTell() const;
72 DECLARE_NO_COPY_CLASS(wxMemoryOutputStream
)