]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mstream.h
speed optimizations: some functions now use wxString::Alloc, wxTextFile::Read
[wxWidgets.git] / include / wx / mstream.h
CommitLineData
32fc4afb
GL
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 __WXMMSTREAM_H__
12#define __WXMMSTREAM_H__
13
79c3e0e1 14#include <wx/stream.h>
32fc4afb 15
79c3e0e1
GL
16class wxMemoryStreamBase {
17 protected:
18 wxMemoryStreamBase();
32fc4afb
GL
19 virtual ~wxMemoryStreamBase();
20
32fc4afb
GL
21 bool ChangeBufferSize(size_t new_length);
22
23 protected:
79c3e0e1 24 bool m_persistent;
32fc4afb 25 size_t m_length;
32fc4afb
GL
26 char *m_buffer;
27 int m_iolimit;
28};
29
79c3e0e1 30class wxMemoryInputStream: virtual public wxMemoryStreamBase, public wxInputStream {
3cacae09 31 DECLARE_CLASS(wxMemoryInputStream)
32fc4afb 32 public:
79c3e0e1
GL
33 wxMemoryInputStream(const char *data, size_t length);
34 virtual ~wxMemoryInputStream();
35
36 wxInputStream& Read(void *buffer, size_t size);
37 off_t SeekI(off_t pos, wxSeekMode mode);
38 off_t TellI() const { return m_position_i; }
39
40 bool Eof() const { return m_eof; }
41 size_t LastRead() const { return m_lastread; }
42
43 protected:
44 bool m_eof;
45 off_t m_position_i;
46 size_t m_lastread;
32fc4afb
GL
47};
48
79c3e0e1
GL
49class wxMemoryOutputStream: virtual public wxMemoryStreamBase, public wxOutputStream {
50 DECLARE_CLASS(wxMemoryOutputStream)
32fc4afb 51 public:
79c3e0e1
GL
52 wxMemoryOutputStream(char *data = NULL, size_t length = 0);
53 virtual ~wxMemoryOutputStream();
54
55 wxOutputStream& Write(const void *buffer, size_t size);
56 off_t SeekO(off_t pos, wxSeekMode mode);
57 off_t TellO() const { return m_position_o; }
58
59 bool Bad() const { return m_bad; }
60 size_t LastWrite() const { return m_lastwrite; }
61
62 char *GetData() { return m_buffer; }
63 size_t GetLength() { return m_length; }
64
65 protected:
66 bool m_bad;
67 off_t m_position_o;
68 size_t m_lastwrite;
32fc4afb
GL
69};
70
79c3e0e1
GL
71class wxMemoryStream: public wxMemoryInputStream, public wxMemoryOutputStream {
72 DECLARE_CLASS(wxMemoryStream)
32fc4afb 73 public:
79c3e0e1
GL
74 wxMemoryStream(char *data = NULL, size_t length = 0);
75 virtual ~wxMemoryStream();
32fc4afb
GL
76};
77
78#endif