]>
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"
30 #if !USE_SHARED_LIBRARY
31 IMPLEMENT_CLASS(wxDataInputStream, wxFilterInputStream)
32 IMPLEMENT_CLASS(wxDataOutputStream, wxFilterOutputStream)
36 wxDataInputStream::wxDataInputStream(wxInputStream
& s
)
37 : wxFilterInputStream(s
)
41 wxDataInputStream::~wxDataInputStream()
45 unsigned long wxDataInputStream::Read32()
51 return (unsigned long)buf
[0] |
52 ((unsigned long)buf
[1] << 8) |
53 ((unsigned long)buf
[2] << 16) |
54 ((unsigned long)buf
[3] << 24);
57 unsigned short wxDataInputStream::Read16()
63 return (unsigned short)buf
[0] |
64 ((unsigned short)buf
[1] << 8);
67 unsigned char wxDataInputStream::Read8()
72 return (unsigned char)buf
;
75 // Must be at global scope for VC++ 5
76 extern "C" double ConvertFromIeeeExtended(const unsigned char *bytes
);
78 double wxDataInputStream::ReadDouble()
84 return ConvertFromIeeeExtended((unsigned char *)buf
);
90 wxString
wxDataInputStream::ReadLine()
94 // TODO: Implement ReadLine
98 wxString
wxDataInputStream::ReadString()
105 string
= new char[len
+1];
116 wxDataOutputStream::wxDataOutputStream(wxOutputStream
& s
)
117 : wxFilterOutputStream(s
)
121 wxDataOutputStream::~wxDataOutputStream()
125 void wxDataOutputStream::Write32(unsigned long i
)
130 buf
[1] = (i
>> 8) & 0xff;
131 buf
[2] = (i
>> 16) & 0xff;
132 buf
[3] = (i
>> 24) & 0xff;
136 void wxDataOutputStream::Write16(unsigned short i
)
141 buf
[1] = (i
>> 8) & 0xff;
145 void wxDataOutputStream::Write8(unsigned char i
)
150 void wxDataOutputStream::WriteLine(const wxString
& line
)
153 wxString tmp_string
= line
+ "\r\n";
155 wxString tmp_string
= line
+ '\n';
158 Write((const char *) tmp_string
, tmp_string
.Length());
161 void wxDataOutputStream::WriteString(const wxString
& string
)
163 Write32(string
.Length());
164 Write((const char *) string
, string
.Length());
167 // Must be at global scope for VC++ 5
168 extern "C" void ConvertToIeeeExtended(double num
, unsigned char *bytes
);
170 void wxDataOutputStream::WriteDouble(double d
)
175 ConvertToIeeeExtended(d
, (unsigned char *)buf
);
177 # pragma warning "wxDataStream::WriteDouble() not using IeeeExtended - will not work!"