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 wxMemoryInputStream
: public wxInputStream
24 wxMemoryInputStream(const void *data
, size_t length
);
25 virtual ~wxMemoryInputStream();
26 virtual wxFileOffset
GetLength() const { return m_length
; }
27 virtual bool Eof() const;
28 virtual bool IsSeekable() const { return true; }
32 wxStreamBuffer
*GetInputStreamBuffer() const { return m_i_streambuf
; }
34 // deprecated, compatibility only
35 wxStreamBuffer
*InputStreamBuffer() const { return m_i_streambuf
; }
38 wxStreamBuffer
*m_i_streambuf
;
40 size_t OnSysRead(void *buffer
, size_t nbytes
);
41 wxFileOffset
OnSysSeek(wxFileOffset pos
, wxSeekMode mode
);
42 wxFileOffset
OnSysTell() const;
47 DECLARE_NO_COPY_CLASS(wxMemoryInputStream
)
50 class WXDLLIMPEXP_BASE wxMemoryOutputStream
: public wxOutputStream
53 // if data is !NULL it must be allocated with malloc()
54 wxMemoryOutputStream(void *data
= NULL
, size_t length
= 0);
55 virtual ~wxMemoryOutputStream();
56 virtual wxFileOffset
GetLength() const { return m_o_streambuf
->GetLastAccess(); }
57 virtual bool IsSeekable() const { return true; }
59 size_t CopyTo(void *buffer
, size_t len
) const;
61 wxStreamBuffer
*GetOutputStreamBuffer() const { return m_o_streambuf
; }
63 // deprecated, compatibility only
64 wxStreamBuffer
*OutputStreamBuffer() const { return m_o_streambuf
; }
67 wxStreamBuffer
*m_o_streambuf
;
70 size_t OnSysWrite(const void *buffer
, size_t nbytes
);
71 wxFileOffset
OnSysSeek(wxFileOffset pos
, wxSeekMode mode
);
72 wxFileOffset
OnSysTell() const;
74 DECLARE_NO_COPY_CLASS(wxMemoryOutputStream
)