]> git.saurik.com Git - wxWidgets.git/blob - include/wx/txtstrm.h
Added minimal file dialog for SmartPhone
[wxWidgets.git] / include / wx / txtstrm.h
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 #define wxEOT wxT('\4') // the End-Of-Text control code (used only inside wxTextInputStream)
33
34 // If you're scanning through a file using wxTextInputStream, you should check for EOF _before_
35 // reading the next item (word / number), because otherwise the last item may get lost.
36 // You should however be prepared to receive an empty item (empty string / zero number) at the
37 // end of file, especially on Windows systems. This is unavoidable because most (but not all) files end
38 // with whitespace (i.e. usually a newline).
39 class WXDLLIMPEXP_BASE wxTextInputStream
40 {
41 public:
42 #if wxUSE_UNICODE
43 wxTextInputStream(wxInputStream& s, const wxString &sep=wxT(" \t"), wxMBConv& conv = wxConvUTF8 );
44 #else
45 wxTextInputStream(wxInputStream& s, const wxString &sep=wxT(" \t") );
46 #endif
47 ~wxTextInputStream();
48
49 wxUint32 Read32(int base = 10); // base may be between 2 and 36, inclusive, or the special 0 (= C format)
50 wxUint16 Read16(int base = 10);
51 wxUint8 Read8(int base = 10);
52 wxInt32 Read32S(int base = 10);
53 wxInt16 Read16S(int base = 10);
54 wxInt8 Read8S(int base = 10);
55 double ReadDouble();
56 wxString ReadString(); // deprecated: use ReadLine or ReadWord instead
57 wxString ReadLine();
58 wxString ReadWord();
59
60 wxString GetStringSeparators() const { return m_separators; }
61 void SetStringSeparators(const wxString &c) { m_separators = c; }
62
63 // Operators
64 wxTextInputStream& operator>>(wxString& word);
65 wxTextInputStream& operator>>(char& c);
66 wxTextInputStream& operator>>(wxInt16& i);
67 wxTextInputStream& operator>>(wxInt32& i);
68 wxTextInputStream& operator>>(wxUint16& i);
69 wxTextInputStream& operator>>(wxUint32& i);
70 wxTextInputStream& operator>>(double& i);
71 wxTextInputStream& operator>>(float& f);
72
73 wxTextInputStream& operator>>( __wxTextInputManip func) { return func(*this); }
74
75 protected:
76 wxInputStream &m_input;
77 wxString m_separators;
78 char m_lastBytes[10]; // stores the bytes that were read for the last character
79
80 #if wxUSE_UNICODE
81 wxMBConv &m_conv;
82 #endif
83
84 bool EatEOL(const wxChar &c);
85 void UngetLast(); // should be used instead of wxInputStream::Ungetch() because of Unicode issues
86 // returns EOT (\4) if there is a stream error, or end of file
87 wxChar NextChar(); // this should be used instead of GetC() because of Unicode issues
88 wxChar NextNonSeparators();
89 };
90
91 typedef enum
92 {
93 wxEOL_NATIVE,
94 wxEOL_UNIX,
95 wxEOL_MAC,
96 wxEOL_DOS
97 } wxEOL;
98
99 class WXDLLIMPEXP_BASE wxTextOutputStream
100 {
101 public:
102 #if wxUSE_UNICODE
103 wxTextOutputStream( wxOutputStream& s, wxEOL mode = wxEOL_NATIVE, wxMBConv& conv = wxConvUTF8 );
104 #else
105 wxTextOutputStream( wxOutputStream& s, wxEOL mode = wxEOL_NATIVE );
106 #endif
107 virtual ~wxTextOutputStream();
108
109 void SetMode( wxEOL mode = wxEOL_NATIVE );
110 wxEOL GetMode() { return m_mode; }
111
112 void Write32(wxUint32 i);
113 void Write16(wxUint16 i);
114 void Write8(wxUint8 i);
115 virtual void WriteDouble(double d);
116 virtual void WriteString(const wxString& string);
117
118 wxTextOutputStream& operator<<(const wxChar *string);
119 wxTextOutputStream& operator<<(const wxString& string);
120 wxTextOutputStream& operator<<(char c);
121 wxTextOutputStream& operator<<(wxInt16 c);
122 wxTextOutputStream& operator<<(wxInt32 c);
123 wxTextOutputStream& operator<<(wxUint16 c);
124 wxTextOutputStream& operator<<(wxUint32 c);
125 wxTextOutputStream& operator<<(double f);
126 wxTextOutputStream& operator<<(float f);
127
128 wxTextOutputStream& operator<<( __wxTextOutputManip func) { return func(*this); }
129
130 protected:
131 wxOutputStream &m_output;
132 wxEOL m_mode;
133
134 #if wxUSE_UNICODE
135 wxMBConv &m_conv;
136 #endif
137
138 };
139
140 #endif
141 // wxUSE_STREAMS
142
143 #endif
144 // _WX_DATSTREAM_H_