Fixed that stupid stream problem.
[wxWidgets.git] / src / common / stream.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: stream.cpp
3 // Purpose: wxStream 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 #ifdef __GNUG__
13 #pragma implementation "stream.h"
14 #endif
15
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WX_PRECOMP
24 #include "wx/setup.h"
25 #endif
26
27 #include "wx/object.h"
28 #include "wx/stream.h"
29
30 #if !USE_SHARED_LIBRARY
31 IMPLEMENT_ABSTRACT_CLASS(wxInputStream, wxObject)
32 IMPLEMENT_ABSTRACT_CLASS(wxOutputStream, wxObject)
33 IMPLEMENT_ABSTRACT_CLASS2(wxStream, wxInputStream, wxOutputStream)
34 IMPLEMENT_CLASS(wxFilterInputStream, wxInputStream)
35 IMPLEMENT_CLASS(wxFilterOutputStream, wxOutputStream)
36 #endif
37
38 wxInputStream::wxInputStream()
39 : wxObject()
40 {
41 }
42
43 wxInputStream::~wxInputStream()
44 {
45 }
46
47 #define BUF_TEMP_SIZE 10000
48
49 wxInputStream& wxInputStream::Read(wxOutputStream& stream_out)
50 {
51 char buf[BUF_TEMP_SIZE];
52 size_t bytes_read = BUF_TEMP_SIZE;
53
54 while (bytes_read == BUF_TEMP_SIZE && !stream_out.Bad()) {
55 bytes_read = Read(buf, bytes_read).LastRead();
56
57 stream_out.Write(buf, bytes_read);
58 }
59 return *this;
60 }
61
62 wxOutputStream::wxOutputStream()
63 : wxObject()
64 {
65 }
66
67 wxOutputStream::~wxOutputStream()
68 {
69 }
70
71 wxOutputStream& wxOutputStream::Write(wxInputStream& stream_in)
72 {
73 stream_in.Read(*this);
74 return *this;
75 }
76
77 wxFilterInputStream::wxFilterInputStream(wxInputStream& stream)
78 : wxInputStream()
79 {
80 m_parent_i_stream = &stream;
81 }
82
83 wxFilterInputStream::~wxFilterInputStream()
84 {
85 }
86
87 wxFilterOutputStream::wxFilterOutputStream(wxOutputStream& stream)
88 : wxOutputStream()
89 {
90 m_parent_o_stream = &stream;
91 }
92
93 wxFilterOutputStream::~wxFilterOutputStream()
94 {
95 }