]> git.saurik.com Git - wxWidgets.git/blob - include/wx/datstrm.h
wxDialogBase only has one ctor, so just do initialization in ctor instead of Init()
[wxWidgets.git] / include / wx / datstrm.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/datstrm.h
3 // Purpose: Data stream classes
4 // Author: Guilhem Lavaux
5 // Modified by: Mickael Gilabert
6 // Created: 28/06/1998
7 // Copyright: (c) Guilhem Lavaux
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_DATSTREAM_H_
12 #define _WX_DATSTREAM_H_
13
14 #include "wx/stream.h"
15 #include "wx/longlong.h"
16 #include "wx/convauto.h"
17
18 #if wxUSE_STREAMS
19
20 // Common wxDataInputStream and wxDataOutputStream parameters.
21 class WXDLLIMPEXP_BASE wxDataStreamBase
22 {
23 public:
24 void BigEndianOrdered(bool be_order) { m_be_order = be_order; }
25
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 {
32 #if wxUSE_APPLE_IEEE
33 m_useExtendedPrecision = false;
34 #endif // wxUSE_APPLE_IEEE
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
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
62 #if wxUSE_APPLE_IEEE
63 bool m_useExtendedPrecision;
64 #endif // wxUSE_APPLE_IEEE
65
66 #if wxUSE_UNICODE
67 wxMBConv *m_conv;
68 #endif
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);
78
79 bool IsOk() { return m_input->IsOk(); }
80
81 #if wxHAS_INT64
82 wxUint64 Read64();
83 #endif
84 #if wxUSE_LONGLONG
85 wxLongLong ReadLL();
86 #endif
87 wxUint32 Read32();
88 wxUint16 Read16();
89 wxUint8 Read8();
90 double ReadDouble();
91 float ReadFloat();
92 wxString ReadString();
93
94 #if wxHAS_INT64
95 void Read64(wxUint64 *buffer, size_t size);
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
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);
111
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);
119 #if wxHAS_INT64
120 wxDataInputStream& operator>>(wxUint64& i);
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
127 wxDataInputStream& operator>>(double& d);
128 wxDataInputStream& operator>>(float& f);
129
130 protected:
131 wxInputStream *m_input;
132
133 wxDECLARE_NO_COPY_CLASS(wxDataInputStream);
134 };
135
136 class WXDLLIMPEXP_BASE wxDataOutputStream : public wxDataStreamBase
137 {
138 public:
139 wxDataOutputStream(wxOutputStream& s, const wxMBConv& conv = wxConvUTF8);
140
141 bool IsOk() { return m_output->IsOk(); }
142
143 #if wxHAS_INT64
144 void Write64(wxUint64 i);
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
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);
157
158 #if wxHAS_INT64
159 void Write64(const wxUint64 *buffer, size_t size);
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
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);
175
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);
183 #if wxHAS_INT64
184 wxDataOutputStream& operator<<(wxUint64 i);
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
191 wxDataOutputStream& operator<<(double d);
192 wxDataOutputStream& operator<<(float f);
193
194 protected:
195 wxOutputStream *m_output;
196
197 wxDECLARE_NO_COPY_CLASS(wxDataOutputStream);
198 };
199
200 #endif
201 // wxUSE_STREAMS
202
203 #endif
204 // _WX_DATSTREAM_H_