Blame qtools/qiodevice.h

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