]>
Commit | Line | Data |
---|---|---|
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 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Guilhem Lavaux | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_DATSTREAM_H_ | |
13 | #define _WX_DATSTREAM_H_ | |
14 | ||
15 | #include "wx/stream.h" | |
16 | #include "wx/longlong.h" | |
17 | #include "wx/convauto.h" | |
18 | ||
19 | #if wxUSE_STREAMS | |
20 | ||
21 | class WXDLLIMPEXP_BASE wxDataInputStream | |
22 | { | |
23 | public: | |
24 | #if wxUSE_UNICODE | |
25 | wxDataInputStream(wxInputStream& s, const wxMBConv& conv = wxConvUTF8 ); | |
26 | #else | |
27 | wxDataInputStream(wxInputStream& s); | |
28 | #endif | |
29 | ~wxDataInputStream(); | |
30 | ||
31 | bool IsOk() { return m_input->IsOk(); } | |
32 | ||
33 | #if wxHAS_INT64 | |
34 | wxUint64 Read64(); | |
35 | #endif | |
36 | #if wxUSE_LONGLONG | |
37 | wxLongLong ReadLL(); | |
38 | #endif | |
39 | wxUint32 Read32(); | |
40 | wxUint16 Read16(); | |
41 | wxUint8 Read8(); | |
42 | double ReadDouble(); | |
43 | wxString ReadString(); | |
44 | ||
45 | #if wxHAS_INT64 | |
46 | void Read64(wxUint64 *buffer, size_t size); | |
47 | void Read64(wxInt64 *buffer, size_t size); | |
48 | #endif | |
49 | #if defined(wxLongLong_t) && wxUSE_LONGLONG | |
50 | void Read64(wxULongLong *buffer, size_t size); | |
51 | void Read64(wxLongLong *buffer, size_t size); | |
52 | #endif | |
53 | #if wxUSE_LONGLONG | |
54 | void ReadLL(wxULongLong *buffer, size_t size); | |
55 | void ReadLL(wxLongLong *buffer, size_t size); | |
56 | #endif | |
57 | void Read32(wxUint32 *buffer, size_t size); | |
58 | void Read16(wxUint16 *buffer, size_t size); | |
59 | void Read8(wxUint8 *buffer, size_t size); | |
60 | void ReadDouble(double *buffer, size_t size); | |
61 | ||
62 | wxDataInputStream& operator>>(wxString& s); | |
63 | wxDataInputStream& operator>>(wxInt8& c); | |
64 | wxDataInputStream& operator>>(wxInt16& i); | |
65 | wxDataInputStream& operator>>(wxInt32& i); | |
66 | wxDataInputStream& operator>>(wxUint8& c); | |
67 | wxDataInputStream& operator>>(wxUint16& i); | |
68 | wxDataInputStream& operator>>(wxUint32& i); | |
69 | #if wxHAS_INT64 | |
70 | wxDataInputStream& operator>>(wxUint64& i); | |
71 | wxDataInputStream& operator>>(wxInt64& i); | |
72 | #endif | |
73 | #if defined(wxLongLong_t) && wxUSE_LONGLONG | |
74 | wxDataInputStream& operator>>(wxULongLong& i); | |
75 | wxDataInputStream& operator>>(wxLongLong& i); | |
76 | #endif | |
77 | wxDataInputStream& operator>>(double& i); | |
78 | wxDataInputStream& operator>>(float& f); | |
79 | ||
80 | void BigEndianOrdered(bool be_order) { m_be_order = be_order; } | |
81 | ||
82 | #if wxUSE_UNICODE | |
83 | void SetConv( const wxMBConv &conv ); | |
84 | wxMBConv *GetConv() const { return m_conv; } | |
85 | #endif | |
86 | ||
87 | protected: | |
88 | wxInputStream *m_input; | |
89 | bool m_be_order; | |
90 | #if wxUSE_UNICODE | |
91 | wxMBConv *m_conv; | |
92 | #endif | |
93 | ||
94 | wxDECLARE_NO_COPY_CLASS(wxDataInputStream); | |
95 | }; | |
96 | ||
97 | class WXDLLIMPEXP_BASE wxDataOutputStream | |
98 | { | |
99 | public: | |
100 | #if wxUSE_UNICODE | |
101 | wxDataOutputStream(wxOutputStream& s, const wxMBConv& conv = wxConvUTF8 ); | |
102 | #else | |
103 | wxDataOutputStream(wxOutputStream& s); | |
104 | #endif | |
105 | ~wxDataOutputStream(); | |
106 | ||
107 | bool IsOk() { return m_output->IsOk(); } | |
108 | ||
109 | #if wxHAS_INT64 | |
110 | void Write64(wxUint64 i); | |
111 | void Write64(wxInt64 i); | |
112 | #endif | |
113 | #if wxUSE_LONGLONG | |
114 | void WriteLL(const wxLongLong &ll); | |
115 | void WriteLL(const wxULongLong &ll); | |
116 | #endif | |
117 | void Write32(wxUint32 i); | |
118 | void Write16(wxUint16 i); | |
119 | void Write8(wxUint8 i); | |
120 | void WriteDouble(double d); | |
121 | void WriteString(const wxString& string); | |
122 | ||
123 | #if wxHAS_INT64 | |
124 | void Write64(const wxUint64 *buffer, size_t size); | |
125 | void Write64(const wxInt64 *buffer, size_t size); | |
126 | #endif | |
127 | #if defined(wxLongLong_t) && wxUSE_LONGLONG | |
128 | void Write64(const wxULongLong *buffer, size_t size); | |
129 | void Write64(const wxLongLong *buffer, size_t size); | |
130 | #endif | |
131 | #if wxUSE_LONGLONG | |
132 | void WriteLL(const wxULongLong *buffer, size_t size); | |
133 | void WriteLL(const wxLongLong *buffer, size_t size); | |
134 | #endif | |
135 | void Write32(const wxUint32 *buffer, size_t size); | |
136 | void Write16(const wxUint16 *buffer, size_t size); | |
137 | void Write8(const wxUint8 *buffer, size_t size); | |
138 | void WriteDouble(const double *buffer, size_t size); | |
139 | ||
140 | wxDataOutputStream& operator<<(const wxString& string); | |
141 | wxDataOutputStream& operator<<(wxInt8 c); | |
142 | wxDataOutputStream& operator<<(wxInt16 i); | |
143 | wxDataOutputStream& operator<<(wxInt32 i); | |
144 | wxDataOutputStream& operator<<(wxUint8 c); | |
145 | wxDataOutputStream& operator<<(wxUint16 i); | |
146 | wxDataOutputStream& operator<<(wxUint32 i); | |
147 | #if wxHAS_INT64 | |
148 | wxDataOutputStream& operator<<(wxUint64 i); | |
149 | wxDataOutputStream& operator<<(wxInt64 i); | |
150 | #endif | |
151 | #if defined(wxLongLong_t) && wxUSE_LONGLONG | |
152 | wxDataOutputStream& operator<<(const wxULongLong &i); | |
153 | wxDataOutputStream& operator<<(const wxLongLong &i); | |
154 | #endif | |
155 | wxDataOutputStream& operator<<(double f); | |
156 | wxDataOutputStream& operator<<(float f); | |
157 | ||
158 | void BigEndianOrdered(bool be_order) { m_be_order = be_order; } | |
159 | ||
160 | #if wxUSE_UNICODE | |
161 | void SetConv( const wxMBConv &conv ); | |
162 | wxMBConv *GetConv() const { return m_conv; } | |
163 | #endif | |
164 | ||
165 | protected: | |
166 | wxOutputStream *m_output; | |
167 | bool m_be_order; | |
168 | #if wxUSE_UNICODE | |
169 | wxMBConv *m_conv; | |
170 | #endif | |
171 | ||
172 | wxDECLARE_NO_COPY_CLASS(wxDataOutputStream); | |
173 | }; | |
174 | ||
175 | #endif | |
176 | // wxUSE_STREAMS | |
177 | ||
178 | #endif | |
179 | // _WX_DATSTREAM_H_ |