]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mstream.h
added overloads taking pairs of const char/wchar_t pointers for wxString methods...
[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
VZ
65 // copy ctor is implemented above: it copies the other stream in this one
66 DECLARE_NO_ASSIGN_CLASS(wxMemoryInputStream)
32fc4afb
GL
67};
68
bddd7a8d 69class WXDLLIMPEXP_BASE wxMemoryOutputStream : public wxOutputStream
83141d3a
VZ
70{
71public:
67c8c225
VZ
72 // if data is !NULL it must be allocated with malloc()
73 wxMemoryOutputStream(void *data = NULL, size_t length = 0);
83141d3a 74 virtual ~wxMemoryOutputStream();
588066b7 75 virtual wxFileOffset GetLength() const { return m_o_streambuf->GetLastAccess(); }
3c70014d 76 virtual bool IsSeekable() const { return true; }
0d631778 77
67c8c225 78 size_t CopyTo(void *buffer, size_t len) const;
c980c992 79
67c8c225
VZ
80 wxStreamBuffer *GetOutputStreamBuffer() const { return m_o_streambuf; }
81
40ff126a 82#if WXWIN_COMPATIBILITY_2_6
67c8c225 83 // deprecated, compatibility only
40ff126a
WS
84 wxDEPRECATED( wxStreamBuffer *OutputStreamBuffer() const );
85#endif // WXWIN_COMPATIBILITY_2_6
a324a7bc 86
83141d3a
VZ
87protected:
88 wxStreamBuffer *m_o_streambuf;
c980c992 89
83141d3a
VZ
90protected:
91 size_t OnSysWrite(const void *buffer, size_t nbytes);
4004775e
RL
92 wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
93 wxFileOffset OnSysTell() const;
22f3361e
VZ
94
95 DECLARE_NO_COPY_CLASS(wxMemoryOutputStream)
32fc4afb
GL
96};
97
40ff126a
WS
98#if WXWIN_COMPATIBILITY_2_6
99 inline wxStreamBuffer *wxMemoryInputStream::InputStreamBuffer() const { return m_i_streambuf; }
100 inline wxStreamBuffer *wxMemoryOutputStream::OutputStreamBuffer() const { return m_o_streambuf; }
101#endif // WXWIN_COMPATIBILITY_2_6
102
32fc4afb 103#endif
ce4169a4
RR
104 // wxUSE_STREAMS
105
106#endif
cc985fac 107 // _WX_WXMMSTREAM_H__