FX::QIODevice Class Reference
[File type i/o devicesWriting secure code]

#include <QIODevice.h>

Inheritance diagram for FX::QIODevice:

FX::QBuffer FX::QBZip2Device FX::QFile FX::QGZipDevice FX::QIODeviceS FX::QMemMap FX::QBlkSocket FX::QChildProcess FX::QLocalPipe FX::QPipe FX::QSSLDevice List of all members.

Detailed Description

The abstract base class for all i/o classes in TnFOX (Qt compatible).

This is the base class for all TnFOX byte i/o classes. It provides a universal API for accessing all subclasses and while API compatible with Qt's QIODevice, it provides enhanced functionality.

CR/LF translation facilities are provided by applyCRLF() and removeCRLF(). These were broken first time I wrote them and I find it surprising how difficult it actually is to implement this 100% correctly. They are public as GUI code will want to apply CR/LF before exporting text to the clipboard and remove it when importing. The same functions can also perform Unicode conversions.

Data destruction is performed by shredData(). This uses an algorithm which thoroughly shreds the specified region, ensuring that the data cannot be recovered by any known process. The algorithm used involves XORing the existing data with pseudo-random data seeded with data from FX::Secure::Randomness, then writing zeros over the lot. All TnFOX file i/o devices call this on truncated data when IO_ShredTruncate is specified in the mode. If you wish to destroy an existing file, open it with IO_ShredTruncate, call truncate(0) and close before deleting.

QIODevice is extremely straightforward, so I won't bother explaining any more. What I will say is that there are two types of i/o device in TnFOX: (a) file and (b) synchronous. File i/o devices (eg; FX::FXFile, FX::QBuffer, FX::QMemMap, FX::QGZipDevice etc) let you perform reads and writes on a patch of data and thus they are interchangeable. Synchronous i/o devices (eg; FX::QPipe, FX::QBlkSocket, FX::QLocalPipe etc) which inherit off FX::QIODeviceS imply the use of two threads to use them because data reads in all of them wait for data to be written by the other side. Things like at() have no meaning and size() returns how much data is waiting to be read. Synchronous i/o devices are the foundation stone of Inter Process Communication (IPC) and are used mostly with FX::FXIPCMsg.

All i/o devices in TnFOX are thread-safe and can be used by multiple threads simultaneously though obviously there is only one current file pointer. You will have to synchronise that on your own. Furthermore, full access to the host security mechanism is provided by all i/o devices via permissions().

Differences from QIODevice

See also:
FX::QBuffer, FX::FXFile, FX::QBlkSocket, FX::QPipe, FX::QMemMap

Definition at line 127 of file QIODevice.h.

Public Types

typedef FXfval Offset
 Default
 Unix
 MacOS
 MSDOS
 NoTranslation
 UTF8
 UTF16
 UTF16LE
 UTF32
 UTF32LE
enum  CRLFType { Default, Unix, MacOS, MSDOS }
enum  UnicodeType {
  NoTranslation, UTF8, UTF16, UTF16LE,
  UTF32, UTF32LE
}

Public Member Functions

 QIODevice ()
virtual ~QIODevice ()
FXuint flags () const
FXuint mode () const
FXuint state () const
CRLFType crlfFormat () const
void setCRLFFormat (CRLFType type)
UnicodeType unicodeTranslation () const
void setUnicodeTranslation (UnicodeType type)
bool isBuffered () const
bool isRaw () const
bool isTranslated () const
bool isUTF16Translated () const
bool isUTF32Translated () const
bool isReadable () const
bool isWriteable () const
bool isWritable () const
bool isReadWrite () const
bool isClosed () const
bool isInactive () const
bool isOpen () const
virtual bool isSynchronous () const
virtual bool open (FXuint mode)=0
virtual void close ()=0
virtual void flush ()=0
virtual FXfval size () const =0
virtual void truncate (FXfval size)=0
virtual FXfval at () const
virtual bool at (FXfval newpos)
virtual bool atEnd () const
virtual const FXACLpermissions () const
virtual void setPermissions (const FXACL &)
virtual FXuval readBlock (char *data, FXuval maxlen)=0
FXuval readBlock (FXuchar *data, FXuval maxlen)
virtual FXuval writeBlock (const char *data, FXuval maxlen)=0
FXuval writeBlock (const FXuchar *data, FXuval maxlen)
virtual FXuval readLine (char *data, FXuval maxlen)
virtual FXuval readBlockFrom (char *data, FXuval maxlen, FXfval pos)=0
FXuval readBlockFrom (FXuchar *data, FXuval maxlen, FXfval pos)
virtual FXuval writeBlockTo (FXfval pos, const char *data, FXuval maxlen)=0
FXuval writeBlockTo (FXfval pos, const FXuchar *data, FXuval maxlen)
virtual int getch ()
virtual int putch (int c)
virtual int ungetch (int c)=0
FXfval shredData (FXfval offset, FXfval len=(FXfval)-1)

Static Public Member Functions

static UnicodeType determineUnicodeType (FXuchar *data, FXuval len) throw ()
static FXuval applyCRLF (FXuchar *FXRESTRICT output, const FXuchar *FXRESTRICT input, FXuval outputlen, FXuval &inputlen, CRLFType crlftype=Default, UnicodeType utftype=NoTranslation)
static FXuval removeCRLF (FXuchar *FXRESTRICT output, const FXuchar *FXRESTRICT input, FXuval outputlen, FXuval &inputlen, UnicodeType utftype=NoTranslation)

Protected Member Functions

 QIODevice (const QIODevice &o)
QIODeviceoperator= (const QIODevice &o)
void setFlags (int f)
void setMode (int m)
void setState (int s)

Protected Attributes

FXfval ioIndex

Friends

FXAPI FXStreamoperator<< (FXStream &s, QIODevice &i)
FXAPI FXStreamoperator>> (FXStream &s, QIODevice &i)


The documentation for this class was generated from the following file:
(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:37:40 2009 for TnFOX by doxygen v1.4.7