Added StreamSize() to wxMemoryOutputStream.
[wxWidgets.git] / include / wx / mstream.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: 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 #ifndef _WX_WXMMSTREAM_H__
12 #define _WX_WXMMSTREAM_H__
13
14 #include <wx/stream.h>
15
16 #if wxUSE_STREAMS
17
18 class wxMemoryInputStream: public wxInputStream {
19 private:
20 size_t m_length;
21
22 public:
23 wxMemoryInputStream(const char *data, size_t length);
24 virtual ~wxMemoryInputStream();
25 virtual size_t StreamSize() const { return m_length; }
26
27 char Peek();
28
29 wxStreamBuffer *InputStreamBuffer() const { return m_i_streambuf; }
30
31 protected:
32 wxStreamBuffer *m_i_streambuf;
33
34 protected:
35 size_t OnSysRead(void *buffer, size_t nbytes);
36 off_t OnSysSeek(off_t pos, wxSeekMode mode);
37 off_t OnSysTell() const;
38 };
39
40 class wxMemoryOutputStream: public wxOutputStream {
41 public:
42 wxMemoryOutputStream(char *data = NULL, size_t length = 0);
43 virtual ~wxMemoryOutputStream();
44 virtual size_t StreamSize() const { return m_o_streambuf->GetLastAccess(); }
45
46 wxStreamBuffer *OutputStreamBuffer() const { return m_o_streambuf; }
47
48 protected:
49 wxStreamBuffer *m_o_streambuf;
50
51 protected:
52 size_t OnSysWrite(const void *buffer, size_t nbytes);
53 off_t OnSysSeek(off_t pos, wxSeekMode mode);
54 off_t OnSysTell() const;
55 };
56
57 #endif
58 // wxUSE_STREAMS
59
60 #endif
61 // _WX_WXMMSTREAM_H__
62