1 /****************************************************************************
4 ** Definition of QDataStream class
8 ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
10 ** This file is part of the tools module of the Qt GUI Toolkit.
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.
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.
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.
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.
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.
33 ** Contact info@trolltech.com if any conditions of this licensing are
36 **********************************************************************/
42 #include "qiodevice.h"
46 #ifndef QT_NO_DATASTREAM
47 class Q_EXPORT QDataStream // data stream class
51 QDataStream( QIODevice * );
52 QDataStream( QByteArray, int mode );
53 virtual ~QDataStream();
55 QIODevice *device() const;
56 void setDevice( QIODevice * );
62 enum ByteOrder { BigEndian, LittleEndian };
63 int byteOrder() const;
64 void setByteOrder( int );
66 bool isPrintableData() const;
67 void setPrintableData( bool );
70 void setVersion( int );
72 QDataStream &operator>>( Q_INT8 &i );
73 QDataStream &operator>>( Q_UINT8 &i );
74 QDataStream &operator>>( Q_INT16 &i );
75 QDataStream &operator>>( Q_UINT16 &i );
76 QDataStream &operator>>( Q_INT32 &i );
77 QDataStream &operator>>( Q_UINT32 &i );
78 QDataStream &operator>>( Q_INT64 &i );
79 QDataStream &operator>>( Q_UINT64 &i );
81 QDataStream &operator>>( float &f );
82 QDataStream &operator>>( double &f );
83 QDataStream &operator>>( char *&str );
85 QDataStream &operator<<( Q_INT8 i );
86 QDataStream &operator<<( Q_UINT8 i );
87 QDataStream &operator<<( Q_INT16 i );
88 QDataStream &operator<<( Q_UINT16 i );
89 QDataStream &operator<<( Q_INT32 i );
90 QDataStream &operator<<( Q_UINT32 i );
91 QDataStream &operator<<( Q_INT64 i );
92 QDataStream &operator<<( Q_UINT64 i );
93 QDataStream &operator<<( float f );
94 QDataStream &operator<<( double f );
95 QDataStream &operator<<( const char *str );
97 QDataStream &readBytes( char *&, uint &len );
98 QDataStream &readRawBytes( char *, uint len );
100 QDataStream &writeBytes( const char *, uint len );
101 QDataStream &writeRawBytes( const char *, uint len );
111 private: // Disabled copy constructor and operator=
112 #if defined(Q_DISABLE_COPY)
113 QDataStream( const QDataStream & );
114 QDataStream &operator=( const QDataStream & );
119 /*****************************************************************************
120 QDataStream inline functions
121 *****************************************************************************/
123 inline QIODevice *QDataStream::device() const
126 inline bool QDataStream::atEnd() const
127 { return dev ? dev->atEnd() : TRUE; }
129 inline bool QDataStream::eof() const
132 inline int QDataStream::byteOrder() const
133 { return byteorder; }
135 inline bool QDataStream::isPrintableData() const
136 { return printable; }
138 inline void QDataStream::setPrintableData( bool p )
141 inline int QDataStream::version() const
144 inline void QDataStream::setVersion( int v )
147 inline QDataStream &QDataStream::operator>>( Q_UINT8 &i )
148 { return *this >> (Q_INT8&)i; }
150 inline QDataStream &QDataStream::operator>>( Q_UINT16 &i )
151 { return *this >> (Q_INT16&)i; }
153 inline QDataStream &QDataStream::operator>>( Q_UINT32 &i )
154 { return *this >> (Q_INT32&)i; }
156 inline QDataStream &QDataStream::operator>>( Q_UINT64 &i )
157 { return *this >> (Q_INT64&)i; }
159 inline QDataStream &QDataStream::operator<<( Q_UINT8 i )
160 { return *this << (Q_INT8)i; }
162 inline QDataStream &QDataStream::operator<<( Q_UINT16 i )
163 { return *this << (Q_INT16)i; }
165 inline QDataStream &QDataStream::operator<<( Q_UINT32 i )
166 { return *this << (Q_INT32)i; }
168 inline QDataStream &QDataStream::operator<<( Q_UINT64 i )
169 { return *this << (Q_INT64)i; }
172 #endif // QT_NO_DATASTREAM
173 #endif // QDATASTREAM_H