Chameleon

Chameleon Svn Source Tree

Root/branches/xZenu/src/util/doxygen/qtools/qtextstream.h

Source at commit 1322 created 12 years 8 months ago.
By meklort, Add doxygen to utils folder
1/****************************************************************************
2**
3**
4** Definition of QTextStream class
5**
6** Created : 940922
7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9**
10** This file is part of the tools module of the Qt GUI Toolkit.
11**
12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file.
15**
16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software.
24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37
38#ifndef QTEXTSTREAM_H
39#define QTEXTSTREAM_H
40
41#ifndef QT_H
42#include "qiodevice.h"
43#include "qstring.h"
44#include <stdio.h>
45#endif // QT_H
46
47#ifndef QT_NO_TEXTSTREAM
48class QTextCodec;
49class QTextDecoder;
50
51class QTextStreamPrivate;
52
53class Q_EXPORT QTextStream// text stream class
54{
55public:
56 enum Encoding { Locale, Latin1, Unicode, UnicodeNetworkOrder,
57 UnicodeReverse, RawUnicode, UnicodeUTF8 };
58
59 voidsetEncoding( Encoding );
60#ifndef QT_NO_TEXTCODEC
61 voidsetCodec( QTextCodec* );
62#endif
63
64 // Encoding encoding() const { return cmode; }
65
66 QTextStream();
67 QTextStream( QIODevice * );
68 QTextStream( QString*, int mode );
69 QTextStream( QString&, int mode );// obsolete
70 QTextStream( QByteArray, int mode );
71 QTextStream( FILE *, int mode );
72 virtual ~QTextStream();
73
74 QIODevice*device() const;
75 void setDevice( QIODevice * );
76 void unsetDevice();
77
78 bool atEnd() const;
79 bool eof() const;
80
81 QTextStream &operator>>( QChar & );
82 QTextStream &operator>>( char & );
83 QTextStream &operator>>( signed short & );
84 QTextStream &operator>>( unsigned short & );
85 QTextStream &operator>>( signed int & );
86 QTextStream &operator>>( unsigned int & );
87 QTextStream &operator>>( signed long & );
88 QTextStream &operator>>( unsigned long & );
89 QTextStream &operator>>( float & );
90 QTextStream &operator>>( double & );
91 QTextStream &operator>>( char * );
92 QTextStream &operator>>( QString & );
93 QTextStream &operator>>( QCString & );
94
95 QTextStream &operator<<( QChar );
96 QTextStream &operator<<( char );
97 QTextStream &operator<<( signed short );
98 QTextStream &operator<<( unsigned short );
99 QTextStream &operator<<( signed int );
100 QTextStream &operator<<( unsigned int );
101 QTextStream &operator<<( signed long );
102 QTextStream &operator<<( unsigned long );
103 QTextStream &operator<<( float );
104 QTextStream &operator<<( double );
105 QTextStream &operator<<( const char* );
106 QTextStream &operator<<( const QString & );
107 QTextStream &operator<<( const QCString & );
108 QTextStream &operator<<( void * );// any pointer
109
110 QTextStream &readRawBytes( char *, uint len );
111 QTextStream &writeRawBytes( const char* , uint len );
112
113 QStringreadLine();
114 QStringread();
115 voidskipWhiteSpace();
116
117 enum {
118skipws = 0x0001,// skip whitespace on input
119left = 0x0002,// left-adjust output
120right = 0x0004,// right-adjust output
121internal = 0x0008,// pad after sign
122bin = 0x0010,// binary format integer
123oct = 0x0020,// octal format integer
124dec = 0x0040,// decimal format integer
125hex = 0x0080,// hex format integer
126showbase = 0x0100,// show base indicator
127showpoint = 0x0200,// force decimal point (float)
128uppercase = 0x0400,// upper-case hex output
129showpos = 0x0800,// add '+' to positive integers
130scientific= 0x1000,// scientific float output
131fixed = 0x2000// fixed float output
132 };
133
134 static const int basefield;// bin | oct | dec | hex
135 static const int adjustfield;// left | right | internal
136 static const int floatfield;// scientific | fixed
137
138 int flags() const;
139 int flags( int f );
140 int setf( int bits );
141 int setf( int bits, int mask );
142 int unsetf( int bits );
143
144 void reset();
145
146 int width()const;
147 int width( int );
148 int fill()const;
149 int fill( int );
150 int precision()const;
151 int precision( int );
152
153private:
154 long input_int();
155 voidinit();
156 QTextStream &output_int( int, ulong, bool );
157 QIODevice*dev;
158 boolisNetworkOrder() { return internalOrder == QChar::networkOrdered(); }
159
160 int fflags;
161 int fwidth;
162 int fillchar;
163 int fprec;
164 bool fstrm;
165 bool owndev;
166 QTextCodec *mapper;
167 QTextStreamPrivate * d;
168 QCharungetcBuf;
169 boollatin1;
170 bool internalOrder;
171 booldoUnicodeHeader;
172 void*reserved_ptr;
173
174 QChareat_ws();
175 voidts_ungetc( QChar );
176 QCharts_getc();
177 uintts_getbuf( QChar*, uint );
178 voidts_putc(int);
179 voidts_putc(QChar);
180 boolts_isspace(QChar);
181 boolts_isdigit(QChar);
182 ulonginput_bin();
183 ulonginput_oct();
184 ulonginput_dec();
185 ulonginput_hex();
186 doubleinput_double();
187 QTextStream &writeBlock( const char* p, uint len );
188 QTextStream &writeBlock( const QChar* p, uint len );
189
190private:// Disabled copy constructor and operator=
191#if defined(Q_DISABLE_COPY)
192 QTextStream( const QTextStream & );
193 QTextStream &operator=( const QTextStream & );
194#endif
195};
196
197typedef QTextStream QTS;
198
199class Q_EXPORT QTextIStream : public QTextStream {
200public:
201 QTextIStream( QString* s ) :
202QTextStream(s,IO_ReadOnly) { }
203 QTextIStream( QByteArray ba ) :
204QTextStream(ba,IO_ReadOnly) { }
205 QTextIStream( FILE *f ) :
206QTextStream(f,IO_ReadOnly) { }
207};
208
209class Q_EXPORT QTextOStream : public QTextStream {
210public:
211 QTextOStream( QString* s ) :
212QTextStream(s,IO_WriteOnly) { }
213 QTextOStream( QByteArray ba ) :
214QTextStream(ba,IO_WriteOnly) { }
215 QTextOStream( FILE *f ) :
216QTextStream(f,IO_WriteOnly) { }
217};
218
219/*****************************************************************************
220 QTextStream inline functions
221 *****************************************************************************/
222
223inline QIODevice *QTextStream::device() const
224{ return dev; }
225
226inline bool QTextStream::atEnd() const
227{ return dev ? dev->atEnd() : FALSE; }
228
229inline bool QTextStream::eof() const
230{ return atEnd(); }
231
232inline int QTextStream::flags() const
233{ return fflags; }
234
235inline int QTextStream::flags( int f )
236{ int oldf = fflags; fflags = f; return oldf; }
237
238inline int QTextStream::setf( int bits )
239{ int oldf = fflags; fflags |= bits; return oldf; }
240
241inline int QTextStream::setf( int bits, int mask )
242{ int oldf = fflags; fflags = (fflags & ~mask) | (bits & mask); return oldf; }
243
244inline int QTextStream::unsetf( int bits )
245{ int oldf = fflags; fflags &= ~bits;return oldf; }
246
247inline int QTextStream::width() const
248{ return fwidth; }
249
250inline int QTextStream::width( int w )
251{ int oldw = fwidth; fwidth = w; return oldw; }
252
253inline int QTextStream::fill() const
254{ return fillchar; }
255
256inline int QTextStream::fill( int f )
257{ int oldc = fillchar;fillchar = f; return oldc; }
258
259inline int QTextStream::precision() const
260{ return fprec; }
261
262inline int QTextStream::precision( int p )
263{ int oldp = fprec; fprec = p; return oldp; }
264
265/*!
266 Returns one character from the stream, or EOF.
267*/
268inline QChar QTextStream::ts_getc()
269{ QChar r; return ( ts_getbuf( &r,1 ) == 1 ? r : QChar((ushort)0xffff) ); }
270
271/*****************************************************************************
272 QTextStream manipulators
273 *****************************************************************************/
274
275typedef QTextStream & (*QTSFUNC)(QTextStream &);// manipulator function
276typedef int (QTextStream::*QTSMFI)(int);// manipulator w/int argument
277
278class Q_EXPORT QTSManip {// text stream manipulator
279public:
280 QTSManip( QTSMFI m, int a ) { mf=m; arg=a; }
281 void exec( QTextStream &s ) { (s.*mf)(arg); }
282private:
283 QTSMFI mf;// QTextStream member function
284 int arg;// member function argument
285};
286
287Q_EXPORT inline QTextStream &operator>>( QTextStream &s, QTSFUNC f )
288{ return (*f)( s ); }
289
290Q_EXPORT inline QTextStream &operator<<( QTextStream &s, QTSFUNC f )
291{ return (*f)( s ); }
292
293Q_EXPORT inline QTextStream &operator<<( QTextStream &s, QTSManip m )
294{ m.exec(s); return s; }
295
296Q_EXPORT QTextStream &bin( QTextStream &s );// set bin notation
297Q_EXPORT QTextStream &oct( QTextStream &s );// set oct notation
298Q_EXPORT QTextStream &dec( QTextStream &s );// set dec notation
299Q_EXPORT QTextStream &hex( QTextStream &s );// set hex notation
300Q_EXPORT QTextStream &endl( QTextStream &s );// insert EOL ('\n')
301Q_EXPORT QTextStream &flush( QTextStream &s );// flush output
302Q_EXPORT QTextStream &ws( QTextStream &s );// eat whitespace on input
303Q_EXPORT QTextStream &reset( QTextStream &s );// set default flags
304
305Q_EXPORT inline QTSManip qSetW( int w )
306{
307 QTSMFI func = &QTextStream::width;
308 return QTSManip(func,w);
309}
310
311Q_EXPORT inline QTSManip qSetFill( int f )
312{
313 QTSMFI func = &QTextStream::fill;
314 return QTSManip(func,f);
315}
316
317Q_EXPORT inline QTSManip qSetPrecision( int p )
318{
319 QTSMFI func = &QTextStream::precision;
320 return QTSManip(func,p);
321}
322
323
324#ifndef QT_ALTERNATE_QTSMANIP
325
326// These will go away in Qt 3.0, as they conflict with std libs
327//
328// If you get conflicts now, #define QT_ALTERNATE_QTSMANIP before
329// including this file.
330
331Q_EXPORT inline QTSManip setw( int w )
332{
333 QTSMFI func = &QTextStream::width;
334 return QTSManip(func,w);
335}
336
337Q_EXPORT inline QTSManip setfill( int f )
338{
339 QTSMFI func = &QTextStream::fill;
340 return QTSManip(func,f);
341}
342
343Q_EXPORT inline QTSManip setprecision( int p )
344{
345 QTSMFI func = &QTextStream::precision;
346 return QTSManip(func,p);
347}
348#endif
349
350#endif // QT_NO_TEXTSTREAM
351#endif // QTEXTSTREAM_H
352

Archive Download this file

Revision: 1322