1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Data stream classes
4 // Author: Guilhem Lavaux
5 // Modified by: Mickael Gilabert
7 // Copyright: (c) Guilhem Lavaux
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_DATSTREAM_H_
12 #define _WX_DATSTREAM_H_
14 #include "wx/stream.h"
15 #include "wx/longlong.h"
16 #include "wx/convauto.h"
20 // Common wxDataInputStream and wxDataOutputStream parameters.
21 class WXDLLIMPEXP_BASE wxDataStreamBase
24 void BigEndianOrdered(bool be_order
) { m_be_order
= be_order
; }
26 // By default we use extended precision (80 bit) format for both float and
27 // doubles. Call this function to switch to alternative representation in
28 // which IEEE 754 single precision (32 bits) is used for floats and double
29 // precision (64 bits) is used for doubles.
30 void UseBasicPrecisions()
33 m_useExtendedPrecision
= false;
34 #endif // wxUSE_APPLE_IEEE
37 // UseExtendedPrecision() is not very useful as it corresponds to the
38 // default value, only call it in your code if you want the compilation
39 // fail with the error when using wxWidgets library compiled without
40 // extended precision support.
42 void UseExtendedPrecision()
44 m_useExtendedPrecision
= true;
46 #endif // wxUSE_APPLE_IEEE
49 void SetConv( const wxMBConv
&conv
);
50 wxMBConv
*GetConv() const { return m_conv
; }
54 // Ctor and dtor are both protected, this class is never used directly but
55 // only by its derived classes.
56 wxDataStreamBase(const wxMBConv
& conv
);
63 bool m_useExtendedPrecision
;
64 #endif // wxUSE_APPLE_IEEE
70 wxDECLARE_NO_COPY_CLASS(wxDataStreamBase
);
74 class WXDLLIMPEXP_BASE wxDataInputStream
: public wxDataStreamBase
77 wxDataInputStream(wxInputStream
& s
, const wxMBConv
& conv
= wxConvUTF8
);
79 bool IsOk() { return m_input
->IsOk(); }
92 wxString
ReadString();
95 void Read64(wxUint64
*buffer
, size_t size
);
96 void Read64(wxInt64
*buffer
, size_t size
);
98 #if defined(wxLongLong_t) && wxUSE_LONGLONG
99 void Read64(wxULongLong
*buffer
, size_t size
);
100 void Read64(wxLongLong
*buffer
, size_t size
);
103 void ReadLL(wxULongLong
*buffer
, size_t size
);
104 void ReadLL(wxLongLong
*buffer
, size_t size
);
106 void Read32(wxUint32
*buffer
, size_t size
);
107 void Read16(wxUint16
*buffer
, size_t size
);
108 void Read8(wxUint8
*buffer
, size_t size
);
109 void ReadDouble(double *buffer
, size_t size
);
110 void ReadFloat(float *buffer
, size_t size
);
112 wxDataInputStream
& operator>>(wxString
& s
);
113 wxDataInputStream
& operator>>(wxInt8
& c
);
114 wxDataInputStream
& operator>>(wxInt16
& i
);
115 wxDataInputStream
& operator>>(wxInt32
& i
);
116 wxDataInputStream
& operator>>(wxUint8
& c
);
117 wxDataInputStream
& operator>>(wxUint16
& i
);
118 wxDataInputStream
& operator>>(wxUint32
& i
);
120 wxDataInputStream
& operator>>(wxUint64
& i
);
121 wxDataInputStream
& operator>>(wxInt64
& i
);
123 #if defined(wxLongLong_t) && wxUSE_LONGLONG
124 wxDataInputStream
& operator>>(wxULongLong
& i
);
125 wxDataInputStream
& operator>>(wxLongLong
& i
);
127 wxDataInputStream
& operator>>(double& d
);
128 wxDataInputStream
& operator>>(float& f
);
131 wxInputStream
*m_input
;
133 wxDECLARE_NO_COPY_CLASS(wxDataInputStream
);
136 class WXDLLIMPEXP_BASE wxDataOutputStream
: public wxDataStreamBase
139 wxDataOutputStream(wxOutputStream
& s
, const wxMBConv
& conv
= wxConvUTF8
);
141 bool IsOk() { return m_output
->IsOk(); }
144 void Write64(wxUint64 i
);
145 void Write64(wxInt64 i
);
148 void WriteLL(const wxLongLong
&ll
);
149 void WriteLL(const wxULongLong
&ll
);
151 void Write32(wxUint32 i
);
152 void Write16(wxUint16 i
);
153 void Write8(wxUint8 i
);
154 void WriteDouble(double d
);
155 void WriteFloat(float f
);
156 void WriteString(const wxString
& string
);
159 void Write64(const wxUint64
*buffer
, size_t size
);
160 void Write64(const wxInt64
*buffer
, size_t size
);
162 #if defined(wxLongLong_t) && wxUSE_LONGLONG
163 void Write64(const wxULongLong
*buffer
, size_t size
);
164 void Write64(const wxLongLong
*buffer
, size_t size
);
167 void WriteLL(const wxULongLong
*buffer
, size_t size
);
168 void WriteLL(const wxLongLong
*buffer
, size_t size
);
170 void Write32(const wxUint32
*buffer
, size_t size
);
171 void Write16(const wxUint16
*buffer
, size_t size
);
172 void Write8(const wxUint8
*buffer
, size_t size
);
173 void WriteDouble(const double *buffer
, size_t size
);
174 void WriteFloat(const float *buffer
, size_t size
);
176 wxDataOutputStream
& operator<<(const wxString
& string
);
177 wxDataOutputStream
& operator<<(wxInt8 c
);
178 wxDataOutputStream
& operator<<(wxInt16 i
);
179 wxDataOutputStream
& operator<<(wxInt32 i
);
180 wxDataOutputStream
& operator<<(wxUint8 c
);
181 wxDataOutputStream
& operator<<(wxUint16 i
);
182 wxDataOutputStream
& operator<<(wxUint32 i
);
184 wxDataOutputStream
& operator<<(wxUint64 i
);
185 wxDataOutputStream
& operator<<(wxInt64 i
);
187 #if defined(wxLongLong_t) && wxUSE_LONGLONG
188 wxDataOutputStream
& operator<<(const wxULongLong
&i
);
189 wxDataOutputStream
& operator<<(const wxLongLong
&i
);
191 wxDataOutputStream
& operator<<(double d
);
192 wxDataOutputStream
& operator<<(float f
);
195 wxOutputStream
*m_output
;
197 wxDECLARE_NO_COPY_CLASS(wxDataOutputStream
);