filters

stream.h

00001 #ifndef QPRO_STREAM_H
00002 #define QPRO_STREAM_H
00003 
00004 //#define USE_QT
00005 
00006 #ifdef USE_QT
00007 
00008 #include <qdatastream.h>
00009 #include <qbuffer.h>
00010 
00011 typedef Q_UINT8  QP_UINT8;
00012 typedef Q_INT8   QP_INT8;
00013 typedef Q_INT16  QP_INT16;
00014 typedef Q_INT32  QP_INT32;
00015 
00016 class QpStream : public QDataStream
00017 {
00018 public:
00019    QpStream(unsigned char* pBuffer, unsigned int pLen);
00020    ~QpStream();
00021 
00022 protected:
00023    QBuffer        cBuf;
00024    QByteArray     cByteArray;
00025 
00026    unsigned char* cBuffer;
00027    unsigned int   cLen;
00028 };
00029 
00030 #else
00031 
00032 #include <iostream>
00033 using namespace std;
00034 
00035 // ??? sort out how to do sizes
00036 
00037 typedef char            QP_INT8  ;
00038 typedef unsigned char   QP_UINT8  ;
00039 typedef short           QP_INT16 ;
00040 typedef int             QP_INT32 ;
00041 typedef double          QP_INT64 ;
00042 
00043 class QpIStream
00044 {
00045 public:
00046    QpIStream(const char* pFileName);
00047    QpIStream(unsigned char* pBuffer, unsigned int pLen);
00048    ~QpIStream();
00049 
00050    int          get();
00051 
00052    QpIStream&   read(char* pBuf, QP_INT16 pLen);
00053 
00054        operator void* ();
00055    int operator !();
00056  
00057    QpIStream& operator >> (QP_INT8  &pI8);
00058    QpIStream& operator >> (QP_UINT8 &pI8);
00059    QpIStream& operator >> (QP_INT16 &pI16);
00060    QpIStream& operator >> (QP_INT32 &pI32);
00061    QpIStream& operator >> (QP_INT64 &pI64);
00062    QpIStream& operator >> (char*& pStr);
00063 
00064 protected:
00065    istream*      cIn;
00066    long          cOffset;
00067    streambuf*    cStreamBuf;
00068 };
00069 
00070 #endif
00071 
00072 #endif // QPRO_STREAM_H
KDE Home | KDE Accessibility Home | Description of Access Keys