source: trunk/include/qdatastream.h@ 56

Last change on this file since 56 was 2, checked in by dmik, 20 years ago

Imported xplatform parts of the official release 3.3.1 from Trolltech

  • Property svn:keywords set to Id
File size: 5.7 KB
Line 
1/****************************************************************************
2** $Id: qdatastream.h 2 2005-11-16 15:49:26Z dmik $
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
47class Q_EXPORT QDataStream // data stream class
48{
49public:
50 QDataStream();
51 QDataStream( QIODevice * );
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
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 );
80#if !defined(Q_OS_WIN64)
81 QDataStream &operator>>( Q_LONG &i );
82 QDataStream &operator>>( Q_ULONG &i );
83#endif
84
85 QDataStream &operator>>( float &f );
86 QDataStream &operator>>( double &f );
87 QDataStream &operator>>( char *&str );
88
89 QDataStream &operator<<( Q_INT8 i );
90 QDataStream &operator<<( Q_UINT8 i );
91 QDataStream &operator<<( Q_INT16 i );
92 QDataStream &operator<<( Q_UINT16 i );
93 QDataStream &operator<<( Q_INT32 i );
94 QDataStream &operator<<( Q_UINT32 i );
95 QDataStream &operator<<( Q_INT64 i );
96 QDataStream &operator<<( Q_UINT64 i );
97#if !defined(Q_OS_WIN64)
98 QDataStream &operator<<( Q_LONG i );
99 QDataStream &operator<<( Q_ULONG i );
100#endif
101 QDataStream &operator<<( float f );
102 QDataStream &operator<<( double f );
103 QDataStream &operator<<( const char *str );
104
105 QDataStream &readBytes( char *&, uint &len );
106 QDataStream &readRawBytes( char *, uint len );
107
108 QDataStream &writeBytes( const char *, uint len );
109 QDataStream &writeRawBytes( const char *, uint len );
110
111private:
112 QIODevice *dev;
113 bool owndev;
114 int byteorder;
115 bool printable;
116 bool noswap;
117 int ver;
118
119private: // Disabled copy constructor and operator=
120#if defined(Q_DISABLE_COPY)
121 QDataStream( const QDataStream & );
122 QDataStream &operator=( const QDataStream & );
123#endif
124};
125
126
127/*****************************************************************************
128 QDataStream inline functions
129 *****************************************************************************/
130
131inline QIODevice *QDataStream::device() const
132{ return dev; }
133
134inline bool QDataStream::atEnd() const
135{ return dev ? dev->atEnd() : TRUE; }
136
137inline bool QDataStream::eof() const
138{ return atEnd(); }
139
140inline int QDataStream::byteOrder() const
141{ return byteorder; }
142
143inline bool QDataStream::isPrintableData() const
144{ return printable; }
145
146inline void QDataStream::setPrintableData( bool p )
147{ printable = p; }
148
149inline int QDataStream::version() const
150{ return ver; }
151
152inline void QDataStream::setVersion( int v )
153{ ver = v; }
154
155inline QDataStream &QDataStream::operator>>( Q_UINT8 &i )
156{ return *this >> (Q_INT8&)i; }
157
158inline QDataStream &QDataStream::operator>>( Q_UINT16 &i )
159{ return *this >> (Q_INT16&)i; }
160
161inline QDataStream &QDataStream::operator>>( Q_UINT32 &i )
162{ return *this >> (Q_INT32&)i; }
163
164inline QDataStream &QDataStream::operator>>( Q_UINT64 &i )
165{ return *this >> (Q_INT64&)i; }
166
167#if !defined(Q_OS_WIN64)
168inline QDataStream &QDataStream::operator>>( Q_ULONG &i )
169{ return *this >> (Q_LONG&)i; }
170#endif
171
172inline QDataStream &QDataStream::operator<<( Q_UINT8 i )
173{ return *this << (Q_INT8)i; }
174
175inline QDataStream &QDataStream::operator<<( Q_UINT16 i )
176{ return *this << (Q_INT16)i; }
177
178inline QDataStream &QDataStream::operator<<( Q_UINT32 i )
179{ return *this << (Q_INT32)i; }
180
181inline QDataStream &QDataStream::operator<<( Q_UINT64 i )
182{ return *this << (Q_INT64)i; }
183
184#if !defined(Q_OS_WIN64)
185inline QDataStream &QDataStream::operator<<( Q_ULONG i )
186{ return *this << (Q_LONG)i; }
187#endif
188
189#endif // QT_NO_DATASTREAM
190#endif // QDATASTREAM_H
Note: See TracBrowser for help on using the repository browser.