qdatastream.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 **
4 ** Definition of QDataStream class
5 **
6 ** Created : 930831
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 QDATASTREAM_H
39 #define QDATASTREAM_H
40 
41 #ifndef QT_H
42 #include "qiodevice.h"
43 #include "qstring.h"
44 #endif // QT_H
45 
46 #ifndef QT_NO_DATASTREAM
47 class Q_EXPORT QDataStream // data stream class
48 {
49 public:
50  QDataStream();
52  QDataStream( QByteArray, int mode );
53  virtual ~QDataStream();
54 
55  QIODevice *device() const;
56  void setDevice( QIODevice * );
57  void unsetDevice();
58 
59  bool atEnd() const;
60  bool eof() const;
61 
62  enum ByteOrder { BigEndian, LittleEndian };
63  int byteOrder() const;
64  void setByteOrder( int );
65 
66  bool isPrintableData() const;
67  void setPrintableData( bool );
68 
69  int version() const;
70  void setVersion( int );
71 
80 
81  QDataStream &operator>>( float &f );
82  QDataStream &operator>>( double &f );
83  QDataStream &operator>>( char *&str );
84 
93  QDataStream &operator<<( float f );
94  QDataStream &operator<<( double f );
95  QDataStream &operator<<( const char *str );
96 
97  QDataStream &readBytes( char *&, uint &len );
98  QDataStream &readRawBytes( char *, uint len );
99 
100  QDataStream &writeBytes( const char *, uint len );
101  QDataStream &writeRawBytes( const char *, uint len );
102 
103 private:
105  bool owndev;
107  bool printable;
108  bool noswap;
109  int ver;
110 
111 private: // Disabled copy constructor and operator=
112 #if defined(Q_DISABLE_COPY)
113  QDataStream( const QDataStream & );
114  QDataStream &operator=( const QDataStream & );
115 #endif
116 };
117 
118 
119 /*****************************************************************************
120  QDataStream inline functions
121  *****************************************************************************/
122 
124 { return dev; }
125 
126 inline bool QDataStream::atEnd() const
127 { return dev ? dev->atEnd() : TRUE; }
128 
129 inline bool QDataStream::eof() const
130 { return atEnd(); }
131 
132 inline int QDataStream::byteOrder() const
133 { return byteorder; }
134 
135 inline bool QDataStream::isPrintableData() const
136 { return printable; }
137 
138 inline void QDataStream::setPrintableData( bool p )
139 { printable = p; }
140 
141 inline int QDataStream::version() const
142 { return ver; }
143 
144 inline void QDataStream::setVersion( int v )
145 { ver = v; }
146 
148 { return *this >> (Q_INT8&)i; }
149 
151 { return *this >> (Q_INT16&)i; }
152 
154 { return *this >> (Q_INT32&)i; }
155 
157 { return *this >> (Q_INT64&)i; }
158 
160 { return *this << (Q_INT8)i; }
161 
163 { return *this << (Q_INT16)i; }
164 
166 { return *this << (Q_INT32)i; }
167 
169 { return *this << (Q_INT64)i; }
170 
171 
172 #endif // QT_NO_DATASTREAM
173 #endif // QDATASTREAM_H
QDataStream & operator>>(Q_INT8 &i)
int byteOrder() const
Definition: qdatastream.h:132
QDataStream & operator<<(Q_INT8 i)
QIODevice * device() const
Definition: qdatastream.h:123
QIODevice * dev
Definition: qdatastream.h:104
void setVersion(int)
Definition: qdatastream.h:144
unsigned char Q_UINT8
Definition: qglobal.h:416
signed char Q_INT8
Definition: qglobal.h:415
int Q_INT32
Definition: qglobal.h:419
bool eof() const
Definition: qdatastream.h:129
bool atEnd() const
Definition: qdatastream.h:126
p
Definition: test.py:223
std::ostream & operator<<(std::ostream &os, Analyzer::Table< T > const &t)
Definition: Analyzer.h:136
bool isPrintableData() const
Definition: qdatastream.h:135
unsigned int Q_UINT32
Definition: qglobal.h:420
unsigned long Q_UINT64
Definition: qglobal.h:422
int version() const
Definition: qdatastream.h:141
unsigned short Q_UINT16
Definition: qglobal.h:418
void setPrintableData(bool)
Definition: qdatastream.h:138
QDataStream & operator>>(QDataStream &s, QByteArray &a)
Definition: qcstring.cpp:605
short Q_INT16
Definition: qglobal.h:417
bool printable
Definition: qdatastream.h:107
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:47
The QIODevice class is the base class of I/O devices.
Definition: qiodevice.h:88
long Q_INT64
Definition: qglobal.h:421
unsigned uint
Definition: qglobal.h:351
#define Q_EXPORT
Definition: qglobal.h:468
const bool TRUE
Definition: qglobal.h:371
static QCString str