]> git.saurik.com Git - wxWidgets.git/blame - include/wx/stream.h
speed optimizations: some functions now use wxString::Alloc, wxTextFile::Read
[wxWidgets.git] / include / wx / stream.h
CommitLineData
32fc4afb
GL
1/////////////////////////////////////////////////////////////////////////////
2// Name: stream.h
3// Purpose: "wxWindows stream" base 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 license
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef __WXSTREAM_H__
13#define __WXSTREAM_H__
14
15#ifdef __GNUG__
79c3e0e1 16#pragma interface
32fc4afb
GL
17#endif
18
19#include <stdio.h>
45ea509a
VZ
20#include "wx/object.h"
21#include "wx/string.h"
22#include "wx/filefn.h" // for off_t and wxSeekMode
eda3efe2 23
32fc4afb
GL
24/*
25 * wxStream: base classes
26 */
32fc4afb 27class wxOutputStream;
79c3e0e1 28class wxInputStream: virtual public wxObject {
3cacae09 29 DECLARE_ABSTRACT_CLASS(wxInputStream)
32fc4afb
GL
30 public:
31 wxInputStream();
32 virtual ~wxInputStream();
33
34 virtual wxInputStream& Read(void *buffer, size_t size) = 0;
35 wxInputStream& Read(wxOutputStream& stream_out);
36
79c3e0e1
GL
37 virtual off_t SeekI(off_t pos, wxSeekMode mode = wxFromStart) = 0;
38 virtual off_t TellI() const = 0;
32fc4afb
GL
39
40 virtual bool Eof() const = 0;
41 virtual size_t LastRead() const = 0;
0cd9bfe8
GL
42
43 wxInputStream& operator>>(wxOutputStream& out) { return Read(out); }
32fc4afb
GL
44};
45
79c3e0e1 46class wxOutputStream: virtual public wxObject {
3cacae09 47 DECLARE_ABSTRACT_CLASS(wxOutputStream)
32fc4afb
GL
48 public:
49 wxOutputStream();
50 virtual ~wxOutputStream();
51
52 virtual wxOutputStream& Write(const void *buffer, size_t size) = 0;
53 wxOutputStream& Write(wxInputStream& stream_in);
54
79c3e0e1
GL
55 virtual off_t SeekO(off_t pos, wxSeekMode mode = wxFromStart) = 0;
56 virtual off_t TellO() const = 0;
32fc4afb
GL
57
58 virtual bool Bad() const = 0;
59 virtual size_t LastWrite() const = 0;
60
61 virtual void Sync() {}
62};
63
32fc4afb
GL
64/*
65 * "Filter" streams
66 */
67
68class wxFilterInputStream: public wxInputStream {
69 DECLARE_CLASS(wxFilterInputStream)
70 public:
71 wxFilterInputStream(wxInputStream& stream);
72 virtual ~wxFilterInputStream();
73
74 virtual wxInputStream& Read(void *buffer, size_t size)
75 { return m_parent_i_stream->Read(buffer, size); }
79c3e0e1
GL
76 virtual off_t SeekI(off_t pos, wxSeekMode mode = wxFromStart)
77 { return m_parent_i_stream->SeekI(pos, mode); }
0cd9bfe8
GL
78 virtual off_t TellI() const
79 { return m_parent_i_stream->TellI(); }
32fc4afb
GL
80
81 virtual bool Eof() const { return m_parent_i_stream->Eof(); }
82 virtual size_t LastRead() const { return m_parent_i_stream->LastRead(); }
79c3e0e1 83
32fc4afb
GL
84 protected:
85 wxInputStream *m_parent_i_stream;
86};
87
219f895a 88class wxFilterOutputStream: public wxOutputStream {
32fc4afb
GL
89 DECLARE_CLASS(wxFilterOutputStream)
90 public:
91 wxFilterOutputStream(wxOutputStream& stream);
92 virtual ~wxFilterOutputStream();
93
94 virtual wxOutputStream& Write(const void *buffer, size_t size)
95 { return m_parent_o_stream->Write(buffer, size); }
79c3e0e1
GL
96 virtual off_t SeekO(off_t pos, wxSeekMode mode = wxFromStart)
97 { return m_parent_o_stream->SeekO(pos, mode); }
0cd9bfe8
GL
98 virtual off_t TellO() const
99 { return m_parent_o_stream->TellO(); }
32fc4afb 100
219f895a
RR
101 virtual bool Bad() const { return m_parent_o_stream->Bad(); }
102 virtual size_t LastWrite() const { return m_parent_o_stream->LastWrite(); }
32fc4afb
GL
103
104 protected:
105 wxOutputStream *m_parent_o_stream;
106};
107
108#endif