Eneboo - Documentación para desarrolladores
src/qt/include/qiodevice.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 ** $Id: qt/qiodevice.h   3.3.8   edited Jan 11 14:38 $
00003 **
00004 ** Definition of QIODevice class
00005 **
00006 ** Created : 940913
00007 **
00008 ** Copyright (C) 1992-2007 Trolltech ASA.  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 ASA 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 QIODEVICE_H
00039 #define QIODEVICE_H
00040 
00041 #ifndef QT_H
00042 #include "qglobal.h"
00043 #include "qcstring.h"
00044 #endif // QT_H
00045 
00046 
00047 // IO device access types
00048 
00049 #define IO_Direct               0x0100          // direct access device
00050 #define IO_Sequential           0x0200          // sequential access device
00051 #define IO_Combined             0x0300          // combined direct/sequential
00052 #define IO_TypeMask             0x0f00
00053 
00054 // IO handling modes
00055 
00056 #define IO_Raw                  0x0040          // raw access (not buffered)
00057 #define IO_Async                0x0080          // asynchronous mode
00058 
00059 // IO device open modes
00060 
00061 #define IO_ReadOnly             0x0001          // readable device
00062 #define IO_WriteOnly            0x0002          // writable device
00063 #define IO_ReadWrite            0x0003          // read+write device
00064 #define IO_Append               0x0004          // append
00065 #define IO_Truncate             0x0008          // truncate device
00066 #define IO_Translate            0x0010          // translate CR+LF
00067 #define IO_ModeMask             0x00ff
00068 
00069 // IO device state
00070 
00071 #define IO_Open                 0x1000          // device is open
00072 #define IO_StateMask            0xf000
00073 
00074 // IO device status
00075 
00076 #define IO_Ok                   0
00077 #define IO_ReadError            1               // read error
00078 #define IO_WriteError           2               // write error
00079 #define IO_FatalError           3               // fatal unrecoverable error
00080 #define IO_ResourceError        4               // resource limitation
00081 #define IO_OpenError            5               // cannot open device
00082 #define IO_ConnectError         5               // cannot connect to device
00083 #define IO_AbortError           6               // abort error
00084 #define IO_TimeOutError         7               // time out
00085 #define IO_UnspecifiedError     8               // unspecified error
00086 
00087 
00088 class Q_EXPORT QIODevice
00089 {
00090 public:
00091 #if defined(QT_ABI_QT4)
00092     typedef Q_LLONG Offset;
00093 #else
00094     typedef Q_ULONG Offset;
00095 #endif
00096 
00097     QIODevice();
00098     virtual ~QIODevice();
00099 
00100     int          flags()  const { return ioMode; }
00101     int          mode()   const { return ioMode & IO_ModeMask; }
00102     int          state()  const { return ioMode & IO_StateMask; }
00103 
00104     bool         isDirectAccess()     const { return ((ioMode & IO_Direct)     == IO_Direct); }
00105     bool         isSequentialAccess() const { return ((ioMode & IO_Sequential) == IO_Sequential); }
00106     bool         isCombinedAccess()   const { return ((ioMode & IO_Combined)   == IO_Combined); }
00107     bool         isBuffered()         const { return ((ioMode & IO_Raw)        != IO_Raw); }
00108     bool         isRaw()              const { return ((ioMode & IO_Raw)        == IO_Raw); }
00109     bool         isSynchronous()      const { return ((ioMode & IO_Async)      != IO_Async); }
00110     bool         isAsynchronous()     const { return ((ioMode & IO_Async)      == IO_Async); }
00111     bool         isTranslated()       const { return ((ioMode & IO_Translate)  == IO_Translate); }
00112     bool         isReadable()         const { return ((ioMode & IO_ReadOnly)   == IO_ReadOnly); }
00113     bool         isWritable()         const { return ((ioMode & IO_WriteOnly)  == IO_WriteOnly); }
00114     bool         isReadWrite()        const { return ((ioMode & IO_ReadWrite)  == IO_ReadWrite); }
00115     bool         isInactive()         const { return state() == 0; }
00116     bool         isOpen()             const { return state() == IO_Open; }
00117 
00118     int          status() const { return ioSt; }
00119     void         resetStatus()  { ioSt = IO_Ok; }
00120 
00121     virtual bool open( int mode ) = 0;
00122     virtual void close() = 0;
00123     virtual void flush() = 0;
00124 
00125     virtual Offset size()  const = 0;
00126     virtual Offset at()  const;
00127     virtual bool at( Offset );
00128     virtual bool atEnd()  const;
00129     bool         reset() { return at(0); }
00130 
00131     virtual Q_LONG readBlock( char *data, Q_ULONG maxlen ) = 0;
00132     virtual Q_LONG writeBlock( const char *data, Q_ULONG len ) = 0;
00133     virtual Q_LONG readLine( char *data, Q_ULONG maxlen );
00134     Q_LONG writeBlock( const QByteArray& data );
00135     virtual QByteArray readAll();
00136 
00137     virtual int  getch() = 0;
00138     virtual int  putch( int ) = 0;
00139     virtual int  ungetch( int ) = 0;
00140 
00141 protected:
00142     void         setFlags( int f ) { ioMode = f; }
00143     void         setType( int );
00144     void         setMode( int );
00145     void         setState( int );
00146     void         setStatus( int );
00147     Offset       ioIndex;
00148 
00149 private:
00150     int          ioMode;
00151     int          ioSt;
00152 
00153 private:        // Disabled copy constructor and operator=
00154 #if defined(Q_DISABLE_COPY)
00155     QIODevice( const QIODevice & );
00156     QIODevice &operator=( const QIODevice & );
00157 #endif
00158 };
00159 
00160 
00161 #endif // QIODEVICE_H
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'