[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/include/qtextstream.h:1 -->
|
---|
| 3 | <html>
|
---|
| 4 | <head>
|
---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
| 6 | <title>qtextstream.h Include File</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.h</h1>
|
---|
| 33 |
|
---|
| 34 | <p>This is the verbatim text of the qtextstream.h include file. It is provided only for illustration; the copyright remains with Trolltech.
|
---|
| 35 | <hr>
|
---|
| 36 | <pre>
|
---|
| 37 | /****************************************************************************
|
---|
| 38 | ** $Id: qtextstream-h.html 2051 2007-02-21 10:04:20Z chehrlic $
|
---|
| 39 | **
|
---|
| 40 | ** Definition of QTextStream class
|
---|
| 41 | **
|
---|
| 42 | ** Created : 940922
|
---|
| 43 | **
|
---|
| 44 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
|
---|
| 45 | **
|
---|
| 46 | ** This file is part of the tools module of the Qt GUI Toolkit.
|
---|
| 47 | **
|
---|
| 48 | ** This file may be distributed under the terms of the Q Public License
|
---|
| 49 | ** as defined by Trolltech ASA of Norway and appearing in the file
|
---|
| 50 | ** LICENSE.QPL included in the packaging of this file.
|
---|
| 51 | **
|
---|
| 52 | ** This file may be distributed and/or modified under the terms of the
|
---|
| 53 | ** GNU General Public License version 2 as published by the Free Software
|
---|
| 54 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
| 55 | ** packaging of this file.
|
---|
| 56 | **
|
---|
| 57 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
---|
| 58 | ** licenses may use this file in accordance with the Qt Commercial License
|
---|
| 59 | ** Agreement provided with the Software.
|
---|
| 60 | **
|
---|
| 61 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
| 62 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
| 63 | **
|
---|
| 64 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
| 65 | ** information about Qt Commercial License Agreements.
|
---|
| 66 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
---|
| 67 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
| 68 | **
|
---|
| 69 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
| 70 | ** not clear to you.
|
---|
| 71 | **
|
---|
| 72 | **********************************************************************/
|
---|
| 73 |
|
---|
| 74 | #ifndef QTEXTSTREAM_H
|
---|
| 75 | #define QTEXTSTREAM_H
|
---|
| 76 |
|
---|
| 77 | #ifndef QT_H
|
---|
| 78 | #include "qiodevice.h"
|
---|
| 79 | #include "qstring.h"
|
---|
| 80 | #include <stdio.h>
|
---|
| 81 | #endif // QT_H
|
---|
| 82 |
|
---|
| 83 | #ifndef QT_NO_TEXTSTREAM
|
---|
| 84 | class QTextCodec;
|
---|
| 85 | class QTextDecoder;
|
---|
| 86 |
|
---|
| 87 | class QTextStreamPrivate;
|
---|
| 88 |
|
---|
| 89 | class Q_EXPORT QTextStream // text stream class
|
---|
| 90 | {
|
---|
| 91 | public:
|
---|
| 92 | enum Encoding { Locale, Latin1, Unicode, UnicodeNetworkOrder,
|
---|
| 93 | UnicodeReverse, RawUnicode, UnicodeUTF8 };
|
---|
| 94 |
|
---|
| 95 | void setEncoding( Encoding );
|
---|
| 96 | #ifndef QT_NO_TEXTCODEC
|
---|
| 97 | void setCodec( QTextCodec* );
|
---|
| 98 | QTextCodec *codec();
|
---|
| 99 | #endif
|
---|
| 100 |
|
---|
| 101 | QTextStream();
|
---|
| 102 | QTextStream( QIODevice * );
|
---|
| 103 | QTextStream( QString*, int mode );
|
---|
| 104 | QTextStream( QString&, int mode ); // obsolete
|
---|
| 105 | QTextStream( QByteArray, int mode );
|
---|
| 106 | QTextStream( FILE *, int mode );
|
---|
| 107 | virtual ~QTextStream();
|
---|
| 108 |
|
---|
| 109 | QIODevice *device() const;
|
---|
| 110 | void setDevice( QIODevice * );
|
---|
| 111 | void unsetDevice();
|
---|
| 112 |
|
---|
| 113 | bool atEnd() const;
|
---|
| 114 | bool eof() const;
|
---|
| 115 |
|
---|
| 116 | QTextStream &operator>>( QChar & );
|
---|
| 117 | QTextStream &operator>>( char & );
|
---|
| 118 | QTextStream &operator>>( signed short & );
|
---|
| 119 | QTextStream &operator>>( unsigned short & );
|
---|
| 120 | QTextStream &operator>>( signed int & );
|
---|
| 121 | QTextStream &operator>>( unsigned int & );
|
---|
| 122 | QTextStream &operator>>( signed long & );
|
---|
| 123 | QTextStream &operator>>( unsigned long & );
|
---|
| 124 | QTextStream &operator>>( float & );
|
---|
| 125 | QTextStream &operator>>( double & );
|
---|
| 126 | QTextStream &operator>>( char * );
|
---|
| 127 | QTextStream &operator>>( QString & );
|
---|
| 128 | QTextStream &operator>>( QCString & );
|
---|
| 129 |
|
---|
| 130 | QTextStream &operator<<( QChar );
|
---|
| 131 | QTextStream &operator<<( char );
|
---|
| 132 | QTextStream &operator<<( signed short );
|
---|
| 133 | QTextStream &operator<<( unsigned short );
|
---|
| 134 | QTextStream &operator<<( signed int );
|
---|
| 135 | QTextStream &operator<<( unsigned int );
|
---|
| 136 | QTextStream &operator<<( signed long );
|
---|
| 137 | QTextStream &operator<<( unsigned long );
|
---|
| 138 | QTextStream &operator<<( float );
|
---|
| 139 | QTextStream &operator<<( double );
|
---|
| 140 | QTextStream &operator<<( const char* );
|
---|
| 141 | QTextStream &operator<<( const QString & );
|
---|
| 142 | QTextStream &operator<<( const QCString & );
|
---|
| 143 | QTextStream &operator<<( void * ); // any pointer
|
---|
| 144 |
|
---|
| 145 | QTextStream &readRawBytes( char *, uint len );
|
---|
| 146 | QTextStream &writeRawBytes( const char* , uint len );
|
---|
| 147 |
|
---|
| 148 | QString readLine();
|
---|
| 149 | QString read();
|
---|
| 150 | void skipWhiteSpace();
|
---|
| 151 |
|
---|
| 152 | enum {
|
---|
| 153 | skipws = 0x0001, // skip whitespace on input
|
---|
| 154 | left = 0x0002, // left-adjust output
|
---|
| 155 | right = 0x0004, // right-adjust output
|
---|
| 156 | internal = 0x0008, // pad after sign
|
---|
| 157 | bin = 0x0010, // binary format integer
|
---|
| 158 | oct = 0x0020, // octal format integer
|
---|
| 159 | dec = 0x0040, // decimal format integer
|
---|
| 160 | hex = 0x0080, // hex format integer
|
---|
| 161 | showbase = 0x0100, // show base indicator
|
---|
| 162 | showpoint = 0x0200, // force decimal point (float)
|
---|
| 163 | uppercase = 0x0400, // upper-case hex output
|
---|
| 164 | showpos = 0x0800, // add '+' to positive integers
|
---|
| 165 | scientific= 0x1000, // scientific float output
|
---|
| 166 | fixed = 0x2000 // fixed float output
|
---|
| 167 | };
|
---|
| 168 |
|
---|
| 169 | static const int basefield; // bin | oct | dec | hex
|
---|
| 170 | static const int adjustfield; // left | right | internal
|
---|
| 171 | static const int floatfield; // scientific | fixed
|
---|
| 172 |
|
---|
| 173 | int flags() const;
|
---|
| 174 | int flags( int f );
|
---|
| 175 | int setf( int bits );
|
---|
| 176 | int setf( int bits, int mask );
|
---|
| 177 | int unsetf( int bits );
|
---|
| 178 |
|
---|
| 179 | void reset();
|
---|
| 180 |
|
---|
| 181 | int width() const;
|
---|
| 182 | int width( int );
|
---|
| 183 | int fill() const;
|
---|
| 184 | int fill( int );
|
---|
| 185 | int precision() const;
|
---|
| 186 | int precision( int );
|
---|
| 187 |
|
---|
| 188 | private:
|
---|
| 189 | long input_int();
|
---|
| 190 | void init();
|
---|
| 191 | QTextStream &output_int( int, ulong, bool );
|
---|
| 192 | QIODevice *dev;
|
---|
| 193 |
|
---|
| 194 | int fflags;
|
---|
| 195 | int fwidth;
|
---|
| 196 | int fillchar;
|
---|
| 197 | int fprec;
|
---|
| 198 | bool doUnicodeHeader;
|
---|
| 199 | bool owndev;
|
---|
| 200 | QTextCodec *mapper;
|
---|
| 201 | QTextStreamPrivate * d;
|
---|
| 202 | QChar unused1; // ### remove in Qt 4.0
|
---|
| 203 | bool latin1;
|
---|
| 204 | bool internalOrder;
|
---|
| 205 | bool networkOrder;
|
---|
| 206 | void *unused2; // ### remove in Qt 4.0
|
---|
| 207 |
|
---|
| 208 | QChar eat_ws();
|
---|
| 209 | uint ts_getline( QChar* );
|
---|
| 210 | void ts_ungetc( QChar );
|
---|
| 211 | QChar ts_getc();
|
---|
| 212 | uint ts_getbuf( QChar*, uint );
|
---|
| 213 | void ts_putc(int);
|
---|
| 214 | void ts_putc(QChar);
|
---|
| 215 | bool ts_isspace(QChar);
|
---|
| 216 | bool ts_isdigit(QChar);
|
---|
| 217 | ulong input_bin();
|
---|
| 218 | ulong input_oct();
|
---|
| 219 | ulong input_dec();
|
---|
| 220 | ulong input_hex();
|
---|
| 221 | double input_double();
|
---|
| 222 | QTextStream &writeBlock( const char* p, uint len );
|
---|
| 223 | QTextStream &writeBlock( const QChar* p, uint len );
|
---|
| 224 |
|
---|
| 225 | private: // Disabled copy constructor and operator=
|
---|
| 226 | #if defined(Q_DISABLE_COPY)
|
---|
| 227 | QTextStream( const QTextStream & );
|
---|
| 228 | QTextStream &operator=( const QTextStream & );
|
---|
| 229 | #endif
|
---|
| 230 | };
|
---|
| 231 |
|
---|
| 232 | typedef QTextStream QTS;
|
---|
| 233 |
|
---|
| 234 | class Q_EXPORT QTextIStream : public QTextStream {
|
---|
| 235 | public:
|
---|
| 236 | QTextIStream( const QString* s ) :
|
---|
| 237 | QTextStream((QString*)s,IO_ReadOnly) { }
|
---|
| 238 | QTextIStream( QByteArray ba ) :
|
---|
| 239 | QTextStream(ba,IO_ReadOnly) { }
|
---|
| 240 | QTextIStream( FILE *f ) :
|
---|
| 241 | QTextStream(f,IO_ReadOnly) { }
|
---|
| 242 |
|
---|
| 243 | private: // Disabled copy constructor and operator=
|
---|
| 244 | #if defined(Q_DISABLE_COPY)
|
---|
| 245 | QTextIStream( const QTextIStream & );
|
---|
| 246 | QTextIStream &operator=( const QTextIStream & );
|
---|
| 247 | #endif
|
---|
| 248 | };
|
---|
| 249 |
|
---|
| 250 | class Q_EXPORT QTextOStream : public QTextStream {
|
---|
| 251 | public:
|
---|
| 252 | QTextOStream( QString* s ) :
|
---|
| 253 | QTextStream(s,IO_WriteOnly) { }
|
---|
| 254 | QTextOStream( QByteArray ba ) :
|
---|
| 255 | QTextStream(ba,IO_WriteOnly) { }
|
---|
| 256 | QTextOStream( FILE *f ) :
|
---|
| 257 | QTextStream(f,IO_WriteOnly) { }
|
---|
| 258 |
|
---|
| 259 | private: // Disabled copy constructor and operator=
|
---|
| 260 | #if defined(Q_DISABLE_COPY)
|
---|
| 261 | QTextOStream( const QTextOStream & );
|
---|
| 262 | QTextOStream &operator=( const QTextOStream & );
|
---|
| 263 | #endif
|
---|
| 264 | };
|
---|
| 265 |
|
---|
| 266 | /*****************************************************************************
|
---|
| 267 | QTextStream inline functions
|
---|
| 268 | *****************************************************************************/
|
---|
| 269 |
|
---|
| 270 | inline QIODevice *QTextStream::device() const
|
---|
| 271 | { return dev; }
|
---|
| 272 |
|
---|
| 273 | inline bool QTextStream::atEnd() const
|
---|
| 274 | { return dev ? dev->atEnd() : FALSE; }
|
---|
| 275 |
|
---|
| 276 | inline bool QTextStream::eof() const
|
---|
| 277 | { return atEnd(); }
|
---|
| 278 |
|
---|
| 279 | inline int QTextStream::flags() const
|
---|
| 280 | { return fflags; }
|
---|
| 281 |
|
---|
| 282 | inline int QTextStream::flags( int f )
|
---|
| 283 | { int oldf = fflags; fflags = f; return oldf; }
|
---|
| 284 |
|
---|
| 285 | inline int QTextStream::setf( int bits )
|
---|
| 286 | { int oldf = fflags; fflags |= bits; return oldf; }
|
---|
| 287 |
|
---|
| 288 | inline int QTextStream::setf( int bits, int mask )
|
---|
| 289 | { int oldf = fflags; fflags = (fflags & ~mask) | (bits & mask); return oldf; }
|
---|
| 290 |
|
---|
| 291 | inline int QTextStream::unsetf( int bits )
|
---|
| 292 | { int oldf = fflags; fflags &= ~bits; return oldf; }
|
---|
| 293 |
|
---|
| 294 | inline int QTextStream::width() const
|
---|
| 295 | { return fwidth; }
|
---|
| 296 |
|
---|
| 297 | inline int QTextStream::width( int w )
|
---|
| 298 | { int oldw = fwidth; fwidth = w; return oldw; }
|
---|
| 299 |
|
---|
| 300 | inline int QTextStream::fill() const
|
---|
| 301 | { return fillchar; }
|
---|
| 302 |
|
---|
| 303 | inline int QTextStream::fill( int f )
|
---|
| 304 | { int oldc = fillchar; fillchar = f; return oldc; }
|
---|
| 305 |
|
---|
| 306 | inline int QTextStream::precision() const
|
---|
| 307 | { return fprec; }
|
---|
| 308 |
|
---|
| 309 | inline int QTextStream::precision( int p )
|
---|
| 310 | { int oldp = fprec; fprec = p; return oldp; }
|
---|
| 311 |
|
---|
| 312 | /*!
|
---|
| 313 | Returns one character from the stream, or EOF.
|
---|
| 314 | */
|
---|
| 315 | inline QChar QTextStream::ts_getc()
|
---|
| 316 | { QChar r; return ( ts_getbuf( &r,1 ) == 1 ? r : QChar((ushort)0xffff) ); }
|
---|
| 317 |
|
---|
| 318 | /*****************************************************************************
|
---|
| 319 | QTextStream manipulators
|
---|
| 320 | *****************************************************************************/
|
---|
| 321 |
|
---|
| 322 | typedef QTextStream & (*QTSFUNC)(QTextStream &);// manipulator function
|
---|
| 323 | typedef int (QTextStream::*QTSMFI)(int); // manipulator w/int argument
|
---|
| 324 |
|
---|
| 325 | class Q_EXPORT QTSManip { // text stream manipulator
|
---|
| 326 | public:
|
---|
| 327 | QTSManip( QTSMFI m, int a ) { mf=m; arg=a; }
|
---|
| 328 | void exec( QTextStream &s ) { (s.*mf)(arg); }
|
---|
| 329 | private:
|
---|
| 330 | QTSMFI mf; // QTextStream member function
|
---|
| 331 | int arg; // member function argument
|
---|
| 332 | };
|
---|
| 333 |
|
---|
| 334 | Q_EXPORT inline QTextStream &operator>>( QTextStream &s, QTSFUNC f )
|
---|
| 335 | { return (*f)( s ); }
|
---|
| 336 |
|
---|
| 337 | Q_EXPORT inline QTextStream &operator<<( QTextStream &s, QTSFUNC f )
|
---|
| 338 | { return (*f)( s ); }
|
---|
| 339 |
|
---|
| 340 | Q_EXPORT inline QTextStream &operator<<( QTextStream &s, QTSManip m )
|
---|
| 341 | { m.exec(s); return s; }
|
---|
| 342 |
|
---|
| 343 | Q_EXPORT QTextStream &bin( QTextStream &s ); // set bin notation
|
---|
| 344 | Q_EXPORT QTextStream &oct( QTextStream &s ); // set oct notation
|
---|
| 345 | Q_EXPORT QTextStream &dec( QTextStream &s ); // set dec notation
|
---|
| 346 | Q_EXPORT QTextStream &hex( QTextStream &s ); // set hex notation
|
---|
| 347 | Q_EXPORT QTextStream &endl( QTextStream &s ); // insert EOL ('\n')
|
---|
| 348 | Q_EXPORT QTextStream &flush( QTextStream &s ); // flush output
|
---|
| 349 | Q_EXPORT QTextStream &ws( QTextStream &s ); // eat whitespace on input
|
---|
| 350 | Q_EXPORT QTextStream &reset( QTextStream &s ); // set default flags
|
---|
| 351 |
|
---|
| 352 | Q_EXPORT inline QTSManip qSetW( int w )
|
---|
| 353 | {
|
---|
| 354 | QTSMFI func = &QTextStream::width;
|
---|
| 355 | return QTSManip(func,w);
|
---|
| 356 | }
|
---|
| 357 |
|
---|
| 358 | Q_EXPORT inline QTSManip qSetFill( int f )
|
---|
| 359 | {
|
---|
| 360 | QTSMFI func = &QTextStream::fill;
|
---|
| 361 | return QTSManip(func,f);
|
---|
| 362 | }
|
---|
| 363 |
|
---|
| 364 | Q_EXPORT inline QTSManip qSetPrecision( int p )
|
---|
| 365 | {
|
---|
| 366 | QTSMFI func = &QTextStream::precision;
|
---|
| 367 | return QTSManip(func,p);
|
---|
| 368 | }
|
---|
| 369 |
|
---|
| 370 | #endif // QT_NO_TEXTSTREAM
|
---|
| 371 | #endif // QTEXTSTREAM_H
|
---|
| 372 | </pre>
|
---|
| 373 | <!-- eof -->
|
---|
| 374 | <p><address><hr><div align=center>
|
---|
| 375 | <table width=100% cellspacing=0 border=0><tr>
|
---|
| 376 | <td>Copyright © 2007
|
---|
| 377 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
| 378 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
| 379 | </table></div></address></body>
|
---|
| 380 | </html>
|
---|