]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mstream.h
Add wxDataViewRendererBase::GetEffectiveAlignment() and use it.
[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
32fc4afb 7// Copyright: (c) Guilhem Lavaux
65571936 8// Licence: wxWindows licence
32fc4afb 9/////////////////////////////////////////////////////////////////////////////
83141d3a 10
34138703
JS
11#ifndef _WX_WXMMSTREAM_H__
12#define _WX_WXMMSTREAM_H__
32fc4afb 13
2ecf902b 14#include "wx/defs.h"
32fc4afb 15
ce4169a4
RR
16#if wxUSE_STREAMS
17
2ecf902b
WS
18#include "wx/stream.h"
19
b5dbe15d 20class WXDLLIMPEXP_FWD_BASE wxMemoryOutputStream;
96461cc2 21
bddd7a8d 22class WXDLLIMPEXP_BASE wxMemoryInputStream : public wxInputStream
83141d3a
VZ
23{
24public:
67c8c225 25 wxMemoryInputStream(const void *data, size_t length);
96461cc2 26 wxMemoryInputStream(const wxMemoryOutputStream& stream);
76447155
VZ
27 wxMemoryInputStream(wxInputStream& stream,
28 wxFileOffset lenFile = wxInvalidOffset)
29 {
30 InitFromStream(stream, lenFile);
31 }
32 wxMemoryInputStream(wxMemoryInputStream& stream)
2a230426 33 : wxInputStream()
76447155
VZ
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)
c0c133e1 67 wxDECLARE_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)
c0c133e1 97 wxDECLARE_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__