]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mstream.h
Apply parts of patch #1719888 to fix compilation on Mac and with
[wxWidgets.git] / include / wx / mstream.h
CommitLineData
32fc4afb 1/////////////////////////////////////////////////////////////////////////////
67c8c225 2// Name: wx/mstream.h
32fc4afb
GL
3// Purpose: Memory stream classes
4// Author: Guilhem Lavaux
5// Modified by:
6// Created: 11/07/98
7// RCS-ID: $Id$
8// Copyright: (c) Guilhem Lavaux
65571936 9// Licence: wxWindows licence
32fc4afb 10/////////////////////////////////////////////////////////////////////////////
83141d3a 11
34138703
JS
12#ifndef _WX_WXMMSTREAM_H__
13#define _WX_WXMMSTREAM_H__
32fc4afb 14
2ecf902b 15#include "wx/defs.h"
32fc4afb 16
ce4169a4
RR
17#if wxUSE_STREAMS
18
2ecf902b
WS
19#include "wx/stream.h"
20
96461cc2
VZ
21class WXDLLIMPEXP_BASE wxMemoryOutputStream;
22
bddd7a8d 23class WXDLLIMPEXP_BASE wxMemoryInputStream : public wxInputStream
83141d3a
VZ
24{
25public:
67c8c225 26 wxMemoryInputStream(const void *data, size_t length);
96461cc2 27 wxMemoryInputStream(const wxMemoryOutputStream& stream);
76447155
VZ
28 wxMemoryInputStream(wxInputStream& stream,
29 wxFileOffset lenFile = wxInvalidOffset)
30 {
31 InitFromStream(stream, lenFile);
32 }
33 wxMemoryInputStream(wxMemoryInputStream& stream)
34 {
35 InitFromStream(stream, wxInvalidOffset);
36 }
37
83141d3a 38 virtual ~wxMemoryInputStream();
588066b7 39 virtual wxFileOffset GetLength() const { return m_length; }
3c70014d 40 virtual bool IsSeekable() const { return true; }
83141d3a 41
2d76b6d8
VZ
42 virtual char Peek();
43 virtual bool CanRead() const;
79c3e0e1 44
67c8c225
VZ
45 wxStreamBuffer *GetInputStreamBuffer() const { return m_i_streambuf; }
46
40ff126a 47#if WXWIN_COMPATIBILITY_2_6
67c8c225 48 // deprecated, compatibility only
40ff126a
WS
49 wxDEPRECATED( wxStreamBuffer *InputStreamBuffer() const );
50#endif // WXWIN_COMPATIBILITY_2_6
c980c992 51
83141d3a
VZ
52protected:
53 wxStreamBuffer *m_i_streambuf;
0d631778 54
83141d3a 55 size_t OnSysRead(void *buffer, size_t nbytes);
4004775e
RL
56 wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
57 wxFileOffset OnSysTell() const;
c980c992 58
83141d3a 59private:
76447155
VZ
60 // common part of ctors taking wxInputStream
61 void InitFromStream(wxInputStream& stream, wxFileOffset lenFile);
62
83141d3a 63 size_t m_length;
22f3361e 64
76447155 65 // copy ctor is implemented above: it copies the other stream in this one
6285e36b 66 DECLARE_ABSTRACT_CLASS(wxMemoryInputStream)
76447155 67 DECLARE_NO_ASSIGN_CLASS(wxMemoryInputStream)
32fc4afb
GL
68};
69
bddd7a8d 70class WXDLLIMPEXP_BASE wxMemoryOutputStream : public wxOutputStream
83141d3a
VZ
71{
72public:
67c8c225
VZ
73 // if data is !NULL it must be allocated with malloc()
74 wxMemoryOutputStream(void *data = NULL, size_t length = 0);
83141d3a 75 virtual ~wxMemoryOutputStream();
588066b7 76 virtual wxFileOffset GetLength() const { return m_o_streambuf->GetLastAccess(); }
3c70014d 77 virtual bool IsSeekable() const { return true; }
0d631778 78
67c8c225 79 size_t CopyTo(void *buffer, size_t len) const;
c980c992 80
67c8c225
VZ
81 wxStreamBuffer *GetOutputStreamBuffer() const { return m_o_streambuf; }
82
40ff126a 83#if WXWIN_COMPATIBILITY_2_6
67c8c225 84 // deprecated, compatibility only
40ff126a
WS
85 wxDEPRECATED( wxStreamBuffer *OutputStreamBuffer() const );
86#endif // WXWIN_COMPATIBILITY_2_6
a324a7bc 87
83141d3a
VZ
88protected:
89 wxStreamBuffer *m_o_streambuf;
c980c992 90
83141d3a
VZ
91protected:
92 size_t OnSysWrite(const void *buffer, size_t nbytes);
4004775e
RL
93 wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
94 wxFileOffset OnSysTell() const;
22f3361e 95
6285e36b 96 DECLARE_DYNAMIC_CLASS(wxMemoryOutputStream)
22f3361e 97 DECLARE_NO_COPY_CLASS(wxMemoryOutputStream)
32fc4afb
GL
98};
99
40ff126a
WS
100#if WXWIN_COMPATIBILITY_2_6
101 inline wxStreamBuffer *wxMemoryInputStream::InputStreamBuffer() const { return m_i_streambuf; }
102 inline wxStreamBuffer *wxMemoryOutputStream::OutputStreamBuffer() const { return m_o_streambuf; }
103#endif // WXWIN_COMPATIBILITY_2_6
104
32fc4afb 105#endif
ce4169a4
RR
106 // wxUSE_STREAMS
107
108#endif
cc985fac 109 // _WX_WXMMSTREAM_H__