You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tqt3/doc/html/ntqtextstream.html

668 lines
40 KiB

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/tools/qtextstream.cpp:56 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>TQTextStream Class</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
<a href="index.html">
<font color="#004faf">Home</font></a>
| <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
| <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>TQTextStream Class Reference</h1>
<p>The TQTextStream class provides basic functions for reading
and writing text using a TQIODevice.
<a href="#details">More...</a>
<p>All the functions in this class are <a href="threads.html#reentrant">reentrant</a> when TQt is built with thread support.</p>
<p><tt>#include &lt;<a href="qtextstream-h.html">ntqtextstream.h</a>&gt;</tt>
<p>Inherited by <a href="qtextistream.html">TQTextIStream</a> and <a href="qtextostream.html">TQTextOStream</a>.
<p><a href="qtextstream-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn>enum <a href="#Encoding-enum"><b>Encoding</b></a> { Locale, Latin1, Unicode, UnicodeNetworkOrder, UnicodeReverse, RawUnicode, UnicodeUTF8 }</li>
<li class=fn>void <a href="#setEncoding"><b>setEncoding</b></a> ( Encoding&nbsp;e )</li>
<li class=fn>void <a href="#setCodec"><b>setCodec</b></a> ( TQTextCodec&nbsp;*&nbsp;codec )</li>
<li class=fn>TQTextCodec * <a href="#codec"><b>codec</b></a> ()</li>
<li class=fn><a href="#TQTextStream"><b>TQTextStream</b></a> ()</li>
<li class=fn><a href="#TQTextStream-2"><b>TQTextStream</b></a> ( TQIODevice&nbsp;*&nbsp;iod )</li>
<li class=fn><a href="#TQTextStream-3"><b>TQTextStream</b></a> ( TQString&nbsp;*&nbsp;str, int&nbsp;filemode )</li>
<li class=fn>TQTextStream ( TQString&nbsp;&amp;&nbsp;str, int&nbsp;filemode ) &nbsp;<em>(obsolete)</em></li>
<li class=fn><a href="#TQTextStream-5"><b>TQTextStream</b></a> ( TQByteArray&nbsp;a, int&nbsp;mode )</li>
<li class=fn><a href="#TQTextStream-6"><b>TQTextStream</b></a> ( FILE&nbsp;*&nbsp;fh, int&nbsp;mode )</li>
<li class=fn>virtual <a href="#~TQTextStream"><b>~TQTextStream</b></a> ()</li>
<li class=fn>TQIODevice * <a href="#device"><b>device</b></a> () const</li>
<li class=fn>void <a href="#setDevice"><b>setDevice</b></a> ( TQIODevice&nbsp;*&nbsp;iod )</li>
<li class=fn>void <a href="#unsetDevice"><b>unsetDevice</b></a> ()</li>
<li class=fn>bool <a href="#atEnd"><b>atEnd</b></a> () const</li>
<li class=fn>bool eof () const &nbsp;<em>(obsolete)</em></li>
<li class=fn>TQTextStream &amp; <a href="#operator-gt-gt"><b>operator&gt;&gt;</b></a> ( TQChar&nbsp;&amp;&nbsp;c )</li>
<li class=fn>TQTextStream &amp; <a href="#operator-gt-gt-2"><b>operator&gt;&gt;</b></a> ( char&nbsp;&amp;&nbsp;c )</li>
<li class=fn>TQTextStream &amp; <a href="#operator-gt-gt-3"><b>operator&gt;&gt;</b></a> ( signed&nbsp;short&nbsp;&amp;&nbsp;i )</li>
<li class=fn>TQTextStream &amp; <a href="#operator-gt-gt-4"><b>operator&gt;&gt;</b></a> ( unsigned&nbsp;short&nbsp;&amp;&nbsp;i )</li>
<li class=fn>TQTextStream &amp; <a href="#operator-gt-gt-5"><b>operator&gt;&gt;</b></a> ( signed&nbsp;int&nbsp;&amp;&nbsp;i )</li>
<li class=fn>TQTextStream &amp; <a href="#operator-gt-gt-6"><b>operator&gt;&gt;</b></a> ( unsigned&nbsp;int&nbsp;&amp;&nbsp;i )</li>
<li class=fn>TQTextStream &amp; <a href="#operator-gt-gt-7"><b>operator&gt;&gt;</b></a> ( signed&nbsp;long&nbsp;&amp;&nbsp;i )</li>
<li class=fn>TQTextStream &amp; <a href="#operator-gt-gt-8"><b>operator&gt;&gt;</b></a> ( unsigned&nbsp;long&nbsp;&amp;&nbsp;i )</li>
<li class=fn>TQTextStream &amp; <a href="#operator-gt-gt-9"><b>operator&gt;&gt;</b></a> ( float&nbsp;&amp;&nbsp;f )</li>
<li class=fn>TQTextStream &amp; <a href="#operator-gt-gt-a"><b>operator&gt;&gt;</b></a> ( double&nbsp;&amp;&nbsp;f )</li>
<li class=fn>TQTextStream &amp; <a href="#operator-gt-gt-b"><b>operator&gt;&gt;</b></a> ( char&nbsp;*&nbsp;s )</li>
<li class=fn>TQTextStream &amp; <a href="#operator-gt-gt-c"><b>operator&gt;&gt;</b></a> ( TQString&nbsp;&amp;&nbsp;str )</li>
<li class=fn>TQTextStream &amp; <a href="#operator-gt-gt-d"><b>operator&gt;&gt;</b></a> ( TQCString&nbsp;&amp;&nbsp;str )</li>
<li class=fn>TQTextStream &amp; <a href="#operator-lt-lt"><b>operator&lt;&lt;</b></a> ( TQChar&nbsp;c )</li>
<li class=fn>TQTextStream &amp; <a href="#operator-lt-lt-2"><b>operator&lt;&lt;</b></a> ( char&nbsp;c )</li>
<li class=fn>TQTextStream &amp; <a href="#operator-lt-lt-3"><b>operator&lt;&lt;</b></a> ( signed&nbsp;short&nbsp;i )</li>
<li class=fn>TQTextStream &amp; <a href="#operator-lt-lt-4"><b>operator&lt;&lt;</b></a> ( unsigned&nbsp;short&nbsp;i )</li>
<li class=fn>TQTextStream &amp; <a href="#operator-lt-lt-5"><b>operator&lt;&lt;</b></a> ( signed&nbsp;int&nbsp;i )</li>
<li class=fn>TQTextStream &amp; <a href="#operator-lt-lt-6"><b>operator&lt;&lt;</b></a> ( unsigned&nbsp;int&nbsp;i )</li>
<li class=fn>TQTextStream &amp; <a href="#operator-lt-lt-7"><b>operator&lt;&lt;</b></a> ( signed&nbsp;long&nbsp;i )</li>
<li class=fn>TQTextStream &amp; <a href="#operator-lt-lt-8"><b>operator&lt;&lt;</b></a> ( unsigned&nbsp;long&nbsp;i )</li>
<li class=fn>TQTextStream &amp; <a href="#operator-lt-lt-9"><b>operator&lt;&lt;</b></a> ( float&nbsp;f )</li>
<li class=fn>TQTextStream &amp; <a href="#operator-lt-lt-a"><b>operator&lt;&lt;</b></a> ( double&nbsp;f )</li>
<li class=fn>TQTextStream &amp; <a href="#operator-lt-lt-b"><b>operator&lt;&lt;</b></a> ( const&nbsp;char&nbsp;*&nbsp;s )</li>
<li class=fn>TQTextStream &amp; <a href="#operator-lt-lt-c"><b>operator&lt;&lt;</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;s )</li>
<li class=fn>TQTextStream &amp; <a href="#operator-lt-lt-d"><b>operator&lt;&lt;</b></a> ( const&nbsp;TQCString&nbsp;&amp;&nbsp;s )</li>
<li class=fn>TQTextStream &amp; <a href="#operator-lt-lt-e"><b>operator&lt;&lt;</b></a> ( void&nbsp;*&nbsp;ptr )</li>
<li class=fn>TQTextStream &amp; <a href="#readRawBytes"><b>readRawBytes</b></a> ( char&nbsp;*&nbsp;s, uint&nbsp;len )</li>
<li class=fn>TQTextStream &amp; <a href="#writeRawBytes"><b>writeRawBytes</b></a> ( const&nbsp;char&nbsp;*&nbsp;s, uint&nbsp;len )</li>
<li class=fn>TQString <a href="#readLine"><b>readLine</b></a> ()</li>
<li class=fn>TQString <a href="#read"><b>read</b></a> ()</li>
<li class=fn>void <a href="#skipWhiteSpace"><b>skipWhiteSpace</b></a> ()</li>
<li class=fn>int <a href="#flags"><b>flags</b></a> () const</li>
<li class=fn>int <a href="#flags-2"><b>flags</b></a> ( int&nbsp;f )</li>
<li class=fn>int <a href="#setf"><b>setf</b></a> ( int&nbsp;bits )</li>
<li class=fn>int <a href="#setf-2"><b>setf</b></a> ( int&nbsp;bits, int&nbsp;mask )</li>
<li class=fn>int <a href="#unsetf"><b>unsetf</b></a> ( int&nbsp;bits )</li>
<li class=fn>void <a href="#reset"><b>reset</b></a> ()</li>
<li class=fn>int <a href="#width"><b>width</b></a> () const</li>
<li class=fn>int <a href="#width-2"><b>width</b></a> ( int&nbsp;w )</li>
<li class=fn>int <a href="#fill"><b>fill</b></a> () const</li>
<li class=fn>int <a href="#fill-2"><b>fill</b></a> ( int&nbsp;f )</li>
<li class=fn>int <a href="#precision"><b>precision</b></a> () const</li>
<li class=fn>int <a href="#precision-2"><b>precision</b></a> ( int&nbsp;p )</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>
The TQTextStream class provides basic functions for reading
and writing text using a <a href="ntqiodevice.html">TQIODevice</a>.
<p>
<p> The text stream class has a functional interface that is very
similar to that of the standard C++ iostream class.
<p> TQt provides several global functions similar to the ones in iostream:
<center><table cellpadding="4" cellspacing="2" border="0">
<tr bgcolor="#a2c511"> <th valign="top">Function <th valign="top">Meaning
<tr bgcolor="#f0f0f0"> <td valign="top">bin <td valign="top">sets the TQTextStream to read/write binary numbers
<tr bgcolor="#d0d0d0"> <td valign="top">oct <td valign="top">sets the TQTextStream to read/write octal numbers
<tr bgcolor="#f0f0f0"> <td valign="top">dec <td valign="top">sets the TQTextStream to read/write decimal numbers
<tr bgcolor="#d0d0d0"> <td valign="top">hex <td valign="top">sets the TQTextStream to read/write hexadecimal numbers
<tr bgcolor="#f0f0f0"> <td valign="top">endl <td valign="top">forces a line break
<tr bgcolor="#d0d0d0"> <td valign="top">flush <td valign="top">forces the TQIODevice to flush any buffered data
<tr bgcolor="#f0f0f0"> <td valign="top">ws <td valign="top">eats any available whitespace (on input)
<tr bgcolor="#d0d0d0"> <td valign="top">reset <td valign="top">resets the TQTextStream to its default mode (see <a href="#reset">reset</a>())
<tr bgcolor="#f0f0f0"> <td valign="top">qSetW(int) <td valign="top">sets the <a href="#width">field width</a>
to the given argument
<tr bgcolor="#d0d0d0"> <td valign="top">qSetFill(int) <td valign="top">sets the <a href="#fill">fill character</a> to the given argument
<tr bgcolor="#f0f0f0"> <td valign="top">qSetPrecision(int) <td valign="top">sets the <a href="#precision">precision</a> to the given argument
</table></center>
<p> <b>Warning:</b> By default TQTextStream will automatically detect whether
integers in the stream are in decimal, octal, hexadecimal or
binary format when reading from the stream. In particular, a
leading '0' signifies octal, i.e. the sequence "0100" will be
interpreted as 64.
<p> The TQTextStream class reads and writes text; it is not appropriate
for dealing with binary data (but <a href="ntqdatastream.html">TQDataStream</a> is).
<p> By default, output of Unicode text (i.e. <a href="ntqstring.html">TQString</a>) is done using
the local 8-bit encoding. This can be changed using the
<a href="#setEncoding">setEncoding</a>() method. For input, the TQTextStream will auto-detect
standard Unicode "byte order marked" text files; otherwise the
local 8-bit encoding is used.
<p> The <a href="ntqiodevice.html">TQIODevice</a> is set in the constructor, or later using
<a href="#setDevice">setDevice</a>(). If the end of the input is reached <a href="#atEnd">atEnd</a>() returns
TRUE. Data can be read into variables of the appropriate type
using the <a href="#operator-gt-gt">operator&gt;&gt;</a>() overloads, or read in its entirety into a
single string using <a href="#read">read</a>(), or read a line at a time using
<a href="#readLine">readLine</a>(). Whitespace can be skipped over using <a href="#skipWhiteSpace">skipWhiteSpace</a>().
You can set flags for the stream using <a href="#flags">flags</a>() or <a href="#setf">setf</a>(). The
stream also supports <a href="#width">width</a>(), <a href="#precision">precision</a>() and <a href="#fill">fill</a>(); use <a href="#reset">reset</a>()
to reset the defaults.
<p> <p>See also <a href="ntqdatastream.html">TQDataStream</a>, <a href="io.html">Input/Output and Networking</a>, and <a href="text.html">Text Related Classes</a>.
<hr><h2>Member Type Documentation</h2>
<h3 class=fn><a name="Encoding-enum"></a>TQTextStream::Encoding</h3>
<ul>
<li><tt>TQTextStream::Locale</tt>
<li><tt>TQTextStream::Latin1</tt>
<li><tt>TQTextStream::Unicode</tt>
<li><tt>TQTextStream::UnicodeNetworkOrder</tt>
<li><tt>TQTextStream::UnicodeReverse</tt>
<li><tt>TQTextStream::RawUnicode</tt>
<li><tt>TQTextStream::UnicodeUTF8</tt>
</ul><p> See <a href="#setEncoding">setEncoding</a>() for an explanation of the encodings.
<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="TQTextStream"></a>TQTextStream::TQTextStream ()
</h3>
Constructs a data stream that has no IO device.
<h3 class=fn><a name="TQTextStream-2"></a>TQTextStream::TQTextStream ( <a href="ntqiodevice.html">TQIODevice</a>&nbsp;*&nbsp;iod )
</h3>
Constructs a text stream that uses the IO device <em>iod</em>.
<h3 class=fn><a name="TQTextStream-3"></a>TQTextStream::TQTextStream ( <a href="ntqstring.html">TQString</a>&nbsp;*&nbsp;str, int&nbsp;filemode )
</h3>
Constructs a text stream that operates on the Unicode <a href="ntqstring.html">TQString</a>, <em>str</em>, through an internal device. The <em>filemode</em> argument is
passed to the device's open() function; see <a href="ntqiodevice.html#mode">TQIODevice::mode</a>().
<p> If you set an encoding or codec with <a href="#setEncoding">setEncoding</a>() or <a href="#setCodec">setCodec</a>(),
this setting is ignored for text streams that operate on TQString.
<p> Example:
<pre>
<a href="ntqstring.html">TQString</a> str;
TQTextStream ts( &amp;str, <a href="ntqfile.html#open">IO_WriteOnly</a> );
ts &lt;&lt; "pi = " &lt;&lt; 3.14; // str == "pi = 3.14"
</pre>
<p> Writing data to the text stream will modify the contents of the
string. The string will be expanded when data is written beyond
the end of the string. Note that the string will not be truncated:
<pre>
<a href="ntqstring.html">TQString</a> str = "pi = 3.14";
TQTextStream ts( &amp;str, IO_WriteOnly );
ts &lt;&lt; "2+2 = " &lt;&lt; 2+2; // str == "2+2 = 414"
</pre>
<p> Note that because TQString is Unicode, you should not use
<a href="#readRawBytes">readRawBytes</a>() or <a href="#writeRawBytes">writeRawBytes</a>() on such a stream.
<h3 class=fn><a name="TQTextStream-4"></a>TQTextStream::TQTextStream ( <a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;str, int&nbsp;filemode )
</h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p> This constructor is equivalent to the constructor taking a <a href="ntqstring.html">TQString</a>*
parameter.
<h3 class=fn><a name="TQTextStream-5"></a>TQTextStream::TQTextStream ( <a href="qbytearray.html">TQByteArray</a>&nbsp;a, int&nbsp;mode )
</h3>
Constructs a text stream that operates on the byte array, <em>a</em>,
through an internal <a href="ntqbuffer.html">TQBuffer</a> device. The <em>mode</em> argument is passed
to the device's open() function; see <a href="ntqiodevice.html#mode">TQIODevice::mode</a>().
<p> Example:
<pre>
<a href="qbytearray.html">TQByteArray</a> array;
TQTextStream ts( array, <a href="ntqfile.html#open">IO_WriteOnly</a> );
ts &lt;&lt; "pi = " &lt;&lt; 3.14 &lt;&lt; '\0'; // array == "pi = 3.14"
</pre>
<p> Writing data to the text stream will modify the contents of the
array. The array will be expanded when data is written beyond the
end of the string.
<p> Same example, using a TQBuffer:
<pre>
<a href="qbytearray.html">TQByteArray</a> array;
<a href="ntqbuffer.html">TQBuffer</a> buf( array );
buf.<a href="ntqiodevice.html#open">open</a>( IO_WriteOnly );
TQTextStream ts( &amp;buf );
ts &lt;&lt; "pi = " &lt;&lt; 3.14 &lt;&lt; '\0'; // array == "pi = 3.14"
buf.<a href="ntqiodevice.html#close">close</a>();
</pre>
<h3 class=fn><a name="TQTextStream-6"></a>TQTextStream::TQTextStream ( FILE&nbsp;*&nbsp;fh, int&nbsp;mode )
</h3>
Constructs a text stream that operates on an existing file handle
<em>fh</em> through an internal <a href="ntqfile.html">TQFile</a> device. The <em>mode</em> argument is
passed to the device's open() function; see <a href="ntqiodevice.html#mode">TQIODevice::mode</a>().
<p> Note that if you create a TQTextStream <tt>cout</tt> or another name that
is also used for another variable of a different type, some
linkers may confuse the two variables, which will often cause
crashes.
<h3 class=fn><a name="~TQTextStream"></a>TQTextStream::~TQTextStream ()<tt> [virtual]</tt>
</h3>
Destroys the text stream.
<p> The destructor does not affect the current IO device.
<h3 class=fn>bool <a name="atEnd"></a>TQTextStream::atEnd () const
</h3>
<p> Returns TRUE if the IO device has reached the end position (end of
the stream or file) or if there is no IO device set; otherwise
returns FALSE.
<p> <p>See also <a href="ntqiodevice.html#atEnd">TQIODevice::atEnd</a>().
<p>Examples: <a href="addressbook-example.html#x601">addressbook/centralwidget.cpp</a> and <a href="grapher-nsplugin-example.html#x2774">grapher/grapher.cpp</a>.
<h3 class=fn><a href="ntqtextcodec.html">TQTextCodec</a>&nbsp;* <a name="codec"></a>TQTextStream::codec ()
</h3>
Returns the codec actually used for this stream.
<p> If Unicode is automatically detected in input, a codec with <a href="ntqtextcodec.html#name">name()</a> "ISO-10646-UCS-2" is returned.
<p> <p>See also <a href="#setCodec">setCodec</a>().
<h3 class=fn><a href="ntqiodevice.html">TQIODevice</a>&nbsp;* <a name="device"></a>TQTextStream::device () const
</h3>
<p> Returns the IO device currently set.
<p> <p>See also <a href="#setDevice">setDevice</a>() and <a href="#unsetDevice">unsetDevice</a>().
<h3 class=fn>bool <a name="eof"></a>TQTextStream::eof () const
</h3>
<p> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p> This function has been renamed to <a href="#atEnd">atEnd</a>().
<p> <p>See also <a href="ntqiodevice.html#atEnd">TQIODevice::atEnd</a>().
<p>Example: <a href="tutorial2-07.html#x2592">chart/chartform_files.cpp</a>.
<h3 class=fn>int <a name="fill"></a>TQTextStream::fill () const
</h3>
<p> Returns the fill character. The default value is ' ' (space).
<h3 class=fn>int <a name="fill-2"></a>TQTextStream::fill ( int&nbsp;f )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Sets the fill character to <em>f</em>. Returns the previous fill character.
<h3 class=fn>int <a name="flags"></a>TQTextStream::flags () const
</h3>
<p> Returns the current stream flags. The default value is 0.
<p> <center><table cellpadding="4" cellspacing="2" border="0">
<tr bgcolor="#a2c511"> <th valign="top">Flag <th valign="top">Meaning
<tr bgcolor="#f0f0f0"> <td valign="top"><tt>skipws</tt> <td valign="top">Not currently used; whitespace always skipped
<tr bgcolor="#d0d0d0"> <td valign="top"><tt>left</tt> <td valign="top">Numeric fields are left-aligned
<tr bgcolor="#f0f0f0"> <td valign="top"><tt>right</tt>
<td valign="top">Not currently used (by default, numerics are right-aligned)
<tr bgcolor="#d0d0d0"> <td valign="top"><tt>internal</tt> <td valign="top">Puts any padding spaces between +/- and value
<tr bgcolor="#f0f0f0"> <td valign="top"><tt>bin</tt> <td valign="top">Output <em>and</em> input only in binary
<tr bgcolor="#d0d0d0"> <td valign="top"><tt>oct</tt> <td valign="top">Output <em>and</em> input only in octal
<tr bgcolor="#f0f0f0"> <td valign="top"><tt>dec</tt> <td valign="top">Output <em>and</em> input only in decimal
<tr bgcolor="#d0d0d0"> <td valign="top"><tt>hex</tt> <td valign="top">Output <em>and</em> input only in hexadecimal
<tr bgcolor="#f0f0f0"> <td valign="top"><tt>showbase</tt>
<td valign="top">Annotates numeric outputs with 0b, 0, or 0x if in <tt>bin</tt>,
<tt>oct</tt>, or <tt>hex</tt> format
<tr bgcolor="#d0d0d0"> <td valign="top"><tt>showpoint</tt> <td valign="top">Not currently used
<tr bgcolor="#f0f0f0"> <td valign="top"><tt>uppercase</tt> <td valign="top">Uses 0B and 0X rather than 0b and 0x
<tr bgcolor="#d0d0d0"> <td valign="top"><tt>showpos</tt> <td valign="top">Shows + for positive numeric values
<tr bgcolor="#f0f0f0"> <td valign="top"><tt>scientific</tt> <td valign="top">Uses scientific notation for floating point values
<tr bgcolor="#d0d0d0"> <td valign="top"><tt>fixed</tt> <td valign="top">Uses fixed-point notation for floating point values
</table></center>
<p> Note that unless <tt>bin</tt>, <tt>oct</tt>, <tt>dec</tt>, or <tt>hex</tt> is set, the
input base is octal if the value starts with 0, hexadecimal if it
starts with 0x, binary if it starts with 0b, and decimal
otherwise.
<p> <p>See also <a href="#setf">setf</a>() and <a href="#unsetf">unsetf</a>().
<h3 class=fn>int <a name="flags-2"></a>TQTextStream::flags ( int&nbsp;f )
</h3>
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Sets the stream flags to <em>f</em>. Returns the previous stream flags.
<p> <p>See also <a href="#setf">setf</a>() and <a href="#unsetf">unsetf</a>().
<h3 class=fn><a href="ntqtextstream.html">TQTextStream</a>&nbsp;&amp; <a name="operator-lt-lt"></a>TQTextStream::operator&lt;&lt; ( <a href="qchar.html">TQChar</a>&nbsp;c )
</h3>
Writes character <tt>char</tt> to the stream and returns a reference to
the stream.
<p> The character <em>c</em> is assumed to be Latin1 encoded independent of
the Encoding set for the TQTextStream.
<h3 class=fn><a href="ntqtextstream.html">TQTextStream</a>&nbsp;&amp; <a name="operator-lt-lt-2"></a>TQTextStream::operator&lt;&lt; ( char&nbsp;c )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Writes character <em>c</em> to the stream and returns a reference to the
stream.
<h3 class=fn><a href="ntqtextstream.html">TQTextStream</a>&nbsp;&amp; <a name="operator-lt-lt-3"></a>TQTextStream::operator&lt;&lt; ( signed&nbsp;short&nbsp;i )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Writes a <tt>short</tt> integer <em>i</em> to the stream and returns a
reference to the stream.
<h3 class=fn><a href="ntqtextstream.html">TQTextStream</a>&nbsp;&amp; <a name="operator-lt-lt-4"></a>TQTextStream::operator&lt;&lt; ( unsigned&nbsp;short&nbsp;i )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Writes an <tt>unsigned</tt> <tt>short</tt> integer <em>i</em> to the stream and
returns a reference to the stream.
<h3 class=fn><a href="ntqtextstream.html">TQTextStream</a>&nbsp;&amp; <a name="operator-lt-lt-5"></a>TQTextStream::operator&lt;&lt; ( signed&nbsp;int&nbsp;i )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Writes an <tt>int</tt> <em>i</em> to the stream and returns a reference to the
stream.
<h3 class=fn><a href="ntqtextstream.html">TQTextStream</a>&nbsp;&amp; <a name="operator-lt-lt-6"></a>TQTextStream::operator&lt;&lt; ( unsigned&nbsp;int&nbsp;i )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Writes an <tt>unsigned</tt> <tt>int</tt> <em>i</em> to the stream and returns a
reference to the stream.
<h3 class=fn><a href="ntqtextstream.html">TQTextStream</a>&nbsp;&amp; <a name="operator-lt-lt-7"></a>TQTextStream::operator&lt;&lt; ( signed&nbsp;long&nbsp;i )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Writes a <tt>long</tt> <tt>int</tt> <em>i</em> to the stream and returns a reference
to the stream.
<h3 class=fn><a href="ntqtextstream.html">TQTextStream</a>&nbsp;&amp; <a name="operator-lt-lt-8"></a>TQTextStream::operator&lt;&lt; ( unsigned&nbsp;long&nbsp;i )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Writes an <tt>unsigned</tt> <tt>long</tt> <tt>int</tt> <em>i</em> to the stream and
returns a reference to the stream.
<h3 class=fn><a href="ntqtextstream.html">TQTextStream</a>&nbsp;&amp; <a name="operator-lt-lt-9"></a>TQTextStream::operator&lt;&lt; ( float&nbsp;f )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Writes a <tt>float</tt> <em>f</em> to the stream and returns a reference to
the stream.
<h3 class=fn><a href="ntqtextstream.html">TQTextStream</a>&nbsp;&amp; <a name="operator-lt-lt-a"></a>TQTextStream::operator&lt;&lt; ( double&nbsp;f )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Writes a <tt>double</tt> <em>f</em> to the stream and returns a reference to
the stream.
<h3 class=fn><a href="ntqtextstream.html">TQTextStream</a>&nbsp;&amp; <a name="operator-lt-lt-b"></a>TQTextStream::operator&lt;&lt; ( const&nbsp;char&nbsp;*&nbsp;s )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Writes a string to the stream and returns a reference to the
stream.
<p> The string <em>s</em> is assumed to be Latin1 encoded independent of the
Encoding set for the TQTextStream.
<h3 class=fn><a href="ntqtextstream.html">TQTextStream</a>&nbsp;&amp; <a name="operator-lt-lt-c"></a>TQTextStream::operator&lt;&lt; ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;s )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Writes <em>s</em> to the stream and returns a reference to the stream.
<h3 class=fn><a href="ntqtextstream.html">TQTextStream</a>&nbsp;&amp; <a name="operator-lt-lt-d"></a>TQTextStream::operator&lt;&lt; ( const&nbsp;<a href="ntqcstring.html">TQCString</a>&nbsp;&amp;&nbsp;s )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Writes <em>s</em> to the stream and returns a reference to the stream.
<p> The string <em>s</em> is assumed to be Latin1 encoded independent of the
Encoding set for the TQTextStream.
<h3 class=fn><a href="ntqtextstream.html">TQTextStream</a>&nbsp;&amp; <a name="operator-lt-lt-e"></a>TQTextStream::operator&lt;&lt; ( void&nbsp;*&nbsp;ptr )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Writes a pointer to the stream and returns a reference to the
stream.
<p> The <em>ptr</em> is output as an unsigned long hexadecimal integer.
<h3 class=fn><a href="ntqtextstream.html">TQTextStream</a>&nbsp;&amp; <a name="operator-gt-gt"></a>TQTextStream::operator&gt;&gt; ( <a href="qchar.html">TQChar</a>&nbsp;&amp;&nbsp;c )
</h3>
Reads a char <em>c</em> from the stream and returns a reference to the
stream. Note that whitespace is <em>not</em> skipped.
<h3 class=fn><a href="ntqtextstream.html">TQTextStream</a>&nbsp;&amp; <a name="operator-gt-gt-2"></a>TQTextStream::operator&gt;&gt; ( char&nbsp;&amp;&nbsp;c )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Reads a char <em>c</em> from the stream and returns a reference to the
stream. Note that whitespace is skipped.
<h3 class=fn><a href="ntqtextstream.html">TQTextStream</a>&nbsp;&amp; <a name="operator-gt-gt-3"></a>TQTextStream::operator&gt;&gt; ( signed&nbsp;short&nbsp;&amp;&nbsp;i )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Reads a signed <tt>short</tt> integer <em>i</em> from the stream and returns a
reference to the stream. See <a href="#flags">flags</a>() for an explanation of the
expected input format.
<h3 class=fn><a href="ntqtextstream.html">TQTextStream</a>&nbsp;&amp; <a name="operator-gt-gt-4"></a>TQTextStream::operator&gt;&gt; ( unsigned&nbsp;short&nbsp;&amp;&nbsp;i )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Reads an unsigned <tt>short</tt> integer <em>i</em> from the stream and
returns a reference to the stream. See <a href="#flags">flags</a>() for an explanation
of the expected input format.
<h3 class=fn><a href="ntqtextstream.html">TQTextStream</a>&nbsp;&amp; <a name="operator-gt-gt-5"></a>TQTextStream::operator&gt;&gt; ( signed&nbsp;int&nbsp;&amp;&nbsp;i )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Reads a signed <tt>int</tt> <em>i</em> from the stream and returns a reference
to the stream. See <a href="#flags">flags</a>() for an explanation of the expected
input format.
<h3 class=fn><a href="ntqtextstream.html">TQTextStream</a>&nbsp;&amp; <a name="operator-gt-gt-6"></a>TQTextStream::operator&gt;&gt; ( unsigned&nbsp;int&nbsp;&amp;&nbsp;i )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Reads an unsigned <tt>int</tt> <em>i</em> from the stream and returns a
reference to the stream. See <a href="#flags">flags</a>() for an explanation of the
expected input format.
<h3 class=fn><a href="ntqtextstream.html">TQTextStream</a>&nbsp;&amp; <a name="operator-gt-gt-7"></a>TQTextStream::operator&gt;&gt; ( signed&nbsp;long&nbsp;&amp;&nbsp;i )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Reads a signed <tt>long</tt> int <em>i</em> from the stream and returns a
reference to the stream. See <a href="#flags">flags</a>() for an explanation of the
expected input format.
<h3 class=fn><a href="ntqtextstream.html">TQTextStream</a>&nbsp;&amp; <a name="operator-gt-gt-8"></a>TQTextStream::operator&gt;&gt; ( unsigned&nbsp;long&nbsp;&amp;&nbsp;i )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Reads an unsigned <tt>long</tt> int <em>i</em> from the stream and returns a
reference to the stream. See <a href="#flags">flags</a>() for an explanation of the
expected input format.
<h3 class=fn><a href="ntqtextstream.html">TQTextStream</a>&nbsp;&amp; <a name="operator-gt-gt-9"></a>TQTextStream::operator&gt;&gt; ( float&nbsp;&amp;&nbsp;f )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Reads a <tt>float</tt> <em>f</em> from the stream and returns a reference to
the stream. See <a href="#flags">flags</a>() for an explanation of the expected input
format.
<h3 class=fn><a href="ntqtextstream.html">TQTextStream</a>&nbsp;&amp; <a name="operator-gt-gt-a"></a>TQTextStream::operator&gt;&gt; ( double&nbsp;&amp;&nbsp;f )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Reads a <tt>double</tt> <em>f</em> from the stream and returns a reference to
the stream. See <a href="#flags">flags</a>() for an explanation of the expected input
format.
<h3 class=fn><a href="ntqtextstream.html">TQTextStream</a>&nbsp;&amp; <a name="operator-gt-gt-b"></a>TQTextStream::operator&gt;&gt; ( char&nbsp;*&nbsp;s )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Reads a "word" from the stream into <em>s</em> and returns a reference
to the stream.
<p> A word consists of characters for which isspace() returns FALSE.
<h3 class=fn><a href="ntqtextstream.html">TQTextStream</a>&nbsp;&amp; <a name="operator-gt-gt-c"></a>TQTextStream::operator&gt;&gt; ( <a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;str )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Reads a "word" from the stream into <em>str</em> and returns a reference
to the stream.
<p> A word consists of characters for which isspace() returns FALSE.
<h3 class=fn><a href="ntqtextstream.html">TQTextStream</a>&nbsp;&amp; <a name="operator-gt-gt-d"></a>TQTextStream::operator&gt;&gt; ( <a href="ntqcstring.html">TQCString</a>&nbsp;&amp;&nbsp;str )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Reads a "word" from the stream into <em>str</em> and returns a reference
to the stream.
<p> A word consists of characters for which isspace() returns FALSE.
<h3 class=fn>int <a name="precision"></a>TQTextStream::precision () const
</h3>
<p> Returns the precision. The default value is 6.
<h3 class=fn>int <a name="precision-2"></a>TQTextStream::precision ( int&nbsp;p )
</h3>
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Sets the precision to <em>p</em>. Returns the previous precision setting.
<h3 class=fn><a href="ntqstring.html">TQString</a> <a name="read"></a>TQTextStream::read ()
</h3>
Reads the entire stream from the current position, and returns a string
containing the text.
<p> <p>See also <a href="ntqiodevice.html#readLine">TQIODevice::readLine</a>().
<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>.
<h3 class=fn><a href="ntqstring.html">TQString</a> <a name="readLine"></a>TQTextStream::readLine ()
</h3>
Reads a line from the stream and returns a string containing the
text.
<p> The returned string does not contain any trailing newline or
carriage return. Note that this is different from
<a href="ntqiodevice.html#readLine">TQIODevice::readLine</a>(), which does not strip the newline at the end
of the line.
<p> On EOF you will get a <a href="ntqstring.html">TQString</a> that is null. On reading an empty
line the returned TQString is empty but not null.
<p> <p>See also <a href="ntqiodevice.html#readLine">TQIODevice::readLine</a>().
<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>.
<h3 class=fn><a href="ntqtextstream.html">TQTextStream</a>&nbsp;&amp; <a name="readRawBytes"></a>TQTextStream::readRawBytes ( char&nbsp;*&nbsp;s, uint&nbsp;len )
</h3>
Reads <em>len</em> bytes from the stream into <em>s</em> and returns a
reference to the stream.
<p> The buffer <em>s</em> must be preallocated.
<p> Note that no encoding is done by this function.
<p> <b>Warning:</b> The behavior of this function is undefined unless the
stream's encoding is set to Unicode or Latin1.
<p> <p>See also <a href="ntqiodevice.html#readBlock">TQIODevice::readBlock</a>().
<h3 class=fn>void <a name="reset"></a>TQTextStream::reset ()
</h3>
Resets the text stream.
<p> <ul>
<li> All flags are set to 0.
<li> The field width is set to 0.
<li> The fill character is set to ' ' (Space).
<li> The precision is set to 6.
</ul>
<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>().
<h3 class=fn>void <a name="setCodec"></a>TQTextStream::setCodec ( <a href="ntqtextcodec.html">TQTextCodec</a>&nbsp;*&nbsp;codec )
</h3>
Sets the codec for this stream to <em>codec</em>. Will not try to
autodetect Unicode.
<p> Note that this function should be called before any data is read
to/written from the stream.
<p> <p>See also <a href="#setEncoding">setEncoding</a>() and <a href="#codec">codec</a>().
<p>Example: <a href="qwerty-example.html#x402">qwerty/qwerty.cpp</a>.
<h3 class=fn>void <a name="setDevice"></a>TQTextStream::setDevice ( <a href="ntqiodevice.html">TQIODevice</a>&nbsp;*&nbsp;iod )
</h3>
Sets the IO device to <em>iod</em>.
<p> <p>See also <a href="#device">device</a>() and <a href="#unsetDevice">unsetDevice</a>().
<h3 class=fn>void <a name="setEncoding"></a>TQTextStream::setEncoding ( <a href="ntqtextstream.html#Encoding-enum">Encoding</a>&nbsp;e )
</h3>
Sets the encoding of this stream to <em>e</em>, where <em>e</em> is one of the
following values:
<center><table cellpadding="4" cellspacing="2" border="0">
<tr bgcolor="#a2c511"> <th valign="top">Encoding <th valign="top">Meaning
<tr bgcolor="#f0f0f0"> <td valign="top">Locale
<td valign="top">Uses local file format (Latin1 if locale is not set), but
autodetecting Unicode(utf16) on input.
<tr bgcolor="#d0d0d0"> <td valign="top">Unicode
<td valign="top">Uses Unicode(utf16) for input and output. Output will be
written in the order most efficient for the current platform
(i.e. the order used internally in <a href="ntqstring.html">TQString</a>).
<tr bgcolor="#f0f0f0"> <td valign="top">UnicodeUTF8
<td valign="top">Using Unicode(utf8) for input and output. If you use it for
input it will autodetect utf16 and use it instead of utf8.
<tr bgcolor="#d0d0d0"> <td valign="top">Latin1
<td valign="top">ISO-8859-1. Will not autodetect utf16.
<tr bgcolor="#f0f0f0"> <td valign="top">UnicodeNetworkOrder
<td valign="top">Uses network order Unicode(utf16) for input and output.
Useful when reading Unicode data that does not start with the
byte order marker.
<tr bgcolor="#d0d0d0"> <td valign="top">UnicodeReverse
<td valign="top">Uses reverse network order Unicode(utf16) for input and
output. Useful when reading Unicode data that does not start
with the byte order marker or when writing data that should be
read by buggy Windows applications.
<tr bgcolor="#f0f0f0"> <td valign="top">RawUnicode
<td valign="top">Like Unicode, but does not write the byte order marker nor
does it auto-detect the byte order. Useful only when writing to
non-persistent storage used by a single process.
</table></center>
<p> <a href="#Encoding-enum">Locale</a> and all Unicode encodings, except <a href="#Encoding-enum">RawUnicode</a>, will look
at the first two bytes in an input stream to determine the byte
order. The initial byte order marker will be stripped off before
data is read.
<p> Note that this function should be called before any data is read to
or written from the stream.
<p> <p>See also <a href="#setCodec">setCodec</a>().
<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>.
<h3 class=fn>int <a name="setf"></a>TQTextStream::setf ( int&nbsp;bits )
</h3>
<p> Sets the stream flag bits <em>bits</em>. Returns the previous stream
flags.
<p> Equivalent to <tt>flags( flags() | bits )</tt>.
<p> <p>See also <a href="#unsetf">unsetf</a>().
<h3 class=fn>int <a name="setf-2"></a>TQTextStream::setf ( int&nbsp;bits, int&nbsp;mask )
</h3>
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Sets the stream flag bits <em>bits</em> with a bit mask <em>mask</em>. Returns
the previous stream flags.
<p> Equivalent to <tt>flags( (flags() &amp; ~mask) | (bits &amp; mask) )</tt>.
<p> <p>See also <a href="#unsetf">unsetf</a>().
<h3 class=fn>void <a name="skipWhiteSpace"></a>TQTextStream::skipWhiteSpace ()
</h3>
Positions the read pointer at the first non-whitespace character.
<h3 class=fn>void <a name="unsetDevice"></a>TQTextStream::unsetDevice ()
</h3>
Unsets the IO device. Equivalent to <a href="#setDevice">setDevice</a>( 0 ).
<p> <p>See also <a href="#device">device</a>() and <a href="#setDevice">setDevice</a>().
<h3 class=fn>int <a name="unsetf"></a>TQTextStream::unsetf ( int&nbsp;bits )
</h3>
<p> Clears the stream flag bits <em>bits</em>. Returns the previous stream
flags.
<p> Equivalent to <tt>flags( flags() &amp; ~mask )</tt>.
<p> <p>See also <a href="#setf">setf</a>().
<h3 class=fn>int <a name="width"></a>TQTextStream::width () const
</h3>
<p> Returns the field width. The default value is 0.
<h3 class=fn>int <a name="width-2"></a>TQTextStream::width ( int&nbsp;w )
</h3>
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Sets the field width to <em>w</em>. Returns the previous field width.
<h3 class=fn><a href="ntqtextstream.html">TQTextStream</a>&nbsp;&amp; <a name="writeRawBytes"></a>TQTextStream::writeRawBytes ( const&nbsp;char&nbsp;*&nbsp;s, uint&nbsp;len )
</h3>
Writes the <em>len</em> bytes from <em>s</em> to the stream and returns a
reference to the stream.
<p> Note that no encoding is done by this function.
<p> <p>See also <a href="ntqiodevice.html#writeBlock">TQIODevice::writeBlock</a>().
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">TQt toolkit</a>.
Copyright &copy; 1995-2007
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>TQt 3.3.8</div>
</table></div></address></body>
</html>