]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/mstream.h
use wxString for wxXmlResource::Set/GetDomain(), it's simpler
[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 wxMemoryInputStream(wxInputStream& stream,
29 wxFileOffset lenFile = wxInvalidOffset)
30 {
31 InitFromStream(stream, lenFile);
32 }
33 wxMemoryInputStream(wxMemoryInputStream& stream)
34 {
35 InitFromStream(stream, wxInvalidOffset);
36 }
37
38 virtual ~wxMemoryInputStream();
39 virtual wxFileOffset GetLength() const { return m_length; }
40 virtual bool IsSeekable() const { return true; }
41
42 virtual char Peek();
43 virtual bool CanRead() const;
44
45 wxStreamBuffer *GetInputStreamBuffer() const { return m_i_streambuf; }
46
47#if WXWIN_COMPATIBILITY_2_6
48 // deprecated, compatibility only
49 wxDEPRECATED( wxStreamBuffer *InputStreamBuffer() const );
50#endif // WXWIN_COMPATIBILITY_2_6
51
52protected:
53 wxStreamBuffer *m_i_streambuf;
54
55 size_t OnSysRead(void *buffer, size_t nbytes);
56 wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
57 wxFileOffset OnSysTell() const;
58
59private:
60 // common part of ctors taking wxInputStream
61 void InitFromStream(wxInputStream& stream, wxFileOffset lenFile);
62
63 size_t m_length;
64
65 // copy ctor is implemented above: it copies the other stream in this one
66 DECLARE_NO_ASSIGN_CLASS(wxMemoryInputStream)
67};
68
69class WXDLLIMPEXP_BASE wxMemoryOutputStream : public wxOutputStream
70{
71public:
72 // if data is !NULL it must be allocated with malloc()
73 wxMemoryOutputStream(void *data = NULL, size_t length = 0);
74 virtual ~wxMemoryOutputStream();
75 virtual wxFileOffset GetLength() const { return m_o_streambuf->GetLastAccess(); }
76 virtual bool IsSeekable() const { return true; }
77
78 size_t CopyTo(void *buffer, size_t len) const;
79
80 wxStreamBuffer *GetOutputStreamBuffer() const { return m_o_streambuf; }
81
82#if WXWIN_COMPATIBILITY_2_6
83 // deprecated, compatibility only
84 wxDEPRECATED( wxStreamBuffer *OutputStreamBuffer() const );
85#endif // WXWIN_COMPATIBILITY_2_6
86
87protected:
88 wxStreamBuffer *m_o_streambuf;
89
90protected:
91 size_t OnSysWrite(const void *buffer, size_t nbytes);
92 wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
93 wxFileOffset OnSysTell() const;
94
95 DECLARE_NO_COPY_CLASS(wxMemoryOutputStream)
96};
97
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
103#endif
104 // wxUSE_STREAMS
105
106#endif
107 // _WX_WXMMSTREAM_H__