00001 /**************************************************************************** 00002 ** $Id: qdatastream.h,v 1.2 2003/07/10 02:40:10 llornkcor Exp $ 00003 ** 00004 ** Definition of QDataStream class 00005 ** 00006 ** Created : 930831 00007 ** 00008 ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 00009 ** 00010 ** This file is part of the tools module of the Qt GUI Toolkit. 00011 ** 00012 ** This file may be distributed under the terms of the Q Public License 00013 ** as defined by Trolltech AS of Norway and appearing in the file 00014 ** LICENSE.QPL included in the packaging of this file. 00015 ** 00016 ** This file may be distributed and/or modified under the terms of the 00017 ** GNU General Public License version 2 as published by the Free Software 00018 ** Foundation and appearing in the file LICENSE.GPL included in the 00019 ** packaging of this file. 00020 ** 00021 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 00022 ** licenses may use this file in accordance with the Qt Commercial License 00023 ** Agreement provided with the Software. 00024 ** 00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00027 ** 00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 00029 ** information about Qt Commercial License Agreements. 00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information. 00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00032 ** 00033 ** Contact info@trolltech.com if any conditions of this licensing are 00034 ** not clear to you. 00035 ** 00036 **********************************************************************/ 00037 00038 #ifndef QDATASTREAM_H 00039 #define QDATASTREAM_H 00040 00041 #ifndef QT_H 00042 #include "qiodevice.h" 00043 #include "qstring.h" 00044 #endif // QT_H 00045 00046 #ifndef QT_NO_DATASTREAM 00047 class Q_EXPORT QDataStream // data stream class 00048 { 00049 public: 00050 QDataStream(); 00051 QDataStream( QIODevice * ); 00052 QDataStream( QByteArray, int mode ); 00053 virtual ~QDataStream(); 00054 00055 QIODevice *device() const; 00056 void setDevice( QIODevice * ); 00057 void unsetDevice(); 00058 00059 bool atEnd() const; 00060 bool eof() const; 00061 00062 enum ByteOrder { BigEndian, LittleEndian }; 00063 int byteOrder() const; 00064 void setByteOrder( int ); 00065 00066 bool isPrintableData() const; 00067 void setPrintableData( bool ); 00068 00069 int version() const; 00070 void setVersion( int ); 00071 00072 QDataStream &operator>>( Q_INT8 &i ); 00073 QDataStream &operator>>( Q_UINT8 &i ); 00074 QDataStream &operator>>( Q_INT16 &i ); 00075 QDataStream &operator>>( Q_UINT16 &i ); 00076 QDataStream &operator>>( Q_INT32 &i ); 00077 QDataStream &operator>>( Q_UINT32 &i ); 00078 QDataStream &operator>>( Q_LONG &i ); 00079 QDataStream &operator>>( Q_ULONG &i ); 00080 00081 QDataStream &operator>>( float &f ); 00082 QDataStream &operator>>( double &f ); 00083 QDataStream &operator>>( char *&str ); 00084 00085 QDataStream &operator<<( Q_INT8 i ); 00086 QDataStream &operator<<( Q_UINT8 i ); 00087 QDataStream &operator<<( Q_INT16 i ); 00088 QDataStream &operator<<( Q_UINT16 i ); 00089 QDataStream &operator<<( Q_INT32 i ); 00090 QDataStream &operator<<( Q_UINT32 i ); 00091 QDataStream &operator<<( Q_LONG i ); 00092 QDataStream &operator<<( Q_ULONG i ); 00093 QDataStream &operator<<( float f ); 00094 QDataStream &operator<<( double f ); 00095 QDataStream &operator<<( const char *str ); 00096 00097 QDataStream &readBytes( char *&, uint &len ); 00098 QDataStream &readRawBytes( char *, uint len ); 00099 00100 QDataStream &writeBytes( const char *, uint len ); 00101 QDataStream &writeRawBytes( const char *, uint len ); 00102 00103 private: 00104 QIODevice *dev; 00105 bool owndev; 00106 int byteorder; 00107 bool printable; 00108 bool noswap; 00109 int ver; 00110 00111 private: // Disabled copy constructor and operator= 00112 #if defined(Q_DISABLE_COPY) 00113 QDataStream( const QDataStream & ); 00114 QDataStream &operator=( const QDataStream & ); 00115 #endif 00116 }; 00117 00118 00119 /***************************************************************************** 00120 QDataStream inline functions 00121 *****************************************************************************/ 00122 00123 inline QIODevice *QDataStream::device() const 00124 { return dev; } 00125 00126 inline bool QDataStream::atEnd() const 00127 { return dev ? dev->atEnd() : TRUE; } 00128 00129 inline bool QDataStream::eof() const 00130 { return atEnd(); } 00131 00132 inline int QDataStream::byteOrder() const 00133 { return byteorder; } 00134 00135 inline bool QDataStream::isPrintableData() const 00136 { return printable; } 00137 00138 inline void QDataStream::setPrintableData( bool p ) 00139 { printable = p; } 00140 00141 inline int QDataStream::version() const 00142 { return ver; } 00143 00144 inline void QDataStream::setVersion( int v ) 00145 { ver = v; } 00146 00147 inline QDataStream &QDataStream::operator>>( Q_UINT8 &i ) 00148 { return *this >> (Q_INT8&)i; } 00149 00150 inline QDataStream &QDataStream::operator>>( Q_UINT16 &i ) 00151 { return *this >> (Q_INT16&)i; } 00152 00153 inline QDataStream &QDataStream::operator>>( Q_UINT32 &i ) 00154 { return *this >> (Q_INT32&)i; } 00155 00156 inline QDataStream &QDataStream::operator>>( Q_ULONG &i ) 00157 { return *this >> (Q_LONG&)i; } 00158 00159 inline QDataStream &QDataStream::operator<<( Q_UINT8 i ) 00160 { return *this << (Q_INT8)i; } 00161 00162 inline QDataStream &QDataStream::operator<<( Q_UINT16 i ) 00163 { return *this << (Q_INT16)i; } 00164 00165 inline QDataStream &QDataStream::operator<<( Q_UINT32 i ) 00166 { return *this << (Q_INT32)i; } 00167 00168 inline QDataStream &QDataStream::operator<<( Q_ULONG i ) 00169 { return *this << (Q_LONG)i; } 00170 00171 00172 #endif // QT_NO_DATASTREAM 00173 #endif // QDATASTREAM_H
1.4.2