]>
git.saurik.com Git - wxWidgets.git/blob - src/common/datstrm.cpp
15a5ef78a8e74e92e6573546149534cb1364cd6b
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Data stream classes
4 // Author: Guilhem Lavaux
8 // Copyright: (c) Guilhem Lavaux
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "datstrm.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
27 #include "wx/datstrm.h"
29 #if !USE_SHARED_LIBRARY
30 IMPLEMENT_CLASS(wxDataInputStream
, wxFilterInputStream
)
31 IMPLEMENT_CLASS(wxDataOutputStream
, wxFilterOutputStream
)
34 wxDataInputStream::wxDataInputStream(wxInputStream
& s
)
35 : wxFilterInputStream(s
)
39 wxDataInputStream::~wxDataInputStream()
43 unsigned long wxDataInputStream::Read32()
47 if (!m_parent_i_stream
)
52 return (unsigned long)buf
[0] |
53 ((unsigned long)buf
[1] << 8) |
54 ((unsigned long)buf
[2] << 16) |
55 ((unsigned long)buf
[3] << 24);
58 unsigned short wxDataInputStream::Read16()
62 if (!m_parent_i_stream
)
67 return (unsigned short)buf
[0] |
68 ((unsigned short)buf
[1] << 8);
71 unsigned char wxDataInputStream::Read8()
75 if (!m_parent_i_stream
)
79 return (unsigned char)buf
;
82 // Must be at global scope for VC++ 5
83 extern "C" double ConvertFromIeeeExtended(const unsigned char *bytes
);
85 double wxDataInputStream::ReadDouble()
90 if (!m_parent_i_stream
)
94 return ConvertFromIeeeExtended((unsigned char *)buf
);
100 wxString
wxDataInputStream::ReadLine()
104 if (!m_parent_i_stream
)
107 // TODO: Implement ReadLine
111 wxString
wxDataInputStream::ReadString()
117 if (!m_parent_i_stream
)
121 string
= new char[len
+1];
132 wxDataOutputStream::wxDataOutputStream(wxOutputStream
& s
)
133 : wxFilterOutputStream(s
)
137 void wxDataOutputStream::Write32(unsigned long i
)
141 if (!m_parent_o_stream
)
145 buf
[1] = (i
>> 8) & 0xff;
146 buf
[2] = (i
>> 16) & 0xff;
147 buf
[3] = (i
>> 24) & 0xff;
151 void wxDataOutputStream::Write16(unsigned short i
)
155 if (!m_parent_o_stream
)
159 buf
[1] = (i
>> 8) & 0xff;
163 void wxDataOutputStream::Write8(unsigned char i
)
165 if (!m_parent_o_stream
)
171 void wxDataOutputStream::WriteLine(const wxString
& line
)
174 wxString tmp_string
= line
+ "\r\n";
176 wxString tmp_string
= line
+ '\n';
179 if (!m_parent_o_stream
)
182 Write((const char *) tmp_string
, tmp_string
.Length());
185 void wxDataOutputStream::WriteString(const wxString
& string
)
187 if (!m_parent_o_stream
)
190 Write32(string
.Length());
191 Write((const char *) string
, string
.Length());
194 // Must be at global scope for VC++ 5
195 extern "C" void ConvertToIeeeExtended(double num
, unsigned char *bytes
);
197 void wxDataOutputStream::WriteDouble(double d
)
201 if (!m_parent_o_stream
)
205 ConvertToIeeeExtended(d
, (unsigned char *)buf
);
207 # pragma warning "wxDataStream::WriteDouble() not using IeeeExtended - will not work!"