]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/txtstrm.tex
typo fix.
[wxWidgets.git] / docs / latex / wx / txtstrm.tex
1 % ----------------------------------------------------------------------------
2 % wxTextInputStream
3 % ----------------------------------------------------------------------------
4 \section{\class{wxTextInputStream}}\label{wxtextinputstream}
5
6 This class provides functions that read text datas using an input stream.
7 So, you can read {\it text} floats, integers.
8
9 The wxTextInputStream correctly reads text files (or streams) in DOS, Macintosh
10 and Unix formats and reports a single newline char as a line ending.
11
12 Operator >> is overloaded and you can use this class like a standard C++ iostream.
13 Note, however, that the arguments are the fixed size types wxUint32, wxInt32 etc
14 and on a typical 32-bit computer, none of these match to the "long" type (wxInt32
15 is defined as int on 32-bit architectures) so that you cannot use long. To avoid
16 problems (here and elsewhere), make use of wxInt32, wxUint32 and similar types.
17
18 For example:
19
20 \begin{verbatim}
21 wxFileInputStream input( "mytext.txt" );
22 wxTextInputStream text( input );
23 wxUint8 i1;
24 float f2;
25 wxString line;
26
27 text >> i1; // read a 8 bit integer.
28 text >> i1 >> f2; // read a 8 bit integer followed by float.
29 text >> line; // read a text line
30 \end{verbatim}
31
32 \wxheading{Include files}
33
34 <wx/txtstrm.h>
35
36 \latexignore{\rtfignore{\wxheading{Members}}}
37
38 \membersection{wxTextInputStream::wxTextInputStream}\label{wxtextinputstreamconstr}
39
40 \func{}{wxTextInputStream}{\param{wxInputStream\&}{ stream}}
41
42 Constructs a text stream object from an input stream. Only read methods will
43 be available.
44
45 \wxheading{Parameters}
46
47 \docparam{stream}{The input stream.}
48
49 \membersection{wxTextInputStream::\destruct{wxTextInputStream}}
50
51 \func{}{\destruct{wxTextInputStream}}{\void}
52
53 Destroys the wxTextInputStream object.
54
55 \membersection{wxTextInputStream::Read8}
56
57 \func{wxUint8}{Read8}{\void}
58
59 Reads a single byte from the stream.
60
61 \membersection{wxTextInputStream::Read16}
62
63 \func{wxUint16}{Read16}{\void}
64
65 Reads a 16 bit integer from the stream.
66
67 \membersection{wxTextInputStream::Read32}
68
69 \func{wxUint16}{Read32}{\void}
70
71 Reads a 32 bit integer from the stream.
72
73 \membersection{wxTextInputStream::ReadDouble}
74
75 \func{double}{ReadDouble}{\void}
76
77 Reads a double (IEEE encoded) from the stream.
78
79 \membersection{wxTextInputStream::ReadLine}\label{wxtextinputstreamreadline}
80
81 \func{wxString}{wxTextInputStream::ReadLine}{\void}
82
83 Reads a line from the input stream and returns it (without the end of line
84 character).
85
86 \membersection{wxTextInputStream::ReadString}
87
88 \func{wxString}{wxTextInputStream::ReadString}{\void}
89
90 {\bf NB:} This method is deprecated, use \helpref{ReadLine}{wxtextinputstreamreadline}
91 or \helpref{ReadWord}{wxtextinputstreamreadword} instead.
92
93 Same as \helpref{ReadLine}{wxtextinputstreamreadline}.
94
95 \membersection{wxTextInputStream::ReadWord}\label{wxtextinputstreamreadword}
96
97 \func{wxString}{wxTextInputStream::ReadWord}{\void}
98
99 Reads a word (a sequence of characters until the next separator) from the
100 input stream.
101
102 \wxheading{See also}
103
104 \helpref{SetStringSeparators}{wxtextinputstreamsetstringseparators}
105
106 \membersection{wxTextInputStream::SetStringSeparators}\label{wxtextinputstreamsetstringseparators}
107
108 \func{void}{SetStringSeparators}{\param{const wxString\& }{sep}}
109
110 Sets the characters which are used to define the word boundaries in
111 \helpref{ReadWord}{wxtextinputstreamreadword}.
112
113 The default separators are the space and {\tt TAB} characters.
114
115 % ----------------------------------------------------------------------------
116 % wxTextOutputStream
117 % ----------------------------------------------------------------------------
118
119 \section{\class{wxTextOutputStream}}\label{wxtextoutputstream}
120
121 This class provides functions that write text datas using an output stream.
122 So, you can write {\it text} floats, integers.
123
124 You can also simulate the C++ cout class:
125
126 \begin{verbatim}
127 wxFFileOutputStream output( stderr );
128 wxTextOutputStream cout( output );
129
130 cout << "This is a text line" << endl;
131 cout << 1234;
132 cout << 1.23456;
133 \end{verbatim}
134
135 The wxTextOutputStream writes text files (or streams) on DOS, Macintosh
136 and Unix in their native formats (concerning the line ending).
137
138 \latexignore{\rtfignore{\wxheading{Members}}}
139
140 \membersection{wxTextOutputStream::wxTextOutputStream}\label{wxtextoutputstreamconstr}
141
142 \func{}{wxTextOutputStream}{\param{wxOutputStream\&}{ stream}, \param{wxEOL}{ mode = wxEOL\_NATIVE}}
143
144 Constructs a text stream object from an output stream. Only write methods will
145 be available.
146
147 \wxheading{Parameters}
148
149 \docparam{stream}{The output stream.}
150
151 \docparam{mode}{The end-of-line mode. One of {\bf wxEOL\_NATIVE}, {\bf wxEOL\_DOS}, {\bf wxEOL\_MAC} and {\bf wxEOL\_UNIX}.}
152
153 \membersection{wxTextOutputStream::\destruct{wxTextOutputStream}}
154
155 \func{}{\destruct{wxTextOutputStream}}{\void}
156
157 Destroys the wxTextOutputStream object.
158
159 \membersection{wxTextOutputStream::GetMode}
160
161 \func{wxEOL}{wxTextOutputStream::GetMode}{\void}
162
163 Returns the end-of-line mode. One of {\bf wxEOL\_DOS}, {\bf wxEOL\_MAC} and {\bf wxEOL\_UNIX}.
164
165 \membersection{wxTextOutputStream::SetMode}
166
167 \func{void}{wxTextOutputStream::SetMode}{{\param wxEOL}{ mode = wxEOL\_NATIVE}}
168
169 Set the end-of-line mode. One of {\bf wxEOL\_NATIVE}, {\bf wxEOL\_DOS}, {\bf wxEOL\_MAC} and {\bf wxEOL\_UNIX}.
170
171 \membersection{wxTextOutputStream::Write8}
172
173 \func{void}{wxTextOutputStream::Write8}{{\param wxUint8 }{i8}}
174
175 Writes the single byte {\it i8} to the stream.
176
177 \membersection{wxTextOutputStream::Write16}
178
179 \func{void}{wxTextOutputStream::Write16}{{\param wxUint16 }{i16}}
180
181 Writes the 16 bit integer {\it i16} to the stream.
182
183 \membersection{wxTextOutputStream::Write32}
184
185 \func{void}{wxTextOutputStream::Write32}{{\param wxUint32 }{i32}}
186
187 Writes the 32 bit integer {\it i32} to the stream.
188
189 \membersection{wxTextOutputStream::WriteDouble}
190
191 \func{virtual void}{wxTextOutputStream::WriteDouble}{{\param double }{f}}
192
193 Writes the double {\it f} to the stream using the IEEE format.
194
195 \membersection{wxTextOutputStream::WriteString}
196
197 \func{virtual void}{wxTextOutputStream::WriteString}{{\param const wxString\& }{string}}
198
199 Writes {\it string} as a line. Depending on the end-of-line mode, it adds
200 $\backslash$n, $\backslash$r or $\backslash$r$\backslash$n.
201