]>
git.saurik.com Git - wxWidgets.git/blob - src/common/datstrm.cpp
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 wxDataInputStream::wxDataInputStream(wxInputStream
& s
)
30 : wxFilterInputStream(s
)
34 wxDataInputStream::~wxDataInputStream()
38 unsigned long wxDataInputStream::Read32()
44 return (unsigned long)buf
[0] |
45 ((unsigned long)buf
[1] << 8) |
46 ((unsigned long)buf
[2] << 16) |
47 ((unsigned long)buf
[3] << 24);
50 unsigned short wxDataInputStream::Read16()
56 return (unsigned short)buf
[0] |
57 ((unsigned short)buf
[1] << 8);
60 unsigned char wxDataInputStream::Read8()
65 return (unsigned char)buf
;
68 // Must be at global scope for VC++ 5
69 extern "C" double ConvertFromIeeeExtended(const unsigned char *bytes
);
71 double wxDataInputStream::ReadDouble()
77 return ConvertFromIeeeExtended((unsigned char *)buf
);
83 wxString
wxDataInputStream::ReadLine()
85 char c
, last_endl
= 0;
86 bool end_line
= FALSE
;
99 if (last_endl
== '\r') {
101 InputStreamBuffer()->WriteBack(c
);
111 wxString
wxDataInputStream::ReadString()
118 string
= new char[len
+1];
129 wxDataOutputStream::wxDataOutputStream(wxOutputStream
& s
)
130 : wxFilterOutputStream(s
)
134 wxDataOutputStream::~wxDataOutputStream()
138 void wxDataOutputStream::Write32(unsigned long i
)
143 buf
[1] = (i
>> 8) & 0xff;
144 buf
[2] = (i
>> 16) & 0xff;
145 buf
[3] = (i
>> 24) & 0xff;
149 void wxDataOutputStream::Write16(unsigned short i
)
154 buf
[1] = (i
>> 8) & 0xff;
158 void wxDataOutputStream::Write8(unsigned char i
)
163 void wxDataOutputStream::WriteLine(const wxString
& line
)
166 wxString tmp_string
= line
+ "\r\n";
168 wxString tmp_string
= line
+ '\n';
171 Write((const char *) tmp_string
, tmp_string
.Length());
174 void wxDataOutputStream::WriteString(const wxString
& string
)
176 Write32(string
.Length());
177 Write((const char *) string
, string
.Length());
180 // Must be at global scope for VC++ 5
181 extern "C" void ConvertToIeeeExtended(double num
, unsigned char *bytes
);
183 void wxDataOutputStream::WriteDouble(double d
)
188 ConvertToIeeeExtended(d
, (unsigned char *)buf
);
190 # pragma warning "wxDataStream::WriteDouble() not using IeeeExtended - will not work!"