]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mstream.h
setting the hacked cocoa font panel as default
[wxWidgets.git] / include / wx / mstream.h
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
21 class WXDLLIMPEXP_BASE wxMemoryOutputStream;
22
23 class WXDLLIMPEXP_BASE wxMemoryInputStream : public wxInputStream
24 {
25 public:
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 // deprecated, compatibility only
37 wxStreamBuffer *InputStreamBuffer() const { return m_i_streambuf; }
38
39 protected:
40 wxStreamBuffer *m_i_streambuf;
41
42 size_t OnSysRead(void *buffer, size_t nbytes);
43 wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
44 wxFileOffset OnSysTell() const;
45
46 private:
47 size_t m_length;
48
49 DECLARE_NO_COPY_CLASS(wxMemoryInputStream)
50 };
51
52 class WXDLLIMPEXP_BASE wxMemoryOutputStream : public wxOutputStream
53 {
54 public:
55 // if data is !NULL it must be allocated with malloc()
56 wxMemoryOutputStream(void *data = NULL, size_t length = 0);
57 virtual ~wxMemoryOutputStream();
58 virtual wxFileOffset GetLength() const { return m_o_streambuf->GetLastAccess(); }
59 virtual bool IsSeekable() const { return true; }
60
61 size_t CopyTo(void *buffer, size_t len) const;
62
63 wxStreamBuffer *GetOutputStreamBuffer() const { return m_o_streambuf; }
64
65 // deprecated, compatibility only
66 wxStreamBuffer *OutputStreamBuffer() const { return m_o_streambuf; }
67
68 protected:
69 wxStreamBuffer *m_o_streambuf;
70
71 protected:
72 size_t OnSysWrite(const void *buffer, size_t nbytes);
73 wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
74 wxFileOffset OnSysTell() const;
75
76 DECLARE_NO_COPY_CLASS(wxMemoryOutputStream)
77 };
78
79 #endif
80 // wxUSE_STREAMS
81
82 #endif
83 // _WX_WXMMSTREAM_H__
84