]> git.saurik.com Git - wxWidgets.git/blob - src/common/stream.cpp
a9c76aff5bb3a2bcb0cb6d758e4087c7c67f511d
[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 #include <wx/stream.h>
19
20 #ifdef __BORLANDC__
21 #pragma hdrstop
22 #endif
23
24 #if !USE_SHARED_LIBRARY
25 IMPLEMENT_ABSTRACT_CLASS(wxInputStream, wxObject)
26 IMPLEMENT_ABSTRACT_CLASS(wxOutputStream, wxObject)
27 IMPLEMENT_CLASS(wxFilterInputStream, wxInputStream)
28 IMPLEMENT_CLASS(wxFilterOutputStream, wxOutputStream)
29 #endif
30
31 wxInputStream::wxInputStream()
32 : wxObject()
33 {
34 }
35
36 wxInputStream::~wxInputStream()
37 {
38 }
39
40 #define BUF_TEMP_SIZE 10000
41
42 wxInputStream& wxInputStream::Read(wxOutputStream& stream_out)
43 {
44 char buf[BUF_TEMP_SIZE];
45 size_t bytes_read = BUF_TEMP_SIZE;
46
47 while (bytes_read == BUF_TEMP_SIZE && !stream_out.Bad()) {
48 bytes_read = Read(buf, bytes_read).LastRead();
49
50 stream_out.Write(buf, bytes_read);
51 }
52 return *this;
53 }
54
55 wxOutputStream::wxOutputStream()
56 : wxObject()
57 {
58 }
59
60 wxOutputStream::~wxOutputStream()
61 {
62 }
63
64 wxOutputStream& wxOutputStream::Write(wxInputStream& stream_in)
65 {
66 stream_in.Read(*this);
67 return *this;
68 }
69
70 wxFilterInputStream::wxFilterInputStream(wxInputStream& stream)
71 : wxInputStream()
72 {
73 m_parent_i_stream = &stream;
74 }
75
76 wxFilterInputStream::~wxFilterInputStream()
77 {
78 }
79
80 wxFilterOutputStream::wxFilterOutputStream(wxOutputStream& stream)
81 : wxOutputStream()
82 {
83 m_parent_o_stream = &stream;
84 }
85
86 wxFilterOutputStream::~wxFilterOutputStream()
87 {
88 }