]>
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 #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()
49 return (unsigned long)buf
[0] |
50 ((unsigned long)buf
[1] << 8) |
51 ((unsigned long)buf
[2] << 16) |
52 ((unsigned long)buf
[3] << 24);
55 unsigned short wxDataInputStream::Read16()
61 return (unsigned short)buf
[0] |
62 ((unsigned short)buf
[1] << 8);
65 unsigned char wxDataInputStream::Read8()
70 return (unsigned char)buf
;
73 // Must be at global scope for VC++ 5
74 extern "C" double ConvertFromIeeeExtended(const unsigned char *bytes
);
76 double wxDataInputStream::ReadDouble()
82 return ConvertFromIeeeExtended((unsigned char *)buf
);
88 wxString
wxDataInputStream::ReadLine()
92 // TODO: Implement ReadLine
96 wxString
wxDataInputStream::ReadString()
103 string
= new char[len
+1];
114 wxDataOutputStream::wxDataOutputStream(wxOutputStream
& s
)
115 : wxFilterOutputStream(s
)
119 wxDataOutputStream::~wxDataOutputStream()
123 void wxDataOutputStream::Write32(unsigned long i
)
128 buf
[1] = (i
>> 8) & 0xff;
129 buf
[2] = (i
>> 16) & 0xff;
130 buf
[3] = (i
>> 24) & 0xff;
134 void wxDataOutputStream::Write16(unsigned short i
)
139 buf
[1] = (i
>> 8) & 0xff;
143 void wxDataOutputStream::Write8(unsigned char i
)
148 void wxDataOutputStream::WriteLine(const wxString
& line
)
151 wxString tmp_string
= line
+ "\r\n";
153 wxString tmp_string
= line
+ '\n';
156 Write((const char *) tmp_string
, tmp_string
.Length());
159 void wxDataOutputStream::WriteString(const wxString
& string
)
161 Write32(string
.Length());
162 Write((const char *) string
, string
.Length());
165 // Must be at global scope for VC++ 5
166 extern "C" void ConvertToIeeeExtended(double num
, unsigned char *bytes
);
168 void wxDataOutputStream::WriteDouble(double d
)
173 ConvertToIeeeExtended(d
, (unsigned char *)buf
);
175 # pragma warning "wxDataStream::WriteDouble() not using IeeeExtended - will not work!"