1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Data stream classes
4 // Author: Guilhem Lavaux
5 // Modified by: Mickael Gilabert
8 // Copyright: (c) Guilhem Lavaux
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_DATSTREAM_H_
13 #define _WX_DATSTREAM_H_
15 #include "wx/stream.h"
16 #include "wx/longlong.h"
17 #include "wx/convauto.h"
21 // Common wxDataInputStream and wxDataOutputStream parameters.
22 class WXDLLIMPEXP_BASE wxDataStreamBase
25 void BigEndianOrdered(bool be_order
) { m_be_order
= be_order
; }
27 // By default we use extended precision (80 bit) format for both float and
28 // doubles. Call this function to switch to alternative representation in
29 // which IEEE 754 single precision (32 bits) is used for floats and double
30 // precision (64 bits) is used for doubles.
31 void UseBasicPrecisions()
34 m_useExtendedPrecision
= false;
35 #endif // wxUSE_APPLE_IEEE
38 // UseExtendedPrecision() is not very useful as it corresponds to the
39 // default value, only call it in your code if you want the compilation
40 // fail with the error when using wxWidgets library compiled without
41 // extended precision support.
43 void UseExtendedPrecision()
45 m_useExtendedPrecision
= true;
47 #endif // wxUSE_APPLE_IEEE
50 void SetConv( const wxMBConv
&conv
);
51 wxMBConv
*GetConv() const { return m_conv
; }
55 // Ctor and dtor are both protected, this class is never used directly but
56 // only by its derived classes.
57 wxDataStreamBase(const wxMBConv
& conv
);
64 bool m_useExtendedPrecision
;
65 #endif // wxUSE_APPLE_IEEE
71 wxDECLARE_NO_COPY_CLASS(wxDataStreamBase
);
75 class WXDLLIMPEXP_BASE wxDataInputStream
: public wxDataStreamBase
78 wxDataInputStream(wxInputStream
& s
, const wxMBConv
& conv
= wxConvUTF8
);
80 bool IsOk() { return m_input
->IsOk(); }
93 wxString
ReadString();
96 void Read64(wxUint64
*buffer
, size_t size
);
97 void Read64(wxInt64
*buffer
, size_t size
);
99 #if defined(wxLongLong_t) && wxUSE_LONGLONG
100 void Read64(wxULongLong
*buffer
, size_t size
);
101 void Read64(wxLongLong
*buffer
, size_t size
);
104 void ReadLL(wxULongLong
*buffer
, size_t size
);
105 void ReadLL(wxLongLong
*buffer
, size_t size
);
107 void Read32(wxUint32
*buffer
, size_t size
);
108 void Read16(wxUint16
*buffer
, size_t size
);
109 void Read8(wxUint8
*buffer
, size_t size
);
110 void ReadDouble(double *buffer
, size_t size
);
111 void ReadFloat(float *buffer
, size_t size
);
113 wxDataInputStream
& operator>>(wxString
& s
);
114 wxDataInputStream
& operator>>(wxInt8
& c
);
115 wxDataInputStream
& operator>>(wxInt16
& i
);
116 wxDataInputStream
& operator>>(wxInt32
& i
);
117 wxDataInputStream
& operator>>(wxUint8
& c
);
118 wxDataInputStream
& operator>>(wxUint16
& i
);
119 wxDataInputStream
& operator>>(wxUint32
& i
);
121 wxDataInputStream
& operator>>(wxUint64
& i
);
122 wxDataInputStream
& operator>>(wxInt64
& i
);
124 #if defined(wxLongLong_t) && wxUSE_LONGLONG
125 wxDataInputStream
& operator>>(wxULongLong
& i
);
126 wxDataInputStream
& operator>>(wxLongLong
& i
);
128 wxDataInputStream
& operator>>(double& d
);
129 wxDataInputStream
& operator>>(float& f
);
132 wxInputStream
*m_input
;
134 wxDECLARE_NO_COPY_CLASS(wxDataInputStream
);
137 class WXDLLIMPEXP_BASE wxDataOutputStream
: public wxDataStreamBase
140 wxDataOutputStream(wxOutputStream
& s
, const wxMBConv
& conv
= wxConvUTF8
);
142 bool IsOk() { return m_output
->IsOk(); }
145 void Write64(wxUint64 i
);
146 void Write64(wxInt64 i
);
149 void WriteLL(const wxLongLong
&ll
);
150 void WriteLL(const wxULongLong
&ll
);
152 void Write32(wxUint32 i
);
153 void Write16(wxUint16 i
);
154 void Write8(wxUint8 i
);
155 void WriteDouble(double d
);
156 void WriteFloat(float f
);
157 void WriteString(const wxString
& string
);
160 void Write64(const wxUint64
*buffer
, size_t size
);
161 void Write64(const wxInt64
*buffer
, size_t size
);
163 #if defined(wxLongLong_t) && wxUSE_LONGLONG
164 void Write64(const wxULongLong
*buffer
, size_t size
);
165 void Write64(const wxLongLong
*buffer
, size_t size
);
168 void WriteLL(const wxULongLong
*buffer
, size_t size
);
169 void WriteLL(const wxLongLong
*buffer
, size_t size
);
171 void Write32(const wxUint32
*buffer
, size_t size
);
172 void Write16(const wxUint16
*buffer
, size_t size
);
173 void Write8(const wxUint8
*buffer
, size_t size
);
174 void WriteDouble(const double *buffer
, size_t size
);
175 void WriteFloat(const float *buffer
, size_t size
);
177 wxDataOutputStream
& operator<<(const wxString
& string
);
178 wxDataOutputStream
& operator<<(wxInt8 c
);
179 wxDataOutputStream
& operator<<(wxInt16 i
);
180 wxDataOutputStream
& operator<<(wxInt32 i
);
181 wxDataOutputStream
& operator<<(wxUint8 c
);
182 wxDataOutputStream
& operator<<(wxUint16 i
);
183 wxDataOutputStream
& operator<<(wxUint32 i
);
185 wxDataOutputStream
& operator<<(wxUint64 i
);
186 wxDataOutputStream
& operator<<(wxInt64 i
);
188 #if defined(wxLongLong_t) && wxUSE_LONGLONG
189 wxDataOutputStream
& operator<<(const wxULongLong
&i
);
190 wxDataOutputStream
& operator<<(const wxLongLong
&i
);
192 wxDataOutputStream
& operator<<(double d
);
193 wxDataOutputStream
& operator<<(float f
);
196 wxOutputStream
*m_output
;
198 wxDECLARE_NO_COPY_CLASS(wxDataOutputStream
);