]>
Commit | Line | Data |
---|---|---|
a3c1786d GL |
1 | % ---------------------------------------------------------------------------- |
2 | % wxTextInputStream | |
3 | % ---------------------------------------------------------------------------- | |
4 | \section{\class{wxTextInputStream}}\label{wxtextinputstream} | |
5 | ||
6 | This class provides functions that read text datas using an input stream. | |
605d715d | 7 | So, you can read {\it text} floats, integers. |
a3c1786d | 8 | |
7ff14117 RR |
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 | ||
b453e1b2 RR |
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 | |
b2cf617c | 16 | problems (here and elsewhere), make use of wxInt32, wxUint32 and similar types. |
a3c1786d GL |
17 | |
18 | For example: | |
b2cf617c | 19 | |
a3c1786d | 20 | \begin{verbatim} |
b453e1b2 | 21 | wxFileInputStream input( "mytext.txt" ); |
a3c1786d GL |
22 | wxTextInputStream text( input ); |
23 | wxUint8 i1; | |
24 | float f2; | |
25 | wxString line; | |
26 | ||
27 | text >> i1; // read a 8 bit integer. | |
3660fc40 | 28 | text >> i1 >> f2; // read a 8 bit integer followed by float. |
a3c1786d GL |
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 | ||
b453e1b2 | 57 | \func{wxUint8}{Read8}{\void} |
a3c1786d GL |
58 | |
59 | Reads a single byte from the stream. | |
60 | ||
61 | \membersection{wxTextInputStream::Read16} | |
62 | ||
b453e1b2 | 63 | \func{wxUint16}{Read16}{\void} |
a3c1786d GL |
64 | |
65 | Reads a 16 bit integer from the stream. | |
66 | ||
67 | \membersection{wxTextInputStream::Read32} | |
68 | ||
b453e1b2 | 69 | \func{wxUint16}{Read32}{\void} |
a3c1786d GL |
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::ReadString} | |
80 | ||
81 | \func{wxString}{wxTextInputStream::ReadString}{\void} | |
82 | ||
b2cf617c | 83 | Reads a line from the stream. A line is a string which ends with |
3660fc40 | 84 | $\backslash$n or $\backslash$r$\backslash$n or $\backslash$r. |
a3c1786d GL |
85 | |
86 | % ---------------------------------------------------------------------------- | |
87 | % wxTextOutputStream | |
88 | % ---------------------------------------------------------------------------- | |
89 | ||
90 | \section{\class{wxTextOutputStream}}\label{wxtextoutputstream} | |
91 | ||
92 | This class provides functions that write text datas using an output stream. | |
28c9c76e | 93 | So, you can write {\it text} floats, integers. |
a3c1786d | 94 | |
65045edd | 95 | You can also simulate the C++ cout class: |
b2cf617c | 96 | |
a3c1786d | 97 | \begin{verbatim} |
65045edd RR |
98 | wxFFileOutputStream output( stderr ); |
99 | wxTextOutputStream cout( output ); | |
a3c1786d | 100 | |
65045edd RR |
101 | cout << "This is a text line" << endl; |
102 | cout << 1234; | |
103 | cout << 1.23456; | |
a3c1786d | 104 | \end{verbatim} |
3660fc40 | 105 | |
7ff14117 RR |
106 | The wxTextOutputStream writes text files (or streams) on DOS, Macintosh |
107 | and Unix in their native formats (concerning the line ending). | |
108 | ||
a3c1786d GL |
109 | \latexignore{\rtfignore{\wxheading{Members}}} |
110 | ||
d7cb14ce | 111 | \membersection{wxTextOutputStream::wxTextOutputStream}\label{wxtextoutputstreamconstr} |
a3c1786d | 112 | |
605d715d | 113 | \func{}{wxTextOutputStream}{\param{wxOutputStream\&}{ stream}, \param{wxEOL}{ mode = wxEOL\_NATIVE}} |
a3c1786d GL |
114 | |
115 | Constructs a text stream object from an output stream. Only write methods will | |
116 | be available. | |
117 | ||
118 | \wxheading{Parameters} | |
119 | ||
120 | \docparam{stream}{The output stream.} | |
121 | ||
b2cf617c | 122 | \docparam{mode}{The end-of-line mode. One of {\bf wxEOL\_NATIVE}, {\bf wxEOL\_DOS}, {\bf wxEOL\_MAC} and {\bf wxEOL\_UNIX}.} |
28c9c76e | 123 | |
a3c1786d GL |
124 | \membersection{wxTextOutputStream::\destruct{wxTextOutputStream}} |
125 | ||
126 | \func{}{\destruct{wxTextOutputStream}}{\void} | |
127 | ||
128 | Destroys the wxTextOutputStream object. | |
129 | ||
28c9c76e RR |
130 | \membersection{wxTextOutputStream::GetMode} |
131 | ||
132 | \func{wxEOL}{wxTextOutputStream::GetMode}{\void} | |
133 | ||
b2cf617c | 134 | Returns the end-of-line mode. One of {\bf wxEOL\_DOS}, {\bf wxEOL\_MAC} and {\bf wxEOL\_UNIX}. |
28c9c76e RR |
135 | |
136 | \membersection{wxTextOutputStream::SetMode} | |
137 | ||
605d715d | 138 | \func{void}{wxTextOutputStream::SetMode}{{\param wxEOL}{ mode = wxEOL\_NATIVE}} |
28c9c76e | 139 | |
b2cf617c | 140 | Set the end-of-line mode. One of {\bf wxEOL\_NATIVE}, {\bf wxEOL\_DOS}, {\bf wxEOL\_MAC} and {\bf wxEOL\_UNIX}. |
28c9c76e | 141 | |
a3c1786d GL |
142 | \membersection{wxTextOutputStream::Write8} |
143 | ||
b453e1b2 | 144 | \func{void}{wxTextOutputStream::Write8}{{\param wxUint8 }{i8}} |
a3c1786d GL |
145 | |
146 | Writes the single byte {\it i8} to the stream. | |
147 | ||
148 | \membersection{wxTextOutputStream::Write16} | |
149 | ||
b453e1b2 | 150 | \func{void}{wxTextOutputStream::Write16}{{\param wxUint16 }{i16}} |
a3c1786d GL |
151 | |
152 | Writes the 16 bit integer {\it i16} to the stream. | |
153 | ||
154 | \membersection{wxTextOutputStream::Write32} | |
155 | ||
b453e1b2 | 156 | \func{void}{wxTextOutputStream::Write32}{{\param wxUint32 }{i32}} |
a3c1786d GL |
157 | |
158 | Writes the 32 bit integer {\it i32} to the stream. | |
159 | ||
160 | \membersection{wxTextOutputStream::WriteDouble} | |
161 | ||
28c9c76e | 162 | \func{virtual void}{wxTextOutputStream::WriteDouble}{{\param double }{f}} |
a3c1786d GL |
163 | |
164 | Writes the double {\it f} to the stream using the IEEE format. | |
165 | ||
166 | \membersection{wxTextOutputStream::WriteString} | |
167 | ||
28c9c76e | 168 | \func{virtual void}{wxTextOutputStream::WriteString}{{\param const wxString\& }{string}} |
a3c1786d | 169 | |
b2cf617c | 170 | Writes {\it string} as a line. Depending on the end-of-line mode, it adds |
28c9c76e | 171 | $\backslash$n, $\backslash$r or $\backslash$r$\backslash$n. |
22d6efa8 | 172 |