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