]>
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"
25 #include "wx/datstrm.h"
27 // ---------------------------------------------------------------------------
29 // ---------------------------------------------------------------------------
31 wxDataInputStream::wxDataInputStream(wxInputStream
& s
)
32 : wxFilterInputStream(s
)
36 wxDataInputStream::~wxDataInputStream()
40 wxUint32
wxDataInputStream::Read32()
46 return (wxUint32
)buf
[0] |
47 ((wxUint32
)buf
[1] << 8) |
48 ((wxUint32
)buf
[2] << 16) |
49 ((wxUint32
)buf
[3] << 24);
52 wxUint16
wxDataInputStream::Read16()
58 return (wxUint16
)buf
[0] |
59 ((wxUint16
)buf
[1] << 8);
62 wxUint8
wxDataInputStream::Read8()
66 Read((char *)&buf
, 1);
70 // Must be at global scope for VC++ 5
71 extern "C" double ConvertFromIeeeExtended(const unsigned char *bytes
);
73 double wxDataInputStream::ReadDouble()
79 return ConvertFromIeeeExtended((unsigned char *)buf
);
85 wxString
wxDataInputStream::ReadString()
92 string
= new char[len
+1];
103 // ---------------------------------------------------------------------------
104 // wxDataOutputStream
105 // ---------------------------------------------------------------------------
107 wxDataOutputStream::wxDataOutputStream(wxOutputStream
& s
)
108 : wxFilterOutputStream(s
)
112 wxDataOutputStream::~wxDataOutputStream()
116 void wxDataOutputStream::Write32(wxUint32 i
)
121 buf
[1] = (i
>> 8) & 0xff;
122 buf
[2] = (i
>> 16) & 0xff;
123 buf
[3] = (i
>> 24) & 0xff;
127 void wxDataOutputStream::Write16(wxUint16 i
)
132 buf
[1] = (i
>> 8) & 0xff;
136 void wxDataOutputStream::Write8(wxUint8 i
)
141 void wxDataOutputStream::WriteString(const wxString
& string
)
143 Write32(string
.Length());
144 Write((const wxChar
*) string
, string
.Length()*sizeof(wxChar
));
147 // Must be at global scope for VC++ 5
148 extern "C" void ConvertToIeeeExtended(double num
, unsigned char *bytes
);
150 void wxDataOutputStream::WriteDouble(double d
)
155 ConvertToIeeeExtended(d
, (unsigned char *)buf
);
157 # pragma warning "wxDataOutputStream::WriteDouble() not using IeeeExtended - will not work!"