source: trunk/doc/html/qtextstream.html

Last change on this file was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 40.2 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/tools/qtextstream.cpp:56 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QTextStream Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QTextStream Class Reference</h1>
33
34<p>The QTextStream class provides basic functions for reading
35and writing text using a QIODevice.
36<a href="#details">More...</a>
37<p>All the functions in this class are <a href="threads.html#reentrant">reentrant</a> when Qt is built with thread support.</p>
38<p><tt>#include &lt;<a href="qtextstream-h.html">qtextstream.h</a>&gt;</tt>
39<p>Inherited by <a href="qtextistream.html">QTextIStream</a> and <a href="qtextostream.html">QTextOStream</a>.
40<p><a href="qtextstream-members.html">List of all member functions.</a>
41<h2>Public Members</h2>
42<ul>
43<li class=fn>enum <a href="#Encoding-enum"><b>Encoding</b></a> { Locale, Latin1, Unicode, UnicodeNetworkOrder, UnicodeReverse, RawUnicode, UnicodeUTF8 }</li>
44<li class=fn>void <a href="#setEncoding"><b>setEncoding</b></a> ( Encoding&nbsp;e )</li>
45<li class=fn>void <a href="#setCodec"><b>setCodec</b></a> ( QTextCodec&nbsp;*&nbsp;codec )</li>
46<li class=fn>QTextCodec * <a href="#codec"><b>codec</b></a> ()</li>
47<li class=fn><a href="#QTextStream"><b>QTextStream</b></a> ()</li>
48<li class=fn><a href="#QTextStream-2"><b>QTextStream</b></a> ( QIODevice&nbsp;*&nbsp;iod )</li>
49<li class=fn><a href="#QTextStream-3"><b>QTextStream</b></a> ( QString&nbsp;*&nbsp;str, int&nbsp;filemode )</li>
50<li class=fn>QTextStream ( QString&nbsp;&amp;&nbsp;str, int&nbsp;filemode ) &nbsp;<em>(obsolete)</em></li>
51<li class=fn><a href="#QTextStream-5"><b>QTextStream</b></a> ( QByteArray&nbsp;a, int&nbsp;mode )</li>
52<li class=fn><a href="#QTextStream-6"><b>QTextStream</b></a> ( FILE&nbsp;*&nbsp;fh, int&nbsp;mode )</li>
53<li class=fn>virtual <a href="#~QTextStream"><b>~QTextStream</b></a> ()</li>
54<li class=fn>QIODevice * <a href="#device"><b>device</b></a> () const</li>
55<li class=fn>void <a href="#setDevice"><b>setDevice</b></a> ( QIODevice&nbsp;*&nbsp;iod )</li>
56<li class=fn>void <a href="#unsetDevice"><b>unsetDevice</b></a> ()</li>
57<li class=fn>bool <a href="#atEnd"><b>atEnd</b></a> () const</li>
58<li class=fn>bool eof () const &nbsp;<em>(obsolete)</em></li>
59<li class=fn>QTextStream &amp; <a href="#operator-gt-gt"><b>operator&gt;&gt;</b></a> ( QChar&nbsp;&amp;&nbsp;c )</li>
60<li class=fn>QTextStream &amp; <a href="#operator-gt-gt-2"><b>operator&gt;&gt;</b></a> ( char&nbsp;&amp;&nbsp;c )</li>
61<li class=fn>QTextStream &amp; <a href="#operator-gt-gt-3"><b>operator&gt;&gt;</b></a> ( signed&nbsp;short&nbsp;&amp;&nbsp;i )</li>
62<li class=fn>QTextStream &amp; <a href="#operator-gt-gt-4"><b>operator&gt;&gt;</b></a> ( unsigned&nbsp;short&nbsp;&amp;&nbsp;i )</li>
63<li class=fn>QTextStream &amp; <a href="#operator-gt-gt-5"><b>operator&gt;&gt;</b></a> ( signed&nbsp;int&nbsp;&amp;&nbsp;i )</li>
64<li class=fn>QTextStream &amp; <a href="#operator-gt-gt-6"><b>operator&gt;&gt;</b></a> ( unsigned&nbsp;int&nbsp;&amp;&nbsp;i )</li>
65<li class=fn>QTextStream &amp; <a href="#operator-gt-gt-7"><b>operator&gt;&gt;</b></a> ( signed&nbsp;long&nbsp;&amp;&nbsp;i )</li>
66<li class=fn>QTextStream &amp; <a href="#operator-gt-gt-8"><b>operator&gt;&gt;</b></a> ( unsigned&nbsp;long&nbsp;&amp;&nbsp;i )</li>
67<li class=fn>QTextStream &amp; <a href="#operator-gt-gt-9"><b>operator&gt;&gt;</b></a> ( float&nbsp;&amp;&nbsp;f )</li>
68<li class=fn>QTextStream &amp; <a href="#operator-gt-gt-a"><b>operator&gt;&gt;</b></a> ( double&nbsp;&amp;&nbsp;f )</li>
69<li class=fn>QTextStream &amp; <a href="#operator-gt-gt-b"><b>operator&gt;&gt;</b></a> ( char&nbsp;*&nbsp;s )</li>
70<li class=fn>QTextStream &amp; <a href="#operator-gt-gt-c"><b>operator&gt;&gt;</b></a> ( QString&nbsp;&amp;&nbsp;str )</li>
71<li class=fn>QTextStream &amp; <a href="#operator-gt-gt-d"><b>operator&gt;&gt;</b></a> ( QCString&nbsp;&amp;&nbsp;str )</li>
72<li class=fn>QTextStream &amp; <a href="#operator-lt-lt"><b>operator&lt;&lt;</b></a> ( QChar&nbsp;c )</li>
73<li class=fn>QTextStream &amp; <a href="#operator-lt-lt-2"><b>operator&lt;&lt;</b></a> ( char&nbsp;c )</li>
74<li class=fn>QTextStream &amp; <a href="#operator-lt-lt-3"><b>operator&lt;&lt;</b></a> ( signed&nbsp;short&nbsp;i )</li>
75<li class=fn>QTextStream &amp; <a href="#operator-lt-lt-4"><b>operator&lt;&lt;</b></a> ( unsigned&nbsp;short&nbsp;i )</li>
76<li class=fn>QTextStream &amp; <a href="#operator-lt-lt-5"><b>operator&lt;&lt;</b></a> ( signed&nbsp;int&nbsp;i )</li>
77<li class=fn>QTextStream &amp; <a href="#operator-lt-lt-6"><b>operator&lt;&lt;</b></a> ( unsigned&nbsp;int&nbsp;i )</li>
78<li class=fn>QTextStream &amp; <a href="#operator-lt-lt-7"><b>operator&lt;&lt;</b></a> ( signed&nbsp;long&nbsp;i )</li>
79<li class=fn>QTextStream &amp; <a href="#operator-lt-lt-8"><b>operator&lt;&lt;</b></a> ( unsigned&nbsp;long&nbsp;i )</li>
80<li class=fn>QTextStream &amp; <a href="#operator-lt-lt-9"><b>operator&lt;&lt;</b></a> ( float&nbsp;f )</li>
81<li class=fn>QTextStream &amp; <a href="#operator-lt-lt-a"><b>operator&lt;&lt;</b></a> ( double&nbsp;f )</li>
82<li class=fn>QTextStream &amp; <a href="#operator-lt-lt-b"><b>operator&lt;&lt;</b></a> ( const&nbsp;char&nbsp;*&nbsp;s )</li>
83<li class=fn>QTextStream &amp; <a href="#operator-lt-lt-c"><b>operator&lt;&lt;</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;s )</li>
84<li class=fn>QTextStream &amp; <a href="#operator-lt-lt-d"><b>operator&lt;&lt;</b></a> ( const&nbsp;QCString&nbsp;&amp;&nbsp;s )</li>
85<li class=fn>QTextStream &amp; <a href="#operator-lt-lt-e"><b>operator&lt;&lt;</b></a> ( void&nbsp;*&nbsp;ptr )</li>
86<li class=fn>QTextStream &amp; <a href="#readRawBytes"><b>readRawBytes</b></a> ( char&nbsp;*&nbsp;s, uint&nbsp;len )</li>
87<li class=fn>QTextStream &amp; <a href="#writeRawBytes"><b>writeRawBytes</b></a> ( const&nbsp;char&nbsp;*&nbsp;s, uint&nbsp;len )</li>
88<li class=fn>QString <a href="#readLine"><b>readLine</b></a> ()</li>
89<li class=fn>QString <a href="#read"><b>read</b></a> ()</li>
90<li class=fn>void <a href="#skipWhiteSpace"><b>skipWhiteSpace</b></a> ()</li>
91<li class=fn>int <a href="#flags"><b>flags</b></a> () const</li>
92<li class=fn>int <a href="#flags-2"><b>flags</b></a> ( int&nbsp;f )</li>
93<li class=fn>int <a href="#setf"><b>setf</b></a> ( int&nbsp;bits )</li>
94<li class=fn>int <a href="#setf-2"><b>setf</b></a> ( int&nbsp;bits, int&nbsp;mask )</li>
95<li class=fn>int <a href="#unsetf"><b>unsetf</b></a> ( int&nbsp;bits )</li>
96<li class=fn>void <a href="#reset"><b>reset</b></a> ()</li>
97<li class=fn>int <a href="#width"><b>width</b></a> () const</li>
98<li class=fn>int <a href="#width-2"><b>width</b></a> ( int&nbsp;w )</li>
99<li class=fn>int <a href="#fill"><b>fill</b></a> () const</li>
100<li class=fn>int <a href="#fill-2"><b>fill</b></a> ( int&nbsp;f )</li>
101<li class=fn>int <a href="#precision"><b>precision</b></a> () const</li>
102<li class=fn>int <a href="#precision-2"><b>precision</b></a> ( int&nbsp;p )</li>
103</ul>
104<hr><a name="details"></a><h2>Detailed Description</h2>
105
106
107
108The QTextStream class provides basic functions for reading
109and writing text using a <a href="qiodevice.html">QIODevice</a>.
110<p>
111
112
113<p> The text stream class has a functional interface that is very
114similar to that of the standard C++ iostream class.
115<p> Qt provides several global functions similar to the ones in iostream:
116<center><table cellpadding="4" cellspacing="2" border="0">
117<tr bgcolor="#a2c511"> <th valign="top">Function <th valign="top">Meaning
118<tr bgcolor="#f0f0f0"> <td valign="top">bin <td valign="top">sets the QTextStream to read/write binary numbers
119<tr bgcolor="#d0d0d0"> <td valign="top">oct <td valign="top">sets the QTextStream to read/write octal numbers
120<tr bgcolor="#f0f0f0"> <td valign="top">dec <td valign="top">sets the QTextStream to read/write decimal numbers
121<tr bgcolor="#d0d0d0"> <td valign="top">hex <td valign="top">sets the QTextStream to read/write hexadecimal numbers
122<tr bgcolor="#f0f0f0"> <td valign="top">endl <td valign="top">forces a line break
123<tr bgcolor="#d0d0d0"> <td valign="top">flush <td valign="top">forces the QIODevice to flush any buffered data
124<tr bgcolor="#f0f0f0"> <td valign="top">ws <td valign="top">eats any available whitespace (on input)
125<tr bgcolor="#d0d0d0"> <td valign="top">reset <td valign="top">resets the QTextStream to its default mode (see <a href="#reset">reset</a>())
126<tr bgcolor="#f0f0f0"> <td valign="top">qSetW(int) <td valign="top">sets the <a href="#width">field width</a>
127to the given argument
128<tr bgcolor="#d0d0d0"> <td valign="top">qSetFill(int) <td valign="top">sets the <a href="#fill">fill character</a> to the given argument
129<tr bgcolor="#f0f0f0"> <td valign="top">qSetPrecision(int) <td valign="top">sets the <a href="#precision">precision</a> to the given argument
130</table></center>
131<p> <b>Warning:</b> By default QTextStream will automatically detect whether
132integers in the stream are in decimal, octal, hexadecimal or
133binary format when reading from the stream. In particular, a
134leading '0' signifies octal, i.e. the sequence "0100" will be
135interpreted as 64.
136<p> The QTextStream class reads and writes text; it is not appropriate
137for dealing with binary data (but <a href="qdatastream.html">QDataStream</a> is).
138<p> By default, output of Unicode text (i.e. <a href="qstring.html">QString</a>) is done using
139the local 8-bit encoding. This can be changed using the
140<a href="#setEncoding">setEncoding</a>() method. For input, the QTextStream will auto-detect
141standard Unicode "byte order marked" text files; otherwise the
142local 8-bit encoding is used.
143<p> The <a href="qiodevice.html">QIODevice</a> is set in the constructor, or later using
144<a href="#setDevice">setDevice</a>(). If the end of the input is reached <a href="#atEnd">atEnd</a>() returns
145TRUE. Data can be read into variables of the appropriate type
146using the <a href="#operator-gt-gt">operator&gt;&gt;</a>() overloads, or read in its entirety into a
147single string using <a href="#read">read</a>(), or read a line at a time using
148<a href="#readLine">readLine</a>(). Whitespace can be skipped over using <a href="#skipWhiteSpace">skipWhiteSpace</a>().
149You can set flags for the stream using <a href="#flags">flags</a>() or <a href="#setf">setf</a>(). The
150stream also supports <a href="#width">width</a>(), <a href="#precision">precision</a>() and <a href="#fill">fill</a>(); use <a href="#reset">reset</a>()
151to reset the defaults.
152<p> <p>See also <a href="qdatastream.html">QDataStream</a>, <a href="io.html">Input/Output and Networking</a>, and <a href="text.html">Text Related Classes</a>.
153
154<hr><h2>Member Type Documentation</h2>
155<h3 class=fn><a name="Encoding-enum"></a>QTextStream::Encoding</h3>
156
157<ul>
158<li><tt>QTextStream::Locale</tt>
159<li><tt>QTextStream::Latin1</tt>
160<li><tt>QTextStream::Unicode</tt>
161<li><tt>QTextStream::UnicodeNetworkOrder</tt>
162<li><tt>QTextStream::UnicodeReverse</tt>
163<li><tt>QTextStream::RawUnicode</tt>
164<li><tt>QTextStream::UnicodeUTF8</tt>
165</ul><p> See <a href="#setEncoding">setEncoding</a>() for an explanation of the encodings.
166
167<hr><h2>Member Function Documentation</h2>
168<h3 class=fn><a name="QTextStream"></a>QTextStream::QTextStream ()
169</h3>
170Constructs a data stream that has no IO device.
171
172<h3 class=fn><a name="QTextStream-2"></a>QTextStream::QTextStream ( <a href="qiodevice.html">QIODevice</a>&nbsp;*&nbsp;iod )
173</h3>
174Constructs a text stream that uses the IO device <em>iod</em>.
175
176<h3 class=fn><a name="QTextStream-3"></a>QTextStream::QTextStream ( <a href="qstring.html">QString</a>&nbsp;*&nbsp;str, int&nbsp;filemode )
177</h3>
178Constructs a text stream that operates on the Unicode <a href="qstring.html">QString</a>, <em>str</em>, through an internal device. The <em>filemode</em> argument is
179passed to the device's open() function; see <a href="qiodevice.html#mode">QIODevice::mode</a>().
180<p> If you set an encoding or codec with <a href="#setEncoding">setEncoding</a>() or <a href="#setCodec">setCodec</a>(),
181this setting is ignored for text streams that operate on QString.
182<p> Example:
183<pre>
184 <a href="qstring.html">QString</a> str;
185 QTextStream ts( &amp;str, <a href="qfile.html#open">IO_WriteOnly</a> );
186 ts &lt;&lt; "pi = " &lt;&lt; 3.14; // str == "pi = 3.14"
187 </pre>
188
189<p> Writing data to the text stream will modify the contents of the
190string. The string will be expanded when data is written beyond
191the end of the string. Note that the string will not be truncated:
192<pre>
193 <a href="qstring.html">QString</a> str = "pi = 3.14";
194 QTextStream ts( &amp;str, IO_WriteOnly );
195 ts &lt;&lt; "2+2 = " &lt;&lt; 2+2; // str == "2+2 = 414"
196 </pre>
197
198<p> Note that because QString is Unicode, you should not use
199<a href="#readRawBytes">readRawBytes</a>() or <a href="#writeRawBytes">writeRawBytes</a>() on such a stream.
200
201<h3 class=fn><a name="QTextStream-4"></a>QTextStream::QTextStream ( <a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;str, int&nbsp;filemode )
202</h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
203<p> This constructor is equivalent to the constructor taking a <a href="qstring.html">QString</a>*
204parameter.
205
206<h3 class=fn><a name="QTextStream-5"></a>QTextStream::QTextStream ( <a href="qbytearray.html">QByteArray</a>&nbsp;a, int&nbsp;mode )
207</h3>
208Constructs a text stream that operates on the byte array, <em>a</em>,
209through an internal <a href="qbuffer.html">QBuffer</a> device. The <em>mode</em> argument is passed
210to the device's open() function; see <a href="qiodevice.html#mode">QIODevice::mode</a>().
211<p> Example:
212<pre>
213 <a href="qbytearray.html">QByteArray</a> array;
214 QTextStream ts( array, <a href="qfile.html#open">IO_WriteOnly</a> );
215 ts &lt;&lt; "pi = " &lt;&lt; 3.14 &lt;&lt; '\0'; // array == "pi = 3.14"
216 </pre>
217
218<p> Writing data to the text stream will modify the contents of the
219array. The array will be expanded when data is written beyond the
220end of the string.
221<p> Same example, using a QBuffer:
222<pre>
223 <a href="qbytearray.html">QByteArray</a> array;
224 <a href="qbuffer.html">QBuffer</a> buf( array );
225 buf.<a href="qiodevice.html#open">open</a>( IO_WriteOnly );
226 QTextStream ts( &amp;buf );
227 ts &lt;&lt; "pi = " &lt;&lt; 3.14 &lt;&lt; '\0'; // array == "pi = 3.14"
228 buf.<a href="qiodevice.html#close">close</a>();
229 </pre>
230
231
232<h3 class=fn><a name="QTextStream-6"></a>QTextStream::QTextStream ( FILE&nbsp;*&nbsp;fh, int&nbsp;mode )
233</h3>
234Constructs a text stream that operates on an existing file handle
235<em>fh</em> through an internal <a href="qfile.html">QFile</a> device. The <em>mode</em> argument is
236passed to the device's open() function; see <a href="qiodevice.html#mode">QIODevice::mode</a>().
237<p> Note that if you create a QTextStream <tt>cout</tt> or another name that
238is also used for another variable of a different type, some
239linkers may confuse the two variables, which will often cause
240crashes.
241
242<h3 class=fn><a name="~QTextStream"></a>QTextStream::~QTextStream ()<tt> [virtual]</tt>
243</h3>
244Destroys the text stream.
245<p> The destructor does not affect the current IO device.
246
247<h3 class=fn>bool <a name="atEnd"></a>QTextStream::atEnd () const
248</h3>
249
250<p> Returns TRUE if the IO device has reached the end position (end of
251the stream or file) or if there is no IO device set; otherwise
252returns FALSE.
253<p> <p>See also <a href="qiodevice.html#atEnd">QIODevice::atEnd</a>().
254
255<p>Examples: <a href="addressbook-example.html#x601">addressbook/centralwidget.cpp</a> and <a href="grapher-nsplugin-example.html#x2774">grapher/grapher.cpp</a>.
256<h3 class=fn><a href="qtextcodec.html">QTextCodec</a>&nbsp;* <a name="codec"></a>QTextStream::codec ()
257</h3>
258Returns the codec actually used for this stream.
259<p> If Unicode is automatically detected in input, a codec with <a href="qtextcodec.html#name">name()</a> "ISO-10646-UCS-2" is returned.
260<p> <p>See also <a href="#setCodec">setCodec</a>().
261
262<h3 class=fn><a href="qiodevice.html">QIODevice</a>&nbsp;* <a name="device"></a>QTextStream::device () const
263</h3>
264
265<p> Returns the IO device currently set.
266<p> <p>See also <a href="#setDevice">setDevice</a>() and <a href="#unsetDevice">unsetDevice</a>().
267
268<h3 class=fn>bool <a name="eof"></a>QTextStream::eof () const
269</h3>
270<p> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
271<p> This function has been renamed to <a href="#atEnd">atEnd</a>().
272<p> <p>See also <a href="qiodevice.html#atEnd">QIODevice::atEnd</a>().
273
274<p>Example: <a href="tutorial2-07.html#x2592">chart/chartform_files.cpp</a>.
275<h3 class=fn>int <a name="fill"></a>QTextStream::fill () const
276</h3>
277
278<p> Returns the fill character. The default value is ' ' (space).
279
280<h3 class=fn>int <a name="fill-2"></a>QTextStream::fill ( int&nbsp;f )
281</h3>
282This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
283<p> Sets the fill character to <em>f</em>. Returns the previous fill character.
284
285<h3 class=fn>int <a name="flags"></a>QTextStream::flags () const
286</h3>
287
288<p> Returns the current stream flags. The default value is 0.
289<p> <center><table cellpadding="4" cellspacing="2" border="0">
290<tr bgcolor="#a2c511"> <th valign="top">Flag <th valign="top">Meaning
291<tr bgcolor="#f0f0f0"> <td valign="top"><tt>skipws</tt> <td valign="top">Not currently used; whitespace always skipped
292<tr bgcolor="#d0d0d0"> <td valign="top"><tt>left</tt> <td valign="top">Numeric fields are left-aligned
293<tr bgcolor="#f0f0f0"> <td valign="top"><tt>right</tt>
294<td valign="top">Not currently used (by default, numerics are right-aligned)
295<tr bgcolor="#d0d0d0"> <td valign="top"><tt>internal</tt> <td valign="top">Puts any padding spaces between +/- and value
296<tr bgcolor="#f0f0f0"> <td valign="top"><tt>bin</tt> <td valign="top">Output <em>and</em> input only in binary
297<tr bgcolor="#d0d0d0"> <td valign="top"><tt>oct</tt> <td valign="top">Output <em>and</em> input only in octal
298<tr bgcolor="#f0f0f0"> <td valign="top"><tt>dec</tt> <td valign="top">Output <em>and</em> input only in decimal
299<tr bgcolor="#d0d0d0"> <td valign="top"><tt>hex</tt> <td valign="top">Output <em>and</em> input only in hexadecimal
300<tr bgcolor="#f0f0f0"> <td valign="top"><tt>showbase</tt>
301<td valign="top">Annotates numeric outputs with 0b, 0, or 0x if in <tt>bin</tt>,
302<tt>oct</tt>, or <tt>hex</tt> format
303<tr bgcolor="#d0d0d0"> <td valign="top"><tt>showpoint</tt> <td valign="top">Not currently used
304<tr bgcolor="#f0f0f0"> <td valign="top"><tt>uppercase</tt> <td valign="top">Uses 0B and 0X rather than 0b and 0x
305<tr bgcolor="#d0d0d0"> <td valign="top"><tt>showpos</tt> <td valign="top">Shows + for positive numeric values
306<tr bgcolor="#f0f0f0"> <td valign="top"><tt>scientific</tt> <td valign="top">Uses scientific notation for floating point values
307<tr bgcolor="#d0d0d0"> <td valign="top"><tt>fixed</tt> <td valign="top">Uses fixed-point notation for floating point values
308</table></center>
309<p> Note that unless <tt>bin</tt>, <tt>oct</tt>, <tt>dec</tt>, or <tt>hex</tt> is set, the
310input base is octal if the value starts with 0, hexadecimal if it
311starts with 0x, binary if it starts with 0b, and decimal
312otherwise.
313<p> <p>See also <a href="#setf">setf</a>() and <a href="#unsetf">unsetf</a>().
314
315<h3 class=fn>int <a name="flags-2"></a>QTextStream::flags ( int&nbsp;f )
316</h3>
317
318<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
319<p> Sets the stream flags to <em>f</em>. Returns the previous stream flags.
320<p> <p>See also <a href="#setf">setf</a>() and <a href="#unsetf">unsetf</a>().
321
322<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="operator-lt-lt"></a>QTextStream::operator&lt;&lt; ( <a href="qchar.html">QChar</a>&nbsp;c )
323</h3>
324Writes character <tt>char</tt> to the stream and returns a reference to
325the stream.
326<p> The character <em>c</em> is assumed to be Latin1 encoded independent of
327the Encoding set for the QTextStream.
328
329<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="operator-lt-lt-2"></a>QTextStream::operator&lt;&lt; ( char&nbsp;c )
330</h3>
331This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
332<p> Writes character <em>c</em> to the stream and returns a reference to the
333stream.
334
335<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="operator-lt-lt-3"></a>QTextStream::operator&lt;&lt; ( signed&nbsp;short&nbsp;i )
336</h3>
337This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
338<p> Writes a <tt>short</tt> integer <em>i</em> to the stream and returns a
339reference to the stream.
340
341<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="operator-lt-lt-4"></a>QTextStream::operator&lt;&lt; ( unsigned&nbsp;short&nbsp;i )
342</h3>
343This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
344<p> Writes an <tt>unsigned</tt> <tt>short</tt> integer <em>i</em> to the stream and
345returns a reference to the stream.
346
347<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="operator-lt-lt-5"></a>QTextStream::operator&lt;&lt; ( signed&nbsp;int&nbsp;i )
348</h3>
349This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
350<p> Writes an <tt>int</tt> <em>i</em> to the stream and returns a reference to the
351stream.
352
353<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="operator-lt-lt-6"></a>QTextStream::operator&lt;&lt; ( unsigned&nbsp;int&nbsp;i )
354</h3>
355This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
356<p> Writes an <tt>unsigned</tt> <tt>int</tt> <em>i</em> to the stream and returns a
357reference to the stream.
358
359<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="operator-lt-lt-7"></a>QTextStream::operator&lt;&lt; ( signed&nbsp;long&nbsp;i )
360</h3>
361This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
362<p> Writes a <tt>long</tt> <tt>int</tt> <em>i</em> to the stream and returns a reference
363to the stream.
364
365<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="operator-lt-lt-8"></a>QTextStream::operator&lt;&lt; ( unsigned&nbsp;long&nbsp;i )
366</h3>
367This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
368<p> Writes an <tt>unsigned</tt> <tt>long</tt> <tt>int</tt> <em>i</em> to the stream and
369returns a reference to the stream.
370
371<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="operator-lt-lt-9"></a>QTextStream::operator&lt;&lt; ( float&nbsp;f )
372</h3>
373This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
374<p> Writes a <tt>float</tt> <em>f</em> to the stream and returns a reference to
375the stream.
376
377<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="operator-lt-lt-a"></a>QTextStream::operator&lt;&lt; ( double&nbsp;f )
378</h3>
379This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
380<p> Writes a <tt>double</tt> <em>f</em> to the stream and returns a reference to
381the stream.
382
383<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="operator-lt-lt-b"></a>QTextStream::operator&lt;&lt; ( const&nbsp;char&nbsp;*&nbsp;s )
384</h3>
385This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
386<p> Writes a string to the stream and returns a reference to the
387stream.
388<p> The string <em>s</em> is assumed to be Latin1 encoded independent of the
389Encoding set for the QTextStream.
390
391<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="operator-lt-lt-c"></a>QTextStream::operator&lt;&lt; ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;s )
392</h3>
393This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
394<p> Writes <em>s</em> to the stream and returns a reference to the stream.
395
396<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="operator-lt-lt-d"></a>QTextStream::operator&lt;&lt; ( const&nbsp;<a href="qcstring.html">QCString</a>&nbsp;&amp;&nbsp;s )
397</h3>
398This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
399<p> Writes <em>s</em> to the stream and returns a reference to the stream.
400<p> The string <em>s</em> is assumed to be Latin1 encoded independent of the
401Encoding set for the QTextStream.
402
403<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="operator-lt-lt-e"></a>QTextStream::operator&lt;&lt; ( void&nbsp;*&nbsp;ptr )
404</h3>
405This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
406<p> Writes a pointer to the stream and returns a reference to the
407stream.
408<p> The <em>ptr</em> is output as an unsigned long hexadecimal integer.
409
410<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="operator-gt-gt"></a>QTextStream::operator&gt;&gt; ( <a href="qchar.html">QChar</a>&nbsp;&amp;&nbsp;c )
411</h3>
412Reads a char <em>c</em> from the stream and returns a reference to the
413stream. Note that whitespace is <em>not</em> skipped.
414
415<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="operator-gt-gt-2"></a>QTextStream::operator&gt;&gt; ( char&nbsp;&amp;&nbsp;c )
416</h3>
417This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
418<p> Reads a char <em>c</em> from the stream and returns a reference to the
419stream. Note that whitespace is skipped.
420
421<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="operator-gt-gt-3"></a>QTextStream::operator&gt;&gt; ( signed&nbsp;short&nbsp;&amp;&nbsp;i )
422</h3>
423This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
424<p> Reads a signed <tt>short</tt> integer <em>i</em> from the stream and returns a
425reference to the stream. See <a href="#flags">flags</a>() for an explanation of the
426expected input format.
427
428<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="operator-gt-gt-4"></a>QTextStream::operator&gt;&gt; ( unsigned&nbsp;short&nbsp;&amp;&nbsp;i )
429</h3>
430This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
431<p> Reads an unsigned <tt>short</tt> integer <em>i</em> from the stream and
432returns a reference to the stream. See <a href="#flags">flags</a>() for an explanation
433of the expected input format.
434
435<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="operator-gt-gt-5"></a>QTextStream::operator&gt;&gt; ( signed&nbsp;int&nbsp;&amp;&nbsp;i )
436</h3>
437This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
438<p> Reads a signed <tt>int</tt> <em>i</em> from the stream and returns a reference
439to the stream. See <a href="#flags">flags</a>() for an explanation of the expected
440input format.
441
442<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="operator-gt-gt-6"></a>QTextStream::operator&gt;&gt; ( unsigned&nbsp;int&nbsp;&amp;&nbsp;i )
443</h3>
444This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
445<p> Reads an unsigned <tt>int</tt> <em>i</em> from the stream and returns a
446reference to the stream. See <a href="#flags">flags</a>() for an explanation of the
447expected input format.
448
449<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="operator-gt-gt-7"></a>QTextStream::operator&gt;&gt; ( signed&nbsp;long&nbsp;&amp;&nbsp;i )
450</h3>
451This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
452<p> Reads a signed <tt>long</tt> int <em>i</em> from the stream and returns a
453reference to the stream. See <a href="#flags">flags</a>() for an explanation of the
454expected input format.
455
456<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="operator-gt-gt-8"></a>QTextStream::operator&gt;&gt; ( unsigned&nbsp;long&nbsp;&amp;&nbsp;i )
457</h3>
458This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
459<p> Reads an unsigned <tt>long</tt> int <em>i</em> from the stream and returns a
460reference to the stream. See <a href="#flags">flags</a>() for an explanation of the
461expected input format.
462
463<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="operator-gt-gt-9"></a>QTextStream::operator&gt;&gt; ( float&nbsp;&amp;&nbsp;f )
464</h3>
465This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
466<p> Reads a <tt>float</tt> <em>f</em> from the stream and returns a reference to
467the stream. See <a href="#flags">flags</a>() for an explanation of the expected input
468format.
469
470<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="operator-gt-gt-a"></a>QTextStream::operator&gt;&gt; ( double&nbsp;&amp;&nbsp;f )
471</h3>
472This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
473<p> Reads a <tt>double</tt> <em>f</em> from the stream and returns a reference to
474the stream. See <a href="#flags">flags</a>() for an explanation of the expected input
475format.
476
477<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="operator-gt-gt-b"></a>QTextStream::operator&gt;&gt; ( char&nbsp;*&nbsp;s )
478</h3>
479This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
480<p> Reads a "word" from the stream into <em>s</em> and returns a reference
481to the stream.
482<p> A word consists of characters for which isspace() returns FALSE.
483
484<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="operator-gt-gt-c"></a>QTextStream::operator&gt;&gt; ( <a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;str )
485</h3>
486This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
487<p> Reads a "word" from the stream into <em>str</em> and returns a reference
488to the stream.
489<p> A word consists of characters for which isspace() returns FALSE.
490
491<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="operator-gt-gt-d"></a>QTextStream::operator&gt;&gt; ( <a href="qcstring.html">QCString</a>&nbsp;&amp;&nbsp;str )
492</h3>
493This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
494<p> Reads a "word" from the stream into <em>str</em> and returns a reference
495to the stream.
496<p> A word consists of characters for which isspace() returns FALSE.
497
498<h3 class=fn>int <a name="precision"></a>QTextStream::precision () const
499</h3>
500
501<p> Returns the precision. The default value is 6.
502
503<h3 class=fn>int <a name="precision-2"></a>QTextStream::precision ( int&nbsp;p )
504</h3>
505
506<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
507<p> Sets the precision to <em>p</em>. Returns the previous precision setting.
508
509<h3 class=fn><a href="qstring.html">QString</a> <a name="read"></a>QTextStream::read ()
510</h3>
511Reads the entire stream from the current position, and returns a string
512containing the text.
513<p> <p>See also <a href="qiodevice.html#readLine">QIODevice::readLine</a>().
514
515<p>Examples: <a href="qaction-application-example.html#x1171">action/application.cpp</a>, <a href="simple-application-example.html#x1589">application/application.cpp</a>, <a href="mdi-example.html#x2074">mdi/application.cpp</a>, <a href="qdir-example.html#x1847">qdir/qdir.cpp</a>, and <a href="qwerty-example.html#x401">qwerty/qwerty.cpp</a>.
516<h3 class=fn><a href="qstring.html">QString</a> <a name="readLine"></a>QTextStream::readLine ()
517</h3>
518Reads a line from the stream and returns a string containing the
519text.
520<p> The returned string does not contain any trailing newline or
521carriage return. Note that this is different from
522<a href="qiodevice.html#readLine">QIODevice::readLine</a>(), which does not strip the newline at the end
523of the line.
524<p> On EOF you will get a <a href="qstring.html">QString</a> that is null. On reading an empty
525line the returned QString is empty but not null.
526<p> <p>See also <a href="qiodevice.html#readLine">QIODevice::readLine</a>().
527
528<p>Examples: <a href="addressbook-example.html#x602">addressbook/centralwidget.cpp</a>, <a href="tutorial2-03.html#x2553">chart/element.cpp</a>, and <a href="clientserver-example.html#x787">network/clientserver/server/server.cpp</a>.
529<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="readRawBytes"></a>QTextStream::readRawBytes ( char&nbsp;*&nbsp;s, uint&nbsp;len )
530</h3>
531Reads <em>len</em> bytes from the stream into <em>s</em> and returns a
532reference to the stream.
533<p> The buffer <em>s</em> must be preallocated.
534<p> Note that no encoding is done by this function.
535<p> <b>Warning:</b> The behavior of this function is undefined unless the
536stream's encoding is set to Unicode or Latin1.
537<p> <p>See also <a href="qiodevice.html#readBlock">QIODevice::readBlock</a>().
538
539<h3 class=fn>void <a name="reset"></a>QTextStream::reset ()
540</h3>
541Resets the text stream.
542<p> <ul>
543<li> All flags are set to 0.
544<li> The field width is set to 0.
545<li> The fill character is set to ' ' (Space).
546<li> The precision is set to 6.
547</ul>
548<p> <p>See also <a href="#setf">setf</a>(), <a href="#width">width</a>(), <a href="#fill">fill</a>(), and <a href="#precision">precision</a>().
549
550<h3 class=fn>void <a name="setCodec"></a>QTextStream::setCodec ( <a href="qtextcodec.html">QTextCodec</a>&nbsp;*&nbsp;codec )
551</h3>
552Sets the codec for this stream to <em>codec</em>. Will not try to
553autodetect Unicode.
554<p> Note that this function should be called before any data is read
555to/written from the stream.
556<p> <p>See also <a href="#setEncoding">setEncoding</a>() and <a href="#codec">codec</a>().
557
558<p>Example: <a href="qwerty-example.html#x402">qwerty/qwerty.cpp</a>.
559<h3 class=fn>void <a name="setDevice"></a>QTextStream::setDevice ( <a href="qiodevice.html">QIODevice</a>&nbsp;*&nbsp;iod )
560</h3>
561Sets the IO device to <em>iod</em>.
562<p> <p>See also <a href="#device">device</a>() and <a href="#unsetDevice">unsetDevice</a>().
563
564<h3 class=fn>void <a name="setEncoding"></a>QTextStream::setEncoding ( <a href="qtextstream.html#Encoding-enum">Encoding</a>&nbsp;e )
565</h3>
566Sets the encoding of this stream to <em>e</em>, where <em>e</em> is one of the
567following values:
568<center><table cellpadding="4" cellspacing="2" border="0">
569<tr bgcolor="#a2c511"> <th valign="top">Encoding <th valign="top">Meaning
570<tr bgcolor="#f0f0f0"> <td valign="top">Locale
571<td valign="top">Uses local file format (Latin1 if locale is not set), but
572autodetecting Unicode(utf16) on input.
573<tr bgcolor="#d0d0d0"> <td valign="top">Unicode
574<td valign="top">Uses Unicode(utf16) for input and output. Output will be
575written in the order most efficient for the current platform
576(i.e. the order used internally in <a href="qstring.html">QString</a>).
577<tr bgcolor="#f0f0f0"> <td valign="top">UnicodeUTF8
578<td valign="top">Using Unicode(utf8) for input and output. If you use it for
579input it will autodetect utf16 and use it instead of utf8.
580<tr bgcolor="#d0d0d0"> <td valign="top">Latin1
581<td valign="top">ISO-8859-1. Will not autodetect utf16.
582<tr bgcolor="#f0f0f0"> <td valign="top">UnicodeNetworkOrder
583<td valign="top">Uses network order Unicode(utf16) for input and output.
584Useful when reading Unicode data that does not start with the
585byte order marker.
586<tr bgcolor="#d0d0d0"> <td valign="top">UnicodeReverse
587<td valign="top">Uses reverse network order Unicode(utf16) for input and
588output. Useful when reading Unicode data that does not start
589with the byte order marker or when writing data that should be
590read by buggy Windows applications.
591<tr bgcolor="#f0f0f0"> <td valign="top">RawUnicode
592<td valign="top">Like Unicode, but does not write the byte order marker nor
593does it auto-detect the byte order. Useful only when writing to
594non-persistent storage used by a single process.
595</table></center>
596<p> <a href="#Encoding-enum">Locale</a> and all Unicode encodings, except <a href="#Encoding-enum">RawUnicode</a>, will look
597at the first two bytes in an input stream to determine the byte
598order. The initial byte order marker will be stripped off before
599data is read.
600<p> Note that this function should be called before any data is read to
601or written from the stream.
602<p> <p>See also <a href="#setCodec">setCodec</a>().
603
604<p>Examples: <a href="addressbook-example.html#x603">addressbook/centralwidget.cpp</a>, <a href="httpd-example.html#x735">network/httpd/httpd.cpp</a>, and <a href="qwerty-example.html#x403">qwerty/qwerty.cpp</a>.
605<h3 class=fn>int <a name="setf"></a>QTextStream::setf ( int&nbsp;bits )
606</h3>
607
608<p> Sets the stream flag bits <em>bits</em>. Returns the previous stream
609flags.
610<p> Equivalent to <tt>flags( flags() | bits )</tt>.
611<p> <p>See also <a href="#unsetf">unsetf</a>().
612
613<h3 class=fn>int <a name="setf-2"></a>QTextStream::setf ( int&nbsp;bits, int&nbsp;mask )
614</h3>
615
616<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
617<p> Sets the stream flag bits <em>bits</em> with a bit mask <em>mask</em>. Returns
618the previous stream flags.
619<p> Equivalent to <tt>flags( (flags() &amp; ~mask) | (bits &amp; mask) )</tt>.
620<p> <p>See also <a href="#unsetf">unsetf</a>().
621
622<h3 class=fn>void <a name="skipWhiteSpace"></a>QTextStream::skipWhiteSpace ()
623</h3>
624Positions the read pointer at the first non-whitespace character.
625
626<h3 class=fn>void <a name="unsetDevice"></a>QTextStream::unsetDevice ()
627</h3>
628Unsets the IO device. Equivalent to <a href="#setDevice">setDevice</a>( 0 ).
629<p> <p>See also <a href="#device">device</a>() and <a href="#setDevice">setDevice</a>().
630
631<h3 class=fn>int <a name="unsetf"></a>QTextStream::unsetf ( int&nbsp;bits )
632</h3>
633
634<p> Clears the stream flag bits <em>bits</em>. Returns the previous stream
635flags.
636<p> Equivalent to <tt>flags( flags() &amp; ~mask )</tt>.
637<p> <p>See also <a href="#setf">setf</a>().
638
639<h3 class=fn>int <a name="width"></a>QTextStream::width () const
640</h3>
641
642<p> Returns the field width. The default value is 0.
643
644<h3 class=fn>int <a name="width-2"></a>QTextStream::width ( int&nbsp;w )
645</h3>
646
647<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
648<p> Sets the field width to <em>w</em>. Returns the previous field width.
649
650<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="writeRawBytes"></a>QTextStream::writeRawBytes ( const&nbsp;char&nbsp;*&nbsp;s, uint&nbsp;len )
651</h3>
652Writes the <em>len</em> bytes from <em>s</em> to the stream and returns a
653reference to the stream.
654<p> Note that no encoding is done by this function.
655<p> <p>See also <a href="qiodevice.html#writeBlock">QIODevice::writeBlock</a>().
656
657<!-- eof -->
658<hr><p>
659This file is part of the <a href="index.html">Qt toolkit</a>.
660Copyright &copy; 1995-2007
661<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
662<table width=100% cellspacing=0 border=0><tr>
663<td>Copyright &copy; 2007
664<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
665<td align=right><div align=right>Qt 3.3.8</div>
666</table></div></address></body>
667</html>
Note: See TracBrowser for help on using the repository browser.