Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

qgxml::QIODeviceAdaptor Class Reference

#include <QIODeviceAdaptor.H>

List of all members.


Detailed Description

Adapts the interface of Qt QIODevice to std::istream.

This class adapts a standard input stream (std::istream) into a valid Qt QIODevice. All function calls performed on an instance of this class are transformed into calls to the istream data member. Although this class extends QIODevice, it implements only a sequential input stream

For compatibility reasons with the parent class QIODevice, this class implements some inherited function members that are not relevant for a sequential output stream. These members are:

Any attempt to use these function members will raise a std::runtime_error exception.

Author:
Jan Rendek
Date:
March 14, 2003 15:27
Since:
Qgar 2.1.1

Definition at line 81 of file QIODeviceAdaptor.H.

Public Member Functions

virtual bool open (int mode)
 Open the I/O device using a specified mode.
virtual void close ()
 Closes the device.
virtual void flush ()
 flushes an open iodevice
virtual Offset size () const
 Returns the size of the IODevice.
virtual Q_LONG readBlock (char *data, Q_ULONG maxlen)
 Reads a block of data from the stream.
virtual Q_LONG writeBlock (const char *data, Q_ULONG len)
 Writes a block of data to the stream.
virtual int getch ()
 reads a single byte from the stream.
virtual int putch (int ch)
 Writes a single byte to the stream.
virtual int ungetch (int ch)
 Puts the character ch back into the I/O device and decrements the index position if it is not zero.
Constructors
 QIODeviceAdaptor (std::istream *stream)
 Default constructor.
Destructors
virtual ~QIODeviceAdaptor ()
 Destructor.

Protected Attributes

std::istream * _stream
 The input stream implementing this IODevice.


Constructor & Destructor Documentation

qgxml::QIODeviceAdaptor::QIODeviceAdaptor std::istream *  stream  )  [explicit]
 

Default constructor.

Create an adaptor redirecting class to a QIODevice instance to a istream instance. This QIODevice should be used only as a sequential input device.

The QIODevice flags set at the creation are:

  • IO_ReadOnly
  • IO_Sequential
  • IO_Open;

Parameters:
stream The stream to which all calls will be redirected to.

qgxml::QIODeviceAdaptor::~QIODeviceAdaptor  )  [virtual]
 

Destructor.

Definition at line 72 of file QIODeviceAdaptor.C.

References close().


Member Function Documentation

void qgxml::QIODeviceAdaptor::close  )  [virtual]
 

Closes the device.

Definition at line 90 of file QIODeviceAdaptor.C.

References flush().

Referenced by ~QIODeviceAdaptor().

void qgxml::QIODeviceAdaptor::flush  )  [virtual]
 

flushes an open iodevice

Definition at line 98 of file QIODeviceAdaptor.C.

References _stream.

Referenced by close().

int qgxml::QIODeviceAdaptor::getch  )  [virtual]
 

reads a single byte from the stream.

Returns:
the byte read cast into an int.

Definition at line 135 of file QIODeviceAdaptor.C.

References _stream.

bool qgxml::QIODeviceAdaptor::open int  mode  )  [virtual]
 

Open the I/O device using a specified mode.

This function is provided for compatibility purpose only. The stream is declared opened at creation time (see QIODeviceAdatptor) and will remain this way until destroyed. Thus this function member returns always true.

Returns:
always true

Definition at line 82 of file QIODeviceAdaptor.C.

int qgxml::QIODeviceAdaptor::putch int  ch  )  [virtual]
 

Writes a single byte to the stream.

Returns:
nothing since any call to this function member will raise an exception.
Warning:
Method redefined for compatibility purpose only. Calling it will raise an error.
Exceptions:
std::runtime_error whenever this function member is called.

Definition at line 143 of file QIODeviceAdaptor.C.

Q_LONG qgxml::QIODeviceAdaptor::readBlock char *  data,
Q_ULONG  maxlen
[virtual]
 

Reads a block of data from the stream.

Reads at most maxlen bytes from the I/O device into data and returns the number of bytes actually read.

Parameters:
data a pointer on a free memory space where to store the read data. This space must be big enough to hold up to maxlen bytes.
maxlen The maximum number of bytes to be read from the device.
Returns:
the number of bytes actually read.

Definition at line 117 of file QIODeviceAdaptor.C.

References _stream.

Q_ULONG qgxml::QIODeviceAdaptor::size  )  const [virtual]
 

Returns the size of the IODevice.

Returns:
nothing since any call to this function member will raise an exception.
Warning:
Method redefined for compatibility purpose only. Calling it will raise an error.
Exceptions:
std::runtime_error whenever this function member is called.

Definition at line 106 of file QIODeviceAdaptor.C.

int qgxml::QIODeviceAdaptor::ungetch int  ch  )  [virtual]
 

Puts the character ch back into the I/O device and decrements the index position if it is not zero.

Returns:
nothing since any call to this function member will raise an exception.
Warning:
Method redefined for compatibility purpose only. Calling it will raise an error.
Exceptions:
std::runtime_error whenever this function member is called.

Definition at line 153 of file QIODeviceAdaptor.C.

References _stream.

Q_LONG qgxml::QIODeviceAdaptor::writeBlock const char *  data,
Q_ULONG  len
[virtual]
 

Writes a block of data to the stream.

Returns:
nothing since any call to this function member will raise an exception.
Warning:
Method redefined for compatibility purpose only. Calling it will raise an error.
Exceptions:
std::runtime_error whenever this function member is called.

Definition at line 125 of file QIODeviceAdaptor.C.


Member Data Documentation

std::istream* qgxml::QIODeviceAdaptor::_stream [protected]
 

The input stream implementing this IODevice.

This data member is the 'real' implementation of the IODevice. Every calls to a function member of this class is translated and redirected to it.

Definition at line 247 of file QIODeviceAdaptor.H.

Referenced by flush(), getch(), readBlock(), and ungetch().


The documentation for this class was generated from the following files: