]>
Commit | Line | Data |
---|---|---|
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 wxMemoryInputStream : public wxInputStream | |
22 | { | |
23 | public: | |
24 | wxMemoryInputStream(const void *data, size_t length); | |
25 | virtual ~wxMemoryInputStream(); | |
26 | virtual wxFileOffset GetLength() const { return m_length; } | |
27 | virtual bool Eof() const; | |
28 | virtual bool IsSeekable() const { return true; } | |
29 | ||
30 | char Peek(); | |
31 | ||
32 | wxStreamBuffer *GetInputStreamBuffer() const { return m_i_streambuf; } | |
33 | ||
34 | // deprecated, compatibility only | |
35 | wxStreamBuffer *InputStreamBuffer() const { return m_i_streambuf; } | |
36 | ||
37 | protected: | |
38 | wxStreamBuffer *m_i_streambuf; | |
39 | ||
40 | size_t OnSysRead(void *buffer, size_t nbytes); | |
41 | wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode); | |
42 | wxFileOffset OnSysTell() const; | |
43 | ||
44 | private: | |
45 | size_t m_length; | |
46 | ||
47 | DECLARE_NO_COPY_CLASS(wxMemoryInputStream) | |
48 | }; | |
49 | ||
50 | class WXDLLIMPEXP_BASE wxMemoryOutputStream : public wxOutputStream | |
51 | { | |
52 | public: | |
53 | // if data is !NULL it must be allocated with malloc() | |
54 | wxMemoryOutputStream(void *data = NULL, size_t length = 0); | |
55 | virtual ~wxMemoryOutputStream(); | |
56 | virtual wxFileOffset GetLength() const { return m_o_streambuf->GetLastAccess(); } | |
57 | virtual bool IsSeekable() const { return true; } | |
58 | ||
59 | size_t CopyTo(void *buffer, size_t len) const; | |
60 | ||
61 | wxStreamBuffer *GetOutputStreamBuffer() const { return m_o_streambuf; } | |
62 | ||
63 | // deprecated, compatibility only | |
64 | wxStreamBuffer *OutputStreamBuffer() const { return m_o_streambuf; } | |
65 | ||
66 | protected: | |
67 | wxStreamBuffer *m_o_streambuf; | |
68 | ||
69 | protected: | |
70 | size_t OnSysWrite(const void *buffer, size_t nbytes); | |
71 | wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode); | |
72 | wxFileOffset OnSysTell() const; | |
73 | ||
74 | DECLARE_NO_COPY_CLASS(wxMemoryOutputStream) | |
75 | }; | |
76 | ||
77 | #endif | |
78 | // wxUSE_STREAMS | |
79 | ||
80 | #endif | |
81 | // _WX_WXMMSTREAM_H__ | |
82 |