]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: txtstrm.h | |
3 | // Purpose: Text stream classes | |
4 | // Author: Guilhem Lavaux | |
5 | // Modified by: | |
6 | // Created: 28/06/1998 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Guilhem Lavaux | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_TXTSTREAM_H_ | |
13 | #define _WX_TXTSTREAM_H_ | |
14 | ||
15 | #if defined(__GNUG__) && !defined(__APPLE__) | |
16 | #pragma interface "txtstrm.h" | |
17 | #endif | |
18 | ||
19 | #include "wx/stream.h" | |
20 | ||
21 | #if wxUSE_STREAMS | |
22 | ||
23 | class WXDLLIMPEXP_BASE wxTextInputStream; | |
24 | class WXDLLIMPEXP_BASE wxTextOutputStream; | |
25 | ||
26 | typedef wxTextInputStream& (*__wxTextInputManip)(wxTextInputStream&); | |
27 | typedef wxTextOutputStream& (*__wxTextOutputManip)(wxTextOutputStream&); | |
28 | ||
29 | WXDLLIMPEXP_BASE wxTextOutputStream &endl( wxTextOutputStream &stream ); | |
30 | ||
31 | ||
32 | class WXDLLIMPEXP_BASE wxTextInputStream | |
33 | { | |
34 | public: | |
35 | #if wxUSE_UNICODE | |
36 | wxTextInputStream(wxInputStream& s, const wxString &sep=wxT(" \t"), wxMBConv& conv = wxConvUTF8 ); | |
37 | #else | |
38 | wxTextInputStream(wxInputStream& s, const wxString &sep=wxT(" \t") ); | |
39 | #endif | |
40 | ~wxTextInputStream(); | |
41 | ||
42 | wxUint32 Read32(); | |
43 | wxUint16 Read16(); | |
44 | wxUint8 Read8(); | |
45 | double ReadDouble(); | |
46 | wxString ReadString(); // deprecated use ReadLine or ReadWord instead | |
47 | wxString ReadLine(); | |
48 | wxString ReadWord(); | |
49 | ||
50 | wxString GetStringSeparators() const { return m_separators; } | |
51 | void SetStringSeparators(const wxString &c) { m_separators = c; } | |
52 | ||
53 | // Operators | |
54 | wxTextInputStream& operator>>(wxString& word); | |
55 | wxTextInputStream& operator>>(char& c); | |
56 | wxTextInputStream& operator>>(wxInt16& i); | |
57 | wxTextInputStream& operator>>(wxInt32& i); | |
58 | wxTextInputStream& operator>>(wxUint16& i); | |
59 | wxTextInputStream& operator>>(wxUint32& i); | |
60 | wxTextInputStream& operator>>(double& i); | |
61 | wxTextInputStream& operator>>(float& f); | |
62 | ||
63 | wxTextInputStream& operator>>( __wxTextInputManip func) { return func(*this); } | |
64 | ||
65 | protected: | |
66 | wxInputStream &m_input; | |
67 | wxString m_separators; | |
68 | ||
69 | #if wxUSE_UNICODE | |
70 | wxMBConv &m_conv; | |
71 | #endif | |
72 | ||
73 | bool EatEOL(const wxChar &c); | |
74 | wxChar NextNonSeparators(); | |
75 | void SkipIfEndOfLine( wxChar c ); | |
76 | }; | |
77 | ||
78 | typedef enum | |
79 | { | |
80 | wxEOL_NATIVE, | |
81 | wxEOL_UNIX, | |
82 | wxEOL_MAC, | |
83 | wxEOL_DOS | |
84 | } wxEOL; | |
85 | ||
86 | class WXDLLIMPEXP_BASE wxTextOutputStream | |
87 | { | |
88 | public: | |
89 | #if wxUSE_UNICODE | |
90 | wxTextOutputStream( wxOutputStream& s, wxEOL mode = wxEOL_NATIVE, wxMBConv& conv = wxConvUTF8 ); | |
91 | #else | |
92 | wxTextOutputStream( wxOutputStream& s, wxEOL mode = wxEOL_NATIVE ); | |
93 | #endif | |
94 | virtual ~wxTextOutputStream(); | |
95 | ||
96 | void SetMode( wxEOL mode = wxEOL_NATIVE ); | |
97 | wxEOL GetMode() { return m_mode; } | |
98 | ||
99 | void Write32(wxUint32 i); | |
100 | void Write16(wxUint16 i); | |
101 | void Write8(wxUint8 i); | |
102 | virtual void WriteDouble(double d); | |
103 | virtual void WriteString(const wxString& string); | |
104 | ||
105 | wxTextOutputStream& operator<<(const wxChar *string); | |
106 | wxTextOutputStream& operator<<(const wxString& string); | |
107 | wxTextOutputStream& operator<<(char c); | |
108 | wxTextOutputStream& operator<<(wxInt16 c); | |
109 | wxTextOutputStream& operator<<(wxInt32 c); | |
110 | wxTextOutputStream& operator<<(wxUint16 c); | |
111 | wxTextOutputStream& operator<<(wxUint32 c); | |
112 | wxTextOutputStream& operator<<(double f); | |
113 | wxTextOutputStream& operator<<(float f); | |
114 | ||
115 | wxTextOutputStream& operator<<( __wxTextOutputManip func) { return func(*this); } | |
116 | ||
117 | protected: | |
118 | wxOutputStream &m_output; | |
119 | wxEOL m_mode; | |
120 | ||
121 | #if wxUSE_UNICODE | |
122 | wxMBConv &m_conv; | |
123 | #endif | |
124 | ||
125 | }; | |
126 | ||
127 | #endif | |
128 | // wxUSE_STREAMS | |
129 | ||
130 | #endif | |
131 | // _WX_DATSTREAM_H_ |