]> git.saurik.com Git - wxWidgets.git/blob - include/wx/txtstrm.h
Generic dirctrl corrections
[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 license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_TXTSTREAM_H_
13 #define _WX_TXTSTREAM_H_
14
15 #ifdef __GNUG__
16 #pragma interface "txtstrm.h"
17 #endif
18
19 #include "wx/stream.h"
20
21 #if wxUSE_STREAMS
22
23 class WXDLLEXPORT wxTextInputStream;
24 class WXDLLEXPORT wxTextOutputStream;
25
26 typedef wxTextInputStream& (*__wxTextInputManip)(wxTextInputStream&);
27 typedef wxTextOutputStream& (*__wxTextOutputManip)(wxTextOutputStream&);
28
29 WXDLLEXPORT wxTextOutputStream &endl( wxTextOutputStream &stream );
30
31 class WXDLLEXPORT wxTextInputStream
32 {
33 public:
34 wxTextInputStream(wxInputStream& s, const wxString &sep=wxT(" \t") );
35 ~wxTextInputStream();
36
37 wxUint32 Read32();
38 wxUint16 Read16();
39 wxUint8 Read8();
40 double ReadDouble();
41 wxString ReadString(); // deprecated use ReadLine or ReadWord instead
42 wxString ReadLine();
43 wxString ReadWord();
44
45 wxString GetStringSeparators() const { return m_separators; }
46 void SetStringSeparators(const wxString &c) { m_separators = c; }
47
48 // Operators
49 wxTextInputStream& operator>>(wxString& word);
50 wxTextInputStream& operator>>(char& c);
51 wxTextInputStream& operator>>(wxInt16& i);
52 wxTextInputStream& operator>>(wxInt32& i);
53 wxTextInputStream& operator>>(wxUint16& i);
54 wxTextInputStream& operator>>(wxUint32& i);
55 wxTextInputStream& operator>>(double& i);
56 wxTextInputStream& operator>>(float& f);
57
58 wxTextInputStream& operator>>( __wxTextInputManip func) { return func(*this); }
59
60 protected:
61 wxInputStream &m_input;
62 wxString m_separators;
63
64 bool EatEOL(const wxChar &c);
65 wxChar NextNonSeparators();
66 void SkipIfEndOfLine( wxChar c );
67 };
68
69 typedef enum {
70 wxEOL_NATIVE,
71 wxEOL_UNIX,
72 wxEOL_MAC,
73 wxEOL_DOS
74 } wxEOL;
75
76 class WXDLLEXPORT wxTextOutputStream
77 {
78 public:
79 wxTextOutputStream( wxOutputStream& s, wxEOL mode = wxEOL_NATIVE );
80 virtual ~wxTextOutputStream();
81
82 void SetMode( wxEOL mode = wxEOL_NATIVE );
83 wxEOL GetMode() { return m_mode; }
84
85 void Write32(wxUint32 i);
86 void Write16(wxUint16 i);
87 void Write8(wxUint8 i);
88 virtual void WriteDouble(double d);
89 virtual void WriteString(const wxString& string);
90
91 wxTextOutputStream& operator<<(const wxChar *string);
92 wxTextOutputStream& operator<<(const wxString& string);
93 wxTextOutputStream& operator<<(char c);
94 wxTextOutputStream& operator<<(wxInt16 c);
95 wxTextOutputStream& operator<<(wxInt32 c);
96 wxTextOutputStream& operator<<(wxUint16 c);
97 wxTextOutputStream& operator<<(wxUint32 c);
98 wxTextOutputStream& operator<<(double f);
99 wxTextOutputStream& operator<<(float f);
100
101 wxTextOutputStream& operator<<( __wxTextOutputManip func) { return func(*this); }
102
103 protected:
104 wxOutputStream &m_output;
105 wxEOL m_mode;
106 };
107
108 #endif
109 // wxUSE_STREAMS
110
111 #endif
112 // _WX_DATSTREAM_H_