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 Eof() const;
31 virtual bool IsSeekable() const { return true; }
35 wxStreamBuffer
*GetInputStreamBuffer() const { return m_i_streambuf
; }
37 // deprecated, compatibility only
38 wxStreamBuffer
*InputStreamBuffer() const { return m_i_streambuf
; }
41 wxStreamBuffer
*m_i_streambuf
;
43 size_t OnSysRead(void *buffer
, size_t nbytes
);
44 wxFileOffset
OnSysSeek(wxFileOffset pos
, wxSeekMode mode
);
45 wxFileOffset
OnSysTell() const;
50 DECLARE_NO_COPY_CLASS(wxMemoryInputStream
)
53 class WXDLLIMPEXP_BASE wxMemoryOutputStream
: public wxOutputStream
56 // if data is !NULL it must be allocated with malloc()
57 wxMemoryOutputStream(void *data
= NULL
, size_t length
= 0);
58 virtual ~wxMemoryOutputStream();
59 virtual wxFileOffset
GetLength() const { return m_o_streambuf
->GetLastAccess(); }
60 virtual bool IsSeekable() const { return true; }
62 size_t CopyTo(void *buffer
, size_t len
) const;
64 wxStreamBuffer
*GetOutputStreamBuffer() const { return m_o_streambuf
; }
66 // deprecated, compatibility only
67 wxStreamBuffer
*OutputStreamBuffer() const { return m_o_streambuf
; }
70 wxStreamBuffer
*m_o_streambuf
;
73 size_t OnSysWrite(const void *buffer
, size_t nbytes
);
74 wxFileOffset
OnSysSeek(wxFileOffset pos
, wxSeekMode mode
);
75 wxFileOffset
OnSysTell() const;
77 DECLARE_NO_COPY_CLASS(wxMemoryOutputStream
)