[190] | 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"><!--
|
---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
| 9 | a:link { color: #004faf; text-decoration: none }
|
---|
| 10 | a:visited { color: #672967; text-decoration: none }
|
---|
| 11 | body { 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 Classes</font></a>
|
---|
| 23 | | <a href="mainclasses.html">
|
---|
| 24 | <font color="#004faf">Main 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 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
|
---|
| 35 | and 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 <<a href="qtextstream-h.html">qtextstream.h</a>></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 e )</li>
|
---|
| 45 | <li class=fn>void <a href="#setCodec"><b>setCodec</b></a> ( QTextCodec * 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 * iod )</li>
|
---|
| 49 | <li class=fn><a href="#QTextStream-3"><b>QTextStream</b></a> ( QString * str, int filemode )</li>
|
---|
| 50 | <li class=fn>QTextStream ( QString & str, int filemode ) <em>(obsolete)</em></li>
|
---|
| 51 | <li class=fn><a href="#QTextStream-5"><b>QTextStream</b></a> ( QByteArray a, int mode )</li>
|
---|
| 52 | <li class=fn><a href="#QTextStream-6"><b>QTextStream</b></a> ( FILE * fh, int 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 * 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 <em>(obsolete)</em></li>
|
---|
| 59 | <li class=fn>QTextStream & <a href="#operator-gt-gt"><b>operator>></b></a> ( QChar & c )</li>
|
---|
| 60 | <li class=fn>QTextStream & <a href="#operator-gt-gt-2"><b>operator>></b></a> ( char & c )</li>
|
---|
| 61 | <li class=fn>QTextStream & <a href="#operator-gt-gt-3"><b>operator>></b></a> ( signed short & i )</li>
|
---|
| 62 | <li class=fn>QTextStream & <a href="#operator-gt-gt-4"><b>operator>></b></a> ( unsigned short & i )</li>
|
---|
| 63 | <li class=fn>QTextStream & <a href="#operator-gt-gt-5"><b>operator>></b></a> ( signed int & i )</li>
|
---|
| 64 | <li class=fn>QTextStream & <a href="#operator-gt-gt-6"><b>operator>></b></a> ( unsigned int & i )</li>
|
---|
| 65 | <li class=fn>QTextStream & <a href="#operator-gt-gt-7"><b>operator>></b></a> ( signed long & i )</li>
|
---|
| 66 | <li class=fn>QTextStream & <a href="#operator-gt-gt-8"><b>operator>></b></a> ( unsigned long & i )</li>
|
---|
| 67 | <li class=fn>QTextStream & <a href="#operator-gt-gt-9"><b>operator>></b></a> ( float & f )</li>
|
---|
| 68 | <li class=fn>QTextStream & <a href="#operator-gt-gt-a"><b>operator>></b></a> ( double & f )</li>
|
---|
| 69 | <li class=fn>QTextStream & <a href="#operator-gt-gt-b"><b>operator>></b></a> ( char * s )</li>
|
---|
| 70 | <li class=fn>QTextStream & <a href="#operator-gt-gt-c"><b>operator>></b></a> ( QString & str )</li>
|
---|
| 71 | <li class=fn>QTextStream & <a href="#operator-gt-gt-d"><b>operator>></b></a> ( QCString & str )</li>
|
---|
| 72 | <li class=fn>QTextStream & <a href="#operator-lt-lt"><b>operator<<</b></a> ( QChar c )</li>
|
---|
| 73 | <li class=fn>QTextStream & <a href="#operator-lt-lt-2"><b>operator<<</b></a> ( char c )</li>
|
---|
| 74 | <li class=fn>QTextStream & <a href="#operator-lt-lt-3"><b>operator<<</b></a> ( signed short i )</li>
|
---|
| 75 | <li class=fn>QTextStream & <a href="#operator-lt-lt-4"><b>operator<<</b></a> ( unsigned short i )</li>
|
---|
| 76 | <li class=fn>QTextStream & <a href="#operator-lt-lt-5"><b>operator<<</b></a> ( signed int i )</li>
|
---|
| 77 | <li class=fn>QTextStream & <a href="#operator-lt-lt-6"><b>operator<<</b></a> ( unsigned int i )</li>
|
---|
| 78 | <li class=fn>QTextStream & <a href="#operator-lt-lt-7"><b>operator<<</b></a> ( signed long i )</li>
|
---|
| 79 | <li class=fn>QTextStream & <a href="#operator-lt-lt-8"><b>operator<<</b></a> ( unsigned long i )</li>
|
---|
| 80 | <li class=fn>QTextStream & <a href="#operator-lt-lt-9"><b>operator<<</b></a> ( float f )</li>
|
---|
| 81 | <li class=fn>QTextStream & <a href="#operator-lt-lt-a"><b>operator<<</b></a> ( double f )</li>
|
---|
| 82 | <li class=fn>QTextStream & <a href="#operator-lt-lt-b"><b>operator<<</b></a> ( const char * s )</li>
|
---|
| 83 | <li class=fn>QTextStream & <a href="#operator-lt-lt-c"><b>operator<<</b></a> ( const QString & s )</li>
|
---|
| 84 | <li class=fn>QTextStream & <a href="#operator-lt-lt-d"><b>operator<<</b></a> ( const QCString & s )</li>
|
---|
| 85 | <li class=fn>QTextStream & <a href="#operator-lt-lt-e"><b>operator<<</b></a> ( void * ptr )</li>
|
---|
| 86 | <li class=fn>QTextStream & <a href="#readRawBytes"><b>readRawBytes</b></a> ( char * s, uint len )</li>
|
---|
| 87 | <li class=fn>QTextStream & <a href="#writeRawBytes"><b>writeRawBytes</b></a> ( const char * s, uint 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 f )</li>
|
---|
| 93 | <li class=fn>int <a href="#setf"><b>setf</b></a> ( int bits )</li>
|
---|
| 94 | <li class=fn>int <a href="#setf-2"><b>setf</b></a> ( int bits, int mask )</li>
|
---|
| 95 | <li class=fn>int <a href="#unsetf"><b>unsetf</b></a> ( int 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 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 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 p )</li>
|
---|
| 103 | </ul>
|
---|
| 104 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
| 105 |
|
---|
| 106 |
|
---|
| 107 |
|
---|
| 108 | The QTextStream class provides basic functions for reading
|
---|
| 109 | and 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
|
---|
| 114 | similar 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>
|
---|
| 127 | to 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
|
---|
| 132 | integers in the stream are in decimal, octal, hexadecimal or
|
---|
| 133 | binary format when reading from the stream. In particular, a
|
---|
| 134 | leading '0' signifies octal, i.e. the sequence "0100" will be
|
---|
| 135 | interpreted as 64.
|
---|
| 136 | <p> The QTextStream class reads and writes text; it is not appropriate
|
---|
| 137 | for 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
|
---|
| 139 | the local 8-bit encoding. This can be changed using the
|
---|
| 140 | <a href="#setEncoding">setEncoding</a>() method. For input, the QTextStream will auto-detect
|
---|
| 141 | standard Unicode "byte order marked" text files; otherwise the
|
---|
| 142 | local 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
|
---|
| 145 | TRUE. Data can be read into variables of the appropriate type
|
---|
| 146 | using the <a href="#operator-gt-gt">operator>></a>() overloads, or read in its entirety into a
|
---|
| 147 | single 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>().
|
---|
| 149 | You can set flags for the stream using <a href="#flags">flags</a>() or <a href="#setf">setf</a>(). The
|
---|
| 150 | 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>()
|
---|
| 151 | to 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>
|
---|
| 170 | Constructs 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> * iod )
|
---|
| 173 | </h3>
|
---|
| 174 | Constructs 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> * str, int filemode )
|
---|
| 177 | </h3>
|
---|
| 178 | Constructs 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
|
---|
| 179 | passed 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>(),
|
---|
| 181 | this 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( &str, <a href="qfile.html#open">IO_WriteOnly</a> );
|
---|
| 186 | ts << "pi = " << 3.14; // str == "pi = 3.14"
|
---|
| 187 | </pre>
|
---|
| 188 |
|
---|
| 189 | <p> Writing data to the text stream will modify the contents of the
|
---|
| 190 | string. The string will be expanded when data is written beyond
|
---|
| 191 | the 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( &str, IO_WriteOnly );
|
---|
| 195 | ts << "2+2 = " << 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> & str, int 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>*
|
---|
| 204 | parameter.
|
---|
| 205 |
|
---|
| 206 | <h3 class=fn><a name="QTextStream-5"></a>QTextStream::QTextStream ( <a href="qbytearray.html">QByteArray</a> a, int mode )
|
---|
| 207 | </h3>
|
---|
| 208 | Constructs a text stream that operates on the byte array, <em>a</em>,
|
---|
| 209 | through an internal <a href="qbuffer.html">QBuffer</a> device. The <em>mode</em> argument is passed
|
---|
| 210 | to 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 << "pi = " << 3.14 << '\0'; // array == "pi = 3.14"
|
---|
| 216 | </pre>
|
---|
| 217 |
|
---|
| 218 | <p> Writing data to the text stream will modify the contents of the
|
---|
| 219 | array. The array will be expanded when data is written beyond the
|
---|
| 220 | end 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( &buf );
|
---|
| 227 | ts << "pi = " << 3.14 << '\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 * fh, int mode )
|
---|
| 233 | </h3>
|
---|
| 234 | Constructs 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
|
---|
| 236 | passed 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
|
---|
| 238 | is also used for another variable of a different type, some
|
---|
| 239 | linkers may confuse the two variables, which will often cause
|
---|
| 240 | crashes.
|
---|
| 241 |
|
---|
| 242 | <h3 class=fn><a name="~QTextStream"></a>QTextStream::~QTextStream ()<tt> [virtual]</tt>
|
---|
| 243 | </h3>
|
---|
| 244 | Destroys 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
|
---|
| 251 | the stream or file) or if there is no IO device set; otherwise
|
---|
| 252 | returns 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> * <a name="codec"></a>QTextStream::codec ()
|
---|
| 257 | </h3>
|
---|
| 258 | Returns 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> * <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 f )
|
---|
| 281 | </h3>
|
---|
| 282 | This 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
|
---|
| 310 | input base is octal if the value starts with 0, hexadecimal if it
|
---|
| 311 | starts with 0x, binary if it starts with 0b, and decimal
|
---|
| 312 | otherwise.
|
---|
| 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 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> & <a name="operator-lt-lt"></a>QTextStream::operator<< ( <a href="qchar.html">QChar</a> c )
|
---|
| 323 | </h3>
|
---|
| 324 | Writes character <tt>char</tt> to the stream and returns a reference to
|
---|
| 325 | the stream.
|
---|
| 326 | <p> The character <em>c</em> is assumed to be Latin1 encoded independent of
|
---|
| 327 | the Encoding set for the QTextStream.
|
---|
| 328 |
|
---|
| 329 | <h3 class=fn><a href="qtextstream.html">QTextStream</a> & <a name="operator-lt-lt-2"></a>QTextStream::operator<< ( char c )
|
---|
| 330 | </h3>
|
---|
| 331 | This 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
|
---|
| 333 | stream.
|
---|
| 334 |
|
---|
| 335 | <h3 class=fn><a href="qtextstream.html">QTextStream</a> & <a name="operator-lt-lt-3"></a>QTextStream::operator<< ( signed short i )
|
---|
| 336 | </h3>
|
---|
| 337 | This 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
|
---|
| 339 | reference to the stream.
|
---|
| 340 |
|
---|
| 341 | <h3 class=fn><a href="qtextstream.html">QTextStream</a> & <a name="operator-lt-lt-4"></a>QTextStream::operator<< ( unsigned short i )
|
---|
| 342 | </h3>
|
---|
| 343 | This 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
|
---|
| 345 | returns a reference to the stream.
|
---|
| 346 |
|
---|
| 347 | <h3 class=fn><a href="qtextstream.html">QTextStream</a> & <a name="operator-lt-lt-5"></a>QTextStream::operator<< ( signed int i )
|
---|
| 348 | </h3>
|
---|
| 349 | This 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
|
---|
| 351 | stream.
|
---|
| 352 |
|
---|
| 353 | <h3 class=fn><a href="qtextstream.html">QTextStream</a> & <a name="operator-lt-lt-6"></a>QTextStream::operator<< ( unsigned int i )
|
---|
| 354 | </h3>
|
---|
| 355 | This 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
|
---|
| 357 | reference to the stream.
|
---|
| 358 |
|
---|
| 359 | <h3 class=fn><a href="qtextstream.html">QTextStream</a> & <a name="operator-lt-lt-7"></a>QTextStream::operator<< ( signed long i )
|
---|
| 360 | </h3>
|
---|
| 361 | This 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
|
---|
| 363 | to the stream.
|
---|
| 364 |
|
---|
| 365 | <h3 class=fn><a href="qtextstream.html">QTextStream</a> & <a name="operator-lt-lt-8"></a>QTextStream::operator<< ( unsigned long i )
|
---|
| 366 | </h3>
|
---|
| 367 | This 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
|
---|
| 369 | returns a reference to the stream.
|
---|
| 370 |
|
---|
| 371 | <h3 class=fn><a href="qtextstream.html">QTextStream</a> & <a name="operator-lt-lt-9"></a>QTextStream::operator<< ( float f )
|
---|
| 372 | </h3>
|
---|
| 373 | This 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
|
---|
| 375 | the stream.
|
---|
| 376 |
|
---|
| 377 | <h3 class=fn><a href="qtextstream.html">QTextStream</a> & <a name="operator-lt-lt-a"></a>QTextStream::operator<< ( double f )
|
---|
| 378 | </h3>
|
---|
| 379 | This 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
|
---|
| 381 | the stream.
|
---|
| 382 |
|
---|
| 383 | <h3 class=fn><a href="qtextstream.html">QTextStream</a> & <a name="operator-lt-lt-b"></a>QTextStream::operator<< ( const char * s )
|
---|
| 384 | </h3>
|
---|
| 385 | This 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
|
---|
| 387 | stream.
|
---|
| 388 | <p> The string <em>s</em> is assumed to be Latin1 encoded independent of the
|
---|
| 389 | Encoding set for the QTextStream.
|
---|
| 390 |
|
---|
| 391 | <h3 class=fn><a href="qtextstream.html">QTextStream</a> & <a name="operator-lt-lt-c"></a>QTextStream::operator<< ( const <a href="qstring.html">QString</a> & s )
|
---|
| 392 | </h3>
|
---|
| 393 | This 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> & <a name="operator-lt-lt-d"></a>QTextStream::operator<< ( const <a href="qcstring.html">QCString</a> & s )
|
---|
| 397 | </h3>
|
---|
| 398 | This 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
|
---|
| 401 | Encoding set for the QTextStream.
|
---|
| 402 |
|
---|
| 403 | <h3 class=fn><a href="qtextstream.html">QTextStream</a> & <a name="operator-lt-lt-e"></a>QTextStream::operator<< ( void * ptr )
|
---|
| 404 | </h3>
|
---|
| 405 | This 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
|
---|
| 407 | stream.
|
---|
| 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> & <a name="operator-gt-gt"></a>QTextStream::operator>> ( <a href="qchar.html">QChar</a> & c )
|
---|
| 411 | </h3>
|
---|
| 412 | Reads a char <em>c</em> from the stream and returns a reference to the
|
---|
| 413 | stream. Note that whitespace is <em>not</em> skipped.
|
---|
| 414 |
|
---|
| 415 | <h3 class=fn><a href="qtextstream.html">QTextStream</a> & <a name="operator-gt-gt-2"></a>QTextStream::operator>> ( char & c )
|
---|
| 416 | </h3>
|
---|
| 417 | This 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
|
---|
| 419 | stream. Note that whitespace is skipped.
|
---|
| 420 |
|
---|
| 421 | <h3 class=fn><a href="qtextstream.html">QTextStream</a> & <a name="operator-gt-gt-3"></a>QTextStream::operator>> ( signed short & i )
|
---|
| 422 | </h3>
|
---|
| 423 | This 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
|
---|
| 425 | reference to the stream. See <a href="#flags">flags</a>() for an explanation of the
|
---|
| 426 | expected input format.
|
---|
| 427 |
|
---|
| 428 | <h3 class=fn><a href="qtextstream.html">QTextStream</a> & <a name="operator-gt-gt-4"></a>QTextStream::operator>> ( unsigned short & i )
|
---|
| 429 | </h3>
|
---|
| 430 | This 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
|
---|
| 432 | returns a reference to the stream. See <a href="#flags">flags</a>() for an explanation
|
---|
| 433 | of the expected input format.
|
---|
| 434 |
|
---|
| 435 | <h3 class=fn><a href="qtextstream.html">QTextStream</a> & <a name="operator-gt-gt-5"></a>QTextStream::operator>> ( signed int & i )
|
---|
| 436 | </h3>
|
---|
| 437 | This 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
|
---|
| 439 | to the stream. See <a href="#flags">flags</a>() for an explanation of the expected
|
---|
| 440 | input format.
|
---|
| 441 |
|
---|
| 442 | <h3 class=fn><a href="qtextstream.html">QTextStream</a> & <a name="operator-gt-gt-6"></a>QTextStream::operator>> ( unsigned int & i )
|
---|
| 443 | </h3>
|
---|
| 444 | This 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
|
---|
| 446 | reference to the stream. See <a href="#flags">flags</a>() for an explanation of the
|
---|
| 447 | expected input format.
|
---|
| 448 |
|
---|
| 449 | <h3 class=fn><a href="qtextstream.html">QTextStream</a> & <a name="operator-gt-gt-7"></a>QTextStream::operator>> ( signed long & i )
|
---|
| 450 | </h3>
|
---|
| 451 | This 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
|
---|
| 453 | reference to the stream. See <a href="#flags">flags</a>() for an explanation of the
|
---|
| 454 | expected input format.
|
---|
| 455 |
|
---|
| 456 | <h3 class=fn><a href="qtextstream.html">QTextStream</a> & <a name="operator-gt-gt-8"></a>QTextStream::operator>> ( unsigned long & i )
|
---|
| 457 | </h3>
|
---|
| 458 | This 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
|
---|
| 460 | reference to the stream. See <a href="#flags">flags</a>() for an explanation of the
|
---|
| 461 | expected input format.
|
---|
| 462 |
|
---|
| 463 | <h3 class=fn><a href="qtextstream.html">QTextStream</a> & <a name="operator-gt-gt-9"></a>QTextStream::operator>> ( float & f )
|
---|
| 464 | </h3>
|
---|
| 465 | This 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
|
---|
| 467 | the stream. See <a href="#flags">flags</a>() for an explanation of the expected input
|
---|
| 468 | format.
|
---|
| 469 |
|
---|
| 470 | <h3 class=fn><a href="qtextstream.html">QTextStream</a> & <a name="operator-gt-gt-a"></a>QTextStream::operator>> ( double & f )
|
---|
| 471 | </h3>
|
---|
| 472 | This 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
|
---|
| 474 | the stream. See <a href="#flags">flags</a>() for an explanation of the expected input
|
---|
| 475 | format.
|
---|
| 476 |
|
---|
| 477 | <h3 class=fn><a href="qtextstream.html">QTextStream</a> & <a name="operator-gt-gt-b"></a>QTextStream::operator>> ( char * s )
|
---|
| 478 | </h3>
|
---|
| 479 | This 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
|
---|
| 481 | to 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> & <a name="operator-gt-gt-c"></a>QTextStream::operator>> ( <a href="qstring.html">QString</a> & str )
|
---|
| 485 | </h3>
|
---|
| 486 | This 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
|
---|
| 488 | to 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> & <a name="operator-gt-gt-d"></a>QTextStream::operator>> ( <a href="qcstring.html">QCString</a> & str )
|
---|
| 492 | </h3>
|
---|
| 493 | This 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
|
---|
| 495 | to 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 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>
|
---|
| 511 | Reads the entire stream from the current position, and returns a string
|
---|
| 512 | containing 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>
|
---|
| 518 | Reads a line from the stream and returns a string containing the
|
---|
| 519 | text.
|
---|
| 520 | <p> The returned string does not contain any trailing newline or
|
---|
| 521 | carriage 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
|
---|
| 523 | of the line.
|
---|
| 524 | <p> On EOF you will get a <a href="qstring.html">QString</a> that is null. On reading an empty
|
---|
| 525 | line 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> & <a name="readRawBytes"></a>QTextStream::readRawBytes ( char * s, uint len )
|
---|
| 530 | </h3>
|
---|
| 531 | Reads <em>len</em> bytes from the stream into <em>s</em> and returns a
|
---|
| 532 | reference 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
|
---|
| 536 | stream'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>
|
---|
| 541 | Resets 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> * codec )
|
---|
| 551 | </h3>
|
---|
| 552 | Sets the codec for this stream to <em>codec</em>. Will not try to
|
---|
| 553 | autodetect Unicode.
|
---|
| 554 | <p> Note that this function should be called before any data is read
|
---|
| 555 | to/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> * iod )
|
---|
| 560 | </h3>
|
---|
| 561 | Sets 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> e )
|
---|
| 565 | </h3>
|
---|
| 566 | Sets the encoding of this stream to <em>e</em>, where <em>e</em> is one of the
|
---|
| 567 | following 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
|
---|
| 572 | autodetecting 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
|
---|
| 575 | written 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
|
---|
| 579 | input 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.
|
---|
| 584 | Useful when reading Unicode data that does not start with the
|
---|
| 585 | byte order marker.
|
---|
| 586 | <tr bgcolor="#d0d0d0"> <td valign="top">UnicodeReverse
|
---|
| 587 | <td valign="top">Uses reverse network order Unicode(utf16) for input and
|
---|
| 588 | output. Useful when reading Unicode data that does not start
|
---|
| 589 | with the byte order marker or when writing data that should be
|
---|
| 590 | read 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
|
---|
| 593 | does it auto-detect the byte order. Useful only when writing to
|
---|
| 594 | non-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
|
---|
| 597 | at the first two bytes in an input stream to determine the byte
|
---|
| 598 | order. The initial byte order marker will be stripped off before
|
---|
| 599 | data is read.
|
---|
| 600 | <p> Note that this function should be called before any data is read to
|
---|
| 601 | or 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 bits )
|
---|
| 606 | </h3>
|
---|
| 607 |
|
---|
| 608 | <p> Sets the stream flag bits <em>bits</em>. Returns the previous stream
|
---|
| 609 | flags.
|
---|
| 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 bits, int 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
|
---|
| 618 | the previous stream flags.
|
---|
| 619 | <p> Equivalent to <tt>flags( (flags() & ~mask) | (bits & 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>
|
---|
| 624 | Positions the read pointer at the first non-whitespace character.
|
---|
| 625 |
|
---|
| 626 | <h3 class=fn>void <a name="unsetDevice"></a>QTextStream::unsetDevice ()
|
---|
| 627 | </h3>
|
---|
| 628 | Unsets 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 bits )
|
---|
| 632 | </h3>
|
---|
| 633 |
|
---|
| 634 | <p> Clears the stream flag bits <em>bits</em>. Returns the previous stream
|
---|
| 635 | flags.
|
---|
| 636 | <p> Equivalent to <tt>flags( flags() & ~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 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> & <a name="writeRawBytes"></a>QTextStream::writeRawBytes ( const char * s, uint len )
|
---|
| 651 | </h3>
|
---|
| 652 | Writes the <em>len</em> bytes from <em>s</em> to the stream and returns a
|
---|
| 653 | reference 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>
|
---|
| 659 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
| 660 | Copyright © 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 © 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>
|
---|