]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/mstream.h
using newer API
[wxWidgets.git] / include / wx / mstream.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/mstream.h
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
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_WXMMSTREAM_H__
13#define _WX_WXMMSTREAM_H__
14
15#include "wx/defs.h"
16
17#if wxUSE_STREAMS
18
19#include "wx/stream.h"
20
21class WXDLLIMPEXP_BASE wxMemoryOutputStream;
22
23class WXDLLIMPEXP_BASE wxMemoryInputStream : public wxInputStream
24{
25public:
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; }
31
32 char Peek();
33
34 wxStreamBuffer *GetInputStreamBuffer() const { return m_i_streambuf; }
35
36#if WXWIN_COMPATIBILITY_2_6
37 // deprecated, compatibility only
38 wxDEPRECATED( wxStreamBuffer *InputStreamBuffer() const );
39#endif // WXWIN_COMPATIBILITY_2_6
40
41protected:
42 wxStreamBuffer *m_i_streambuf;
43
44 size_t OnSysRead(void *buffer, size_t nbytes);
45 wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
46 wxFileOffset OnSysTell() const;
47
48private:
49 size_t m_length;
50
51 DECLARE_NO_COPY_CLASS(wxMemoryInputStream)
52};
53
54class WXDLLIMPEXP_BASE wxMemoryOutputStream : public wxOutputStream
55{
56public:
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; }
62
63 size_t CopyTo(void *buffer, size_t len) const;
64
65 wxStreamBuffer *GetOutputStreamBuffer() const { return m_o_streambuf; }
66
67#if WXWIN_COMPATIBILITY_2_6
68 // deprecated, compatibility only
69 wxDEPRECATED( wxStreamBuffer *OutputStreamBuffer() const );
70#endif // WXWIN_COMPATIBILITY_2_6
71
72protected:
73 wxStreamBuffer *m_o_streambuf;
74
75protected:
76 size_t OnSysWrite(const void *buffer, size_t nbytes);
77 wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
78 wxFileOffset OnSysTell() const;
79
80 DECLARE_NO_COPY_CLASS(wxMemoryOutputStream)
81};
82
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
87
88#endif
89 // wxUSE_STREAMS
90
91#endif
92 // _WX_WXMMSTREAM_H__