home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / qt3_emx.zip / include / qdatastream.h < prev    next >
C/C++ Source or Header  |  2001-10-11  |  5KB  |  174 lines

  1. /****************************************************************************
  2. ** $Id:  qt/qdatastream.h   3.0.0   edited Jun 22 12:41 $
  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();
  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_LONG &i );
  79.     QDataStream &operator>>( Q_ULONG &i );
  80.  
  81.     QDataStream &operator>>( float &f );
  82.     QDataStream &operator>>( double &f );
  83.     QDataStream &operator>>( char *&str );
  84.  
  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_LONG i );
  92.     QDataStream &operator<<( Q_ULONG i );
  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:
  104.     QIODevice    *dev;
  105.     bool     owndev;
  106.     int         byteorder;
  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.  
  123. inline QIODevice *QDataStream::device() const
  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.  
  147. inline QDataStream &QDataStream::operator>>( Q_UINT8 &i )
  148. { return *this >> (Q_INT8&)i; }
  149.  
  150. inline QDataStream &QDataStream::operator>>( Q_UINT16 &i )
  151. { return *this >> (Q_INT16&)i; }
  152.  
  153. inline QDataStream &QDataStream::operator>>( Q_UINT32 &i )
  154. { return *this >> (Q_INT32&)i; }
  155.  
  156. inline QDataStream &QDataStream::operator>>( Q_ULONG &i )
  157. { return *this >> (Q_LONG&)i; }
  158.  
  159. inline QDataStream &QDataStream::operator<<( Q_UINT8 i )
  160. { return *this << (Q_INT8)i; }
  161.  
  162. inline QDataStream &QDataStream::operator<<( Q_UINT16 i )
  163. { return *this << (Q_INT16)i; }
  164.  
  165. inline QDataStream &QDataStream::operator<<( Q_UINT32 i )
  166. { return *this << (Q_INT32)i; }
  167.  
  168. inline QDataStream &QDataStream::operator<<( Q_ULONG i )
  169. { return *this << (Q_LONG)i; }
  170.  
  171.  
  172. #endif // QT_NO_DATASTREAM
  173. #endif // QDATASTREAM_H
  174.