]> git.saurik.com Git - wxWidgets.git/blob - include/wx/datstrm.h
190ff341aa055ae83bda4b20d1846debe688864d
[wxWidgets.git] / include / wx / datstrm.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: 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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "datstrm.h"
17 #endif
18
19 #include "wx/stream.h"
20 #include "wx/longlong.h"
21 #include "wx/strconv.h"
22
23 #if wxUSE_STREAMS
24
25 class WXDLLIMPEXP_BASE wxDataInputStream
26 {
27 public:
28 #if wxUSE_UNICODE
29 wxDataInputStream(wxInputStream& s, wxMBConv& conv = wxConvUTF8);
30 #else
31 wxDataInputStream(wxInputStream& s);
32 #endif
33 ~wxDataInputStream(){}
34
35 bool IsOk() { return m_input->IsOk(); }
36
37 wxUint64 Read64();
38 wxUint32 Read32();
39 wxUint16 Read16();
40 wxUint8 Read8();
41 double ReadDouble();
42 wxString ReadString();
43
44 void Read64(wxUint64 *buffer, size_t size);
45 void Read32(wxUint32 *buffer, size_t size);
46 void Read16(wxUint16 *buffer, size_t size);
47 void Read8(wxUint8 *buffer, size_t size);
48 void ReadDouble(double *buffer, size_t size);
49
50 wxDataInputStream& operator>>(wxString& s);
51 wxDataInputStream& operator>>(wxInt8& c);
52 wxDataInputStream& operator>>(wxInt16& i);
53 wxDataInputStream& operator>>(wxInt32& i);
54 wxDataInputStream& operator>>(wxUint8& c);
55 wxDataInputStream& operator>>(wxUint16& i);
56 wxDataInputStream& operator>>(wxUint32& i);
57 wxDataInputStream& operator>>(wxUint64& i);
58 wxDataInputStream& operator>>(double& i);
59 wxDataInputStream& operator>>(float& f);
60
61 void BigEndianOrdered(bool be_order) { m_be_order = be_order; }
62
63 protected:
64 wxInputStream *m_input;
65 bool m_be_order;
66 #if wxUSE_UNICODE
67 wxMBConv& m_conv;
68 #endif
69
70 DECLARE_NO_COPY_CLASS(wxDataInputStream)
71 };
72
73 class WXDLLIMPEXP_BASE wxDataOutputStream
74 {
75 public:
76 #if wxUSE_UNICODE
77 wxDataOutputStream(wxOutputStream& s, wxMBConv& conv = wxConvUTF8);
78 #else
79 wxDataOutputStream(wxOutputStream& s);
80 #endif
81 ~wxDataOutputStream(){}
82
83 bool IsOk() { return m_output->IsOk(); }
84
85 void Write64(wxUint64 i);
86 void Write32(wxUint32 i);
87 void Write16(wxUint16 i);
88 void Write8(wxUint8 i);
89 void WriteDouble(double d);
90 void WriteString(const wxString& string);
91
92 void Write64(const wxUint64 *buffer, size_t size);
93 void Write32(const wxUint32 *buffer, size_t size);
94 void Write16(const wxUint16 *buffer, size_t size);
95 void Write8(const wxUint8 *buffer, size_t size);
96 void WriteDouble(const double *buffer, size_t size);
97
98 wxDataOutputStream& operator<<(const wxChar *string);
99 wxDataOutputStream& operator<<(const wxString& string);
100 wxDataOutputStream& operator<<(wxInt8 c);
101 wxDataOutputStream& operator<<(wxInt16 i);
102 wxDataOutputStream& operator<<(wxInt32 i);
103 wxDataOutputStream& operator<<(wxUint8 c);
104 wxDataOutputStream& operator<<(wxUint16 i);
105 wxDataOutputStream& operator<<(wxUint32 i);
106 wxDataOutputStream& operator<<(wxUint64 i);
107 wxDataOutputStream& operator<<(double f);
108 wxDataOutputStream& operator<<(float f);
109
110 void BigEndianOrdered(bool be_order) { m_be_order = be_order; }
111
112 protected:
113 wxOutputStream *m_output;
114 bool m_be_order;
115 #if wxUSE_UNICODE
116 wxMBConv& m_conv;
117 #endif
118
119 DECLARE_NO_COPY_CLASS(wxDataOutputStream)
120 };
121
122 #endif
123 // wxUSE_STREAMS
124
125 #endif
126 // _WX_DATSTREAM_H_