]>
Commit | Line | Data |
---|---|---|
cf447356 | 1 | ///////////////////////////////////////////////////////////////////////////// |
80fdcdb9 | 2 | // Name: wx/datstrm.h |
cf447356 GL |
3 | // Purpose: Data stream classes |
4 | // Author: Guilhem Lavaux | |
53663be8 | 5 | // Modified by: Mickael Gilabert |
cf447356 GL |
6 | // Created: 28/06/1998 |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Guilhem Lavaux | |
68379eaf | 9 | // Licence: wxWindows licence |
cf447356 GL |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
34138703 JS |
12 | #ifndef _WX_DATSTREAM_H_ |
13 | #define _WX_DATSTREAM_H_ | |
cf447356 | 14 | |
ed58dbea | 15 | #include "wx/stream.h" |
41b0a113 | 16 | #include "wx/longlong.h" |
830f8f11 | 17 | #include "wx/convauto.h" |
cf447356 | 18 | |
ce4169a4 RR |
19 | #if wxUSE_STREAMS |
20 | ||
61eb6bb6 VZ |
21 | // Common wxDataInputStream and wxDataOutputStream parameters. |
22 | class WXDLLIMPEXP_BASE wxDataStreamBase | |
4c075b70 | 23 | { |
cf447356 | 24 | public: |
61eb6bb6 VZ |
25 | void BigEndianOrdered(bool be_order) { m_be_order = be_order; } |
26 | ||
789ab840 VZ |
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() | |
32 | { | |
a60b469f | 33 | #if wxUSE_APPLE_IEEE |
789ab840 | 34 | m_useExtendedPrecision = false; |
a60b469f | 35 | #endif // wxUSE_APPLE_IEEE |
789ab840 VZ |
36 | } |
37 | ||
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. | |
42 | #if wxUSE_APPLE_IEEE | |
43 | void UseExtendedPrecision() | |
44 | { | |
45 | m_useExtendedPrecision = true; | |
46 | } | |
47 | #endif // wxUSE_APPLE_IEEE | |
48 | ||
61eb6bb6 VZ |
49 | #if wxUSE_UNICODE |
50 | void SetConv( const wxMBConv &conv ); | |
51 | wxMBConv *GetConv() const { return m_conv; } | |
52 | #endif | |
53 | ||
54 | protected: | |
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); | |
58 | ~wxDataStreamBase(); | |
59 | ||
60 | ||
61 | bool m_be_order; | |
62 | ||
789ab840 VZ |
63 | #if wxUSE_APPLE_IEEE |
64 | bool m_useExtendedPrecision; | |
65 | #endif // wxUSE_APPLE_IEEE | |
66 | ||
a99acbb0 | 67 | #if wxUSE_UNICODE |
61eb6bb6 | 68 | wxMBConv *m_conv; |
a99acbb0 | 69 | #endif |
61eb6bb6 VZ |
70 | |
71 | wxDECLARE_NO_COPY_CLASS(wxDataStreamBase); | |
72 | }; | |
73 | ||
74 | ||
75 | class WXDLLIMPEXP_BASE wxDataInputStream : public wxDataStreamBase | |
76 | { | |
77 | public: | |
78 | wxDataInputStream(wxInputStream& s, const wxMBConv& conv = wxConvUTF8); | |
68379eaf | 79 | |
7eb0e037 | 80 | bool IsOk() { return m_input->IsOk(); } |
cf447356 | 81 | |
216a72f3 | 82 | #if wxHAS_INT64 |
41b0a113 | 83 | wxUint64 Read64(); |
216a72f3 VZ |
84 | #endif |
85 | #if wxUSE_LONGLONG | |
86 | wxLongLong ReadLL(); | |
87 | #endif | |
4c075b70 RR |
88 | wxUint32 Read32(); |
89 | wxUint16 Read16(); | |
90 | wxUint8 Read8(); | |
91 | double ReadDouble(); | |
789ab840 | 92 | float ReadFloat(); |
4c075b70 | 93 | wxString ReadString(); |
fae05df5 | 94 | |
216a72f3 | 95 | #if wxHAS_INT64 |
53663be8 | 96 | void Read64(wxUint64 *buffer, size_t size); |
216a72f3 VZ |
97 | void Read64(wxInt64 *buffer, size_t size); |
98 | #endif | |
99 | #if defined(wxLongLong_t) && wxUSE_LONGLONG | |
100 | void Read64(wxULongLong *buffer, size_t size); | |
101 | void Read64(wxLongLong *buffer, size_t size); | |
102 | #endif | |
103 | #if wxUSE_LONGLONG | |
104 | void ReadLL(wxULongLong *buffer, size_t size); | |
105 | void ReadLL(wxLongLong *buffer, size_t size); | |
106 | #endif | |
53663be8 VZ |
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); | |
789ab840 | 111 | void ReadFloat(float *buffer, size_t size); |
53663be8 | 112 | |
4c075b70 RR |
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); | |
216a72f3 | 120 | #if wxHAS_INT64 |
41b0a113 | 121 | wxDataInputStream& operator>>(wxUint64& i); |
216a72f3 VZ |
122 | wxDataInputStream& operator>>(wxInt64& i); |
123 | #endif | |
124 | #if defined(wxLongLong_t) && wxUSE_LONGLONG | |
125 | wxDataInputStream& operator>>(wxULongLong& i); | |
126 | wxDataInputStream& operator>>(wxLongLong& i); | |
127 | #endif | |
337bbb7a | 128 | wxDataInputStream& operator>>(double& d); |
4c075b70 | 129 | wxDataInputStream& operator>>(float& f); |
5a96d2f4 | 130 | |
4c075b70 RR |
131 | protected: |
132 | wxInputStream *m_input; | |
22f3361e | 133 | |
c0c133e1 | 134 | wxDECLARE_NO_COPY_CLASS(wxDataInputStream); |
3d4c6a21 GL |
135 | }; |
136 | ||
61eb6bb6 | 137 | class WXDLLIMPEXP_BASE wxDataOutputStream : public wxDataStreamBase |
4c075b70 RR |
138 | { |
139 | public: | |
61eb6bb6 | 140 | wxDataOutputStream(wxOutputStream& s, const wxMBConv& conv = wxConvUTF8); |
cf447356 | 141 | |
7eb0e037 RR |
142 | bool IsOk() { return m_output->IsOk(); } |
143 | ||
216a72f3 | 144 | #if wxHAS_INT64 |
41b0a113 | 145 | void Write64(wxUint64 i); |
216a72f3 VZ |
146 | void Write64(wxInt64 i); |
147 | #endif | |
148 | #if wxUSE_LONGLONG | |
149 | void WriteLL(const wxLongLong &ll); | |
150 | void WriteLL(const wxULongLong &ll); | |
151 | #endif | |
4c075b70 RR |
152 | void Write32(wxUint32 i); |
153 | void Write16(wxUint16 i); | |
154 | void Write8(wxUint8 i); | |
155 | void WriteDouble(double d); | |
789ab840 | 156 | void WriteFloat(float f); |
4c075b70 | 157 | void WriteString(const wxString& string); |
fae05df5 | 158 | |
216a72f3 | 159 | #if wxHAS_INT64 |
53663be8 | 160 | void Write64(const wxUint64 *buffer, size_t size); |
216a72f3 VZ |
161 | void Write64(const wxInt64 *buffer, size_t size); |
162 | #endif | |
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); | |
166 | #endif | |
167 | #if wxUSE_LONGLONG | |
168 | void WriteLL(const wxULongLong *buffer, size_t size); | |
169 | void WriteLL(const wxLongLong *buffer, size_t size); | |
170 | #endif | |
53663be8 VZ |
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); | |
789ab840 | 175 | void WriteFloat(const float *buffer, size_t size); |
53663be8 | 176 | |
38caaa61 | 177 | wxDataOutputStream& operator<<(const wxString& string); |
4c075b70 RR |
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); | |
216a72f3 | 184 | #if wxHAS_INT64 |
41b0a113 | 185 | wxDataOutputStream& operator<<(wxUint64 i); |
216a72f3 VZ |
186 | wxDataOutputStream& operator<<(wxInt64 i); |
187 | #endif | |
188 | #if defined(wxLongLong_t) && wxUSE_LONGLONG | |
189 | wxDataOutputStream& operator<<(const wxULongLong &i); | |
190 | wxDataOutputStream& operator<<(const wxLongLong &i); | |
191 | #endif | |
337bbb7a | 192 | wxDataOutputStream& operator<<(double d); |
4c075b70 | 193 | wxDataOutputStream& operator<<(float f); |
fae05df5 | 194 | |
4c075b70 RR |
195 | protected: |
196 | wxOutputStream *m_output; | |
22f3361e | 197 | |
c0c133e1 | 198 | wxDECLARE_NO_COPY_CLASS(wxDataOutputStream); |
cf447356 GL |
199 | }; |
200 | ||
ce4169a4 RR |
201 | #endif |
202 | // wxUSE_STREAMS | |
203 | ||
cf447356 | 204 | #endif |
34138703 | 205 | // _WX_DATSTREAM_H_ |