source: trunk/doc/html/qtextstream-h.html@ 190

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

reference documentation added

File size: 12.7 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/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"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>qtextstream.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 &lt;stdio.h&gt;
81#endif // QT_H
82
83#ifndef QT_NO_TEXTSTREAM
84class QTextCodec;
85class QTextDecoder;
86
87class QTextStreamPrivate;
88
89class Q_EXPORT QTextStream // text stream class
90{
91public:
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&amp;, 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 &amp;operator&gt;&gt;( QChar &amp; );
117 QTextStream &amp;operator&gt;&gt;( char &amp; );
118 QTextStream &amp;operator&gt;&gt;( signed short &amp; );
119 QTextStream &amp;operator&gt;&gt;( unsigned short &amp; );
120 QTextStream &amp;operator&gt;&gt;( signed int &amp; );
121 QTextStream &amp;operator&gt;&gt;( unsigned int &amp; );
122 QTextStream &amp;operator&gt;&gt;( signed long &amp; );
123 QTextStream &amp;operator&gt;&gt;( unsigned long &amp; );
124 QTextStream &amp;operator&gt;&gt;( float &amp; );
125 QTextStream &amp;operator&gt;&gt;( double &amp; );
126 QTextStream &amp;operator&gt;&gt;( char * );
127 QTextStream &amp;operator&gt;&gt;( QString &amp; );
128 QTextStream &amp;operator&gt;&gt;( QCString &amp; );
129
130 QTextStream &amp;operator&lt;&lt;( QChar );
131 QTextStream &amp;operator&lt;&lt;( char );
132 QTextStream &amp;operator&lt;&lt;( signed short );
133 QTextStream &amp;operator&lt;&lt;( unsigned short );
134 QTextStream &amp;operator&lt;&lt;( signed int );
135 QTextStream &amp;operator&lt;&lt;( unsigned int );
136 QTextStream &amp;operator&lt;&lt;( signed long );
137 QTextStream &amp;operator&lt;&lt;( unsigned long );
138 QTextStream &amp;operator&lt;&lt;( float );
139 QTextStream &amp;operator&lt;&lt;( double );
140 QTextStream &amp;operator&lt;&lt;( const char* );
141 QTextStream &amp;operator&lt;&lt;( const QString &amp; );
142 QTextStream &amp;operator&lt;&lt;( const QCString &amp; );
143 QTextStream &amp;operator&lt;&lt;( void * ); // any pointer
144
145 QTextStream &amp;readRawBytes( char *, uint len );
146 QTextStream &amp;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
188private:
189 long input_int();
190 void init();
191 QTextStream &amp;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 &amp;writeBlock( const char* p, uint len );
223 QTextStream &amp;writeBlock( const QChar* p, uint len );
224
225private: // Disabled copy constructor and operator=
226#if defined(Q_DISABLE_COPY)
227 QTextStream( const QTextStream &amp; );
228 QTextStream &amp;operator=( const QTextStream &amp; );
229#endif
230};
231
232typedef QTextStream QTS;
233
234class Q_EXPORT QTextIStream : public QTextStream {
235public:
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
243private: // Disabled copy constructor and operator=
244#if defined(Q_DISABLE_COPY)
245 QTextIStream( const QTextIStream &amp; );
246 QTextIStream &amp;operator=( const QTextIStream &amp; );
247#endif
248};
249
250class Q_EXPORT QTextOStream : public QTextStream {
251public:
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
259private: // Disabled copy constructor and operator=
260#if defined(Q_DISABLE_COPY)
261 QTextOStream( const QTextOStream &amp; );
262 QTextOStream &amp;operator=( const QTextOStream &amp; );
263#endif
264};
265
266/*****************************************************************************
267 QTextStream inline functions
268 *****************************************************************************/
269
270inline QIODevice *QTextStream::device() const
271{ return dev; }
272
273inline bool QTextStream::atEnd() const
274{ return dev ? dev-&gt;atEnd() : FALSE; }
275
276inline bool QTextStream::eof() const
277{ return atEnd(); }
278
279inline int QTextStream::flags() const
280{ return fflags; }
281
282inline int QTextStream::flags( int f )
283{ int oldf = fflags; fflags = f; return oldf; }
284
285inline int QTextStream::setf( int bits )
286{ int oldf = fflags; fflags |= bits; return oldf; }
287
288inline int QTextStream::setf( int bits, int mask )
289{ int oldf = fflags; fflags = (fflags &amp; ~mask) | (bits &amp; mask); return oldf; }
290
291inline int QTextStream::unsetf( int bits )
292{ int oldf = fflags; fflags &amp;= ~bits; return oldf; }
293
294inline int QTextStream::width() const
295{ return fwidth; }
296
297inline int QTextStream::width( int w )
298{ int oldw = fwidth; fwidth = w; return oldw; }
299
300inline int QTextStream::fill() const
301{ return fillchar; }
302
303inline int QTextStream::fill( int f )
304{ int oldc = fillchar; fillchar = f; return oldc; }
305
306inline int QTextStream::precision() const
307{ return fprec; }
308
309inline 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*/
315inline QChar QTextStream::ts_getc()
316{ QChar r; return ( ts_getbuf( &amp;r,1 ) == 1 ? r : QChar((ushort)0xffff) ); }
317
318/*****************************************************************************
319 QTextStream manipulators
320 *****************************************************************************/
321
322typedef QTextStream &amp; (*QTSFUNC)(QTextStream &amp;);// manipulator function
323typedef int (QTextStream::*QTSMFI)(int); // manipulator w/int argument
324
325class Q_EXPORT QTSManip { // text stream manipulator
326public:
327 QTSManip( QTSMFI m, int a ) { mf=m; arg=a; }
328 void exec( QTextStream &amp;s ) { (s.*mf)(arg); }
329private:
330 QTSMFI mf; // QTextStream member function
331 int arg; // member function argument
332};
333
334Q_EXPORT inline QTextStream &amp;operator&gt;&gt;( QTextStream &amp;s, QTSFUNC f )
335{ return (*f)( s ); }
336
337Q_EXPORT inline QTextStream &amp;operator&lt;&lt;( QTextStream &amp;s, QTSFUNC f )
338{ return (*f)( s ); }
339
340Q_EXPORT inline QTextStream &amp;operator&lt;&lt;( QTextStream &amp;s, QTSManip m )
341{ m.exec(s); return s; }
342
343Q_EXPORT QTextStream &amp;bin( QTextStream &amp;s ); // set bin notation
344Q_EXPORT QTextStream &amp;oct( QTextStream &amp;s ); // set oct notation
345Q_EXPORT QTextStream &amp;dec( QTextStream &amp;s ); // set dec notation
346Q_EXPORT QTextStream &amp;hex( QTextStream &amp;s ); // set hex notation
347Q_EXPORT QTextStream &amp;endl( QTextStream &amp;s ); // insert EOL ('\n')
348Q_EXPORT QTextStream &amp;flush( QTextStream &amp;s ); // flush output
349Q_EXPORT QTextStream &amp;ws( QTextStream &amp;s ); // eat whitespace on input
350Q_EXPORT QTextStream &amp;reset( QTextStream &amp;s ); // set default flags
351
352Q_EXPORT inline QTSManip qSetW( int w )
353{
354 QTSMFI func = &amp;QTextStream::width;
355 return QTSManip(func,w);
356}
357
358Q_EXPORT inline QTSManip qSetFill( int f )
359{
360 QTSMFI func = &amp;QTextStream::fill;
361 return QTSManip(func,f);
362}
363
364Q_EXPORT inline QTSManip qSetPrecision( int p )
365{
366 QTSMFI func = &amp;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 &copy; 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>
Note: See TracBrowser for help on using the repository browser.