* New wxStream classes: wxStreamBuffer and wxObject*Stream.
[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 // ----------------------------------------------------------------------------
25 // wxInputStream
26 // ----------------------------------------------------------------------------
27
28 wxInputStream::wxInputStream()
29 {
30 }
31
32 wxInputStream::~wxInputStream()
33 {
34 }
35
36 #define BUF_TEMP_SIZE 10000
37
38 wxInputStream& wxInputStream::Read(wxOutputStream& stream_out)
39 {
40 char buf[BUF_TEMP_SIZE];
41 size_t bytes_read = BUF_TEMP_SIZE;
42
43 while (bytes_read == BUF_TEMP_SIZE && !stream_out.Bad()) {
44 bytes_read = Read(buf, bytes_read).LastRead();
45
46 stream_out.Write(buf, bytes_read);
47 }
48 return *this;
49 }
50
51 int wxInputStream::Scanf(const wxString& format, ...)
52 {
53 va_list params;
54
55 va_start(params, format);
56 va_end(params);
57 }
58
59 wxInputStream& wxInputStream::operator>>(wxString& line)
60 {
61 wxDataInputStream s(*this);
62
63 line = s.ReadLine();
64 return *this;
65 }
66
67 wxInputStream& wxInputStream::operator>>(char& c)
68 {
69 c = GetC();
70 }
71
72 wxInputStream& wxInputStream::operator>>(short& i)
73 {
74 Scanf("%i", &i);
75 return *this;
76 }
77
78 wxInputStream& wxInputStream::operator>>(long& i)
79 {
80 Scanf("%l", &i);
81 return *this;
82 }
83
84 wxInputStream& wxInputStream::operator>>(float& f)
85 {
86 Scanf("%f", &f);
87 return *this;
88 }
89
90 // ----------------------------------------------------------------------------
91 // wxOutputStream
92 // ----------------------------------------------------------------------------
93 wxOutputStream::wxOutputStream()
94 {
95 }
96
97 wxOutputStream::~wxOutputStream()
98 {
99 }
100
101 wxOutputStream& wxOutputStream::Write(wxInputStream& stream_in)
102 {
103 stream_in.Read(*this);
104 return *this;
105 }
106
107 // ----------------------------------------------------------------------------
108 // wxFilterInputStream
109 // ----------------------------------------------------------------------------
110 wxFilterInputStream::wxFilterInputStream(wxInputStream& stream)
111 : wxInputStream()
112 {
113 m_parent_i_stream = &stream;
114 }
115
116 wxFilterInputStream::~wxFilterInputStream()
117 {
118 }
119
120 // ----------------------------------------------------------------------------
121 // wxFilterOutputStream
122 // ----------------------------------------------------------------------------
123 wxFilterOutputStream::wxFilterOutputStream(wxOutputStream& stream)
124 : wxOutputStream()
125 {
126 m_parent_o_stream = &stream;
127 }
128
129 wxFilterOutputStream::~wxFilterOutputStream()
130 {
131 }