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 #if WXWIN_COMPATIBILITY_2_6
37 // deprecated, compatibility only
38 wxDEPRECATED( wxStreamBuffer
*InputStreamBuffer() const );
39 #endif // WXWIN_COMPATIBILITY_2_6
42 wxStreamBuffer
*m_i_streambuf
;
44 size_t OnSysRead(void *buffer
, size_t nbytes
);
45 wxFileOffset
OnSysSeek(wxFileOffset pos
, wxSeekMode mode
);
46 wxFileOffset
OnSysTell() const;
51 DECLARE_NO_COPY_CLASS(wxMemoryInputStream
)
54 class WXDLLIMPEXP_BASE wxMemoryOutputStream
: public wxOutputStream
57 // if data is !NULL it must be allocated with malloc()
58 wxMemoryOutputStream(void *data
= NULL
, size_t length
= 0);
59 virtual ~wxMemoryOutputStream();
60 virtual wxFileOffset
GetLength() const { return m_o_streambuf
->GetLastAccess(); }
61 virtual bool IsSeekable() const { return true; }
63 size_t CopyTo(void *buffer
, size_t len
) const;
65 wxStreamBuffer
*GetOutputStreamBuffer() const { return m_o_streambuf
; }
67 #if WXWIN_COMPATIBILITY_2_6
68 // deprecated, compatibility only
69 wxDEPRECATED( wxStreamBuffer
*OutputStreamBuffer() const );
70 #endif // WXWIN_COMPATIBILITY_2_6
73 wxStreamBuffer
*m_o_streambuf
;
76 size_t OnSysWrite(const void *buffer
, size_t nbytes
);
77 wxFileOffset
OnSysSeek(wxFileOffset pos
, wxSeekMode mode
);
78 wxFileOffset
OnSysTell() const;
80 DECLARE_NO_COPY_CLASS(wxMemoryOutputStream
)
83 #if WXWIN_COMPATIBILITY_2_6
84 inline wxStreamBuffer
*wxMemoryInputStream::InputStreamBuffer() const { return m_i_streambuf
; }
85 inline wxStreamBuffer
*wxMemoryOutputStream::OutputStreamBuffer() const { return m_o_streambuf
; }
86 #endif // WXWIN_COMPATIBILITY_2_6