|
Packit |
1c1d7e |
/****************************************************************************
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** Definition of QIODevice class
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** Created : 940913
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** This file is part of the tools module of the Qt GUI Toolkit.
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** This file may be distributed under the terms of the Q Public License
|
|
Packit |
1c1d7e |
** as defined by Trolltech AS of Norway and appearing in the file
|
|
Packit |
1c1d7e |
** LICENSE.QPL included in the packaging of this file.
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** This file may be distributed and/or modified under the terms of the
|
|
Packit |
1c1d7e |
** GNU General Public License version 2 as published by the Free Software
|
|
Packit |
1c1d7e |
** Foundation and appearing in the file LICENSE.GPL included in the
|
|
Packit |
1c1d7e |
** packaging of this file.
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
|
Packit |
1c1d7e |
** licenses may use this file in accordance with the Qt Commercial License
|
|
Packit |
1c1d7e |
** Agreement provided with the Software.
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
Packit |
1c1d7e |
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
|
Packit |
1c1d7e |
** information about Qt Commercial License Agreements.
|
|
Packit |
1c1d7e |
** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
|
Packit |
1c1d7e |
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** Contact info@trolltech.com if any conditions of this licensing are
|
|
Packit |
1c1d7e |
** not clear to you.
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
**********************************************************************/
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
#ifndef QIODEVICE_H
|
|
Packit |
1c1d7e |
#define QIODEVICE_H
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
#ifndef QT_H
|
|
Packit |
1c1d7e |
#include "qglobal.h"
|
|
Packit |
1c1d7e |
#include "qcstring.h"
|
|
Packit |
1c1d7e |
#endif // QT_H
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
// IO device access types
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
#define IO_Direct 0x0100 // direct access device
|
|
Packit |
1c1d7e |
#define IO_Sequential 0x0200 // sequential access device
|
|
Packit |
1c1d7e |
#define IO_Combined 0x0300 // combined direct/sequential
|
|
Packit |
1c1d7e |
#define IO_TypeMask 0x0f00
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
// IO handling modes
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
#define IO_Raw 0x0040 // raw access (not buffered)
|
|
Packit |
1c1d7e |
#define IO_Async 0x0080 // asynchronous mode
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
// IO device open modes
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
#define IO_ReadOnly 0x0001 // readable device
|
|
Packit |
1c1d7e |
#define IO_WriteOnly 0x0002 // writable device
|
|
Packit |
1c1d7e |
#define IO_ReadWrite 0x0003 // read+write device
|
|
Packit |
1c1d7e |
#define IO_Append 0x0004 // append
|
|
Packit |
1c1d7e |
#define IO_Truncate 0x0008 // truncate device
|
|
Packit |
1c1d7e |
#define IO_Translate 0x0010 // translate CR+LF
|
|
Packit |
1c1d7e |
#define IO_ModeMask 0x00ff
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
// IO device state
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
#define IO_Open 0x1000 // device is open
|
|
Packit |
1c1d7e |
#define IO_StateMask 0xf000
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
// IO device status
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
#define IO_Ok 0
|
|
Packit |
1c1d7e |
#define IO_ReadError 1 // read error
|
|
Packit |
1c1d7e |
#define IO_WriteError 2 // write error
|
|
Packit |
1c1d7e |
#define IO_FatalError 3 // fatal unrecoverable error
|
|
Packit |
1c1d7e |
#define IO_ResourceError 4 // resource limitation
|
|
Packit |
1c1d7e |
#define IO_OpenError 5 // cannot open device
|
|
Packit |
1c1d7e |
#define IO_ConnectError 5 // cannot connect to device
|
|
Packit |
1c1d7e |
#define IO_AbortError 6 // abort error
|
|
Packit |
1c1d7e |
#define IO_TimeOutError 7 // time out
|
|
Packit |
1c1d7e |
#define IO_UnspecifiedError 8 // unspecified error
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
class Q_EXPORT QIODevice // IO device class
|
|
Packit |
1c1d7e |
{
|
|
Packit |
1c1d7e |
public:
|
|
Packit |
1c1d7e |
QIODevice();
|
|
Packit |
1c1d7e |
virtual ~QIODevice();
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
int flags() const { return ioMode; }
|
|
Packit |
1c1d7e |
int mode() const { return ioMode & IO_ModeMask; }
|
|
Packit |
1c1d7e |
int state() const { return ioMode & IO_StateMask; }
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
bool isDirectAccess() const { return ((ioMode & IO_Direct) == IO_Direct); }
|
|
Packit |
1c1d7e |
bool isSequentialAccess() const { return ((ioMode & IO_Sequential) == IO_Sequential); }
|
|
Packit |
1c1d7e |
bool isCombinedAccess() const { return ((ioMode & IO_Combined) == IO_Combined); }
|
|
Packit |
1c1d7e |
bool isBuffered() const { return ((ioMode & IO_Raw) != IO_Raw); }
|
|
Packit |
1c1d7e |
bool isRaw() const { return ((ioMode & IO_Raw) == IO_Raw); }
|
|
Packit |
1c1d7e |
bool isSynchronous() const { return ((ioMode & IO_Async) != IO_Async); }
|
|
Packit |
1c1d7e |
bool isAsynchronous() const { return ((ioMode & IO_Async) == IO_Async); }
|
|
Packit |
1c1d7e |
bool isTranslated() const { return ((ioMode & IO_Translate) == IO_Translate); }
|
|
Packit |
1c1d7e |
bool isReadable() const { return ((ioMode & IO_ReadOnly) == IO_ReadOnly); }
|
|
Packit |
1c1d7e |
bool isWritable() const { return ((ioMode & IO_WriteOnly) == IO_WriteOnly); }
|
|
Packit |
1c1d7e |
bool isReadWrite() const { return ((ioMode & IO_ReadWrite) == IO_ReadWrite); }
|
|
Packit |
1c1d7e |
bool isInactive() const { return state() == 0; }
|
|
Packit |
1c1d7e |
bool isOpen() const { return state() == IO_Open; }
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
int status() const { return ioSt; }
|
|
Packit |
1c1d7e |
void resetStatus() { ioSt = IO_Ok; }
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
virtual bool open( int mode ) = 0;
|
|
Packit |
1c1d7e |
virtual void close() = 0;
|
|
Packit |
1c1d7e |
virtual void flush() = 0;
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
virtual uint size() const = 0;
|
|
Packit |
1c1d7e |
virtual int at() const;
|
|
Packit |
1c1d7e |
virtual bool at( int );
|
|
Packit |
1c1d7e |
virtual bool atEnd() const;
|
|
Packit |
1c1d7e |
bool reset() { return at(0); }
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
virtual int readBlock( char *data, uint maxlen ) = 0;
|
|
Packit |
1c1d7e |
virtual int writeBlock( const char *data, uint len ) = 0;
|
|
Packit |
1c1d7e |
virtual int readLine( char *data, uint maxlen );
|
|
Packit |
1c1d7e |
int writeBlock( const QByteArray& data );
|
|
Packit |
1c1d7e |
QByteArray readAll();
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
virtual int getch() = 0;
|
|
Packit |
1c1d7e |
virtual int putch( int ) = 0;
|
|
Packit |
1c1d7e |
virtual int ungetch( int ) = 0;
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
protected:
|
|
Packit |
1c1d7e |
void setFlags( int f ) { ioMode = f; }
|
|
Packit |
1c1d7e |
void setType( int );
|
|
Packit |
1c1d7e |
void setMode( int );
|
|
Packit |
1c1d7e |
void setState( int );
|
|
Packit |
1c1d7e |
void setStatus( int );
|
|
Packit |
1c1d7e |
int ioIndex;
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
private:
|
|
Packit |
1c1d7e |
int ioMode;
|
|
Packit |
1c1d7e |
int ioSt;
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
private: // Disabled copy constructor and operator=
|
|
Packit |
1c1d7e |
#if defined(Q_DISABLE_COPY)
|
|
Packit |
1c1d7e |
QIODevice( const QIODevice & );
|
|
Packit |
1c1d7e |
QIODevice &operator=( const QIODevice & );
|
|
Packit |
1c1d7e |
#endif
|
|
Packit |
1c1d7e |
};
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
#endif // QIODEVICE_H
|