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__
19 #include "wx/stream.h"
21 class WXDLLIMPEXP_BASE wxMemoryOutputStream
;
23 class WXDLLIMPEXP_BASE wxMemoryInputStream
: public wxInputStream
26 wxMemoryInputStream(const void *data
, size_t length
);
27 wxMemoryInputStream(const wxMemoryOutputStream
& stream
);
28 virtual ~wxMemoryInputStream();
29 virtual wxFileOffset
GetLength() const { return m_length
; }
30 virtual bool IsSeekable() const { return true; }
34 wxStreamBuffer
*GetInputStreamBuffer() const { return m_i_streambuf
; }
36 // deprecated, compatibility only
37 wxStreamBuffer
*InputStreamBuffer() const { return m_i_streambuf
; }
40 wxStreamBuffer
*m_i_streambuf
;
42 size_t OnSysRead(void *buffer
, size_t nbytes
);
43 wxFileOffset
OnSysSeek(wxFileOffset pos
, wxSeekMode mode
);
44 wxFileOffset
OnSysTell() const;
49 DECLARE_NO_COPY_CLASS(wxMemoryInputStream
)
52 class WXDLLIMPEXP_BASE wxMemoryOutputStream
: public wxOutputStream
55 // if data is !NULL it must be allocated with malloc()
56 wxMemoryOutputStream(void *data
= NULL
, size_t length
= 0);
57 virtual ~wxMemoryOutputStream();
58 virtual wxFileOffset
GetLength() const { return m_o_streambuf
->GetLastAccess(); }
59 virtual bool IsSeekable() const { return true; }
61 size_t CopyTo(void *buffer
, size_t len
) const;
63 wxStreamBuffer
*GetOutputStreamBuffer() const { return m_o_streambuf
; }
65 // deprecated, compatibility only
66 wxStreamBuffer
*OutputStreamBuffer() const { return m_o_streambuf
; }
69 wxStreamBuffer
*m_o_streambuf
;
72 size_t OnSysWrite(const void *buffer
, size_t nbytes
);
73 wxFileOffset
OnSysSeek(wxFileOffset pos
, wxSeekMode mode
);
74 wxFileOffset
OnSysTell() const;
76 DECLARE_NO_COPY_CLASS(wxMemoryOutputStream
)