QTextStream Class Reference


The QTextStream class provides basic functions for reading and writing text to an QIODevice. (details) (complete member list)

#include <qtstream.h>

Public Members


Detailed Description

The QTextStream class provides basic functions for reading and writing text to an QIODevice.

The text stream class a functional interface that is very similar to that of the standard C++ iostream class. The difference between iostream and QTextStream is that our stream operates on a QIODevice.

The QTextStream class reads and writes ASCII text and it is not appropriate for dealing with binary data (but QDataStream is).

See also: QDataStream.


Member Function Documentation

QTextStream::QTextStream ()

Constructs a data stream that has no IO device.

QTextStream::QTextStream (FILE *fh)

Constructs a data stream that uses the file handle fh (sort of IO device).

This constructor makes it convenient to do such things:

  QTextStream cout( stdout );
  QTextStream cin ( stdin );
  QTextStream cerr( stderr );

QTextStream::QTextStream (QIODevice *d)

Constructs a text stream that uses the IO device d.

QTextStream::~QTextStream ()

Destroys the text stream.

The destructor will not affect the current IO device.

QIODevice * QTextStream::device () const

Returns the IO device currently set.

bool QTextStream::eos () const

Returns TRUE if the IO device has reached the end position (end of stream) or if there is no IO device set.

Returns FALSE if the current position of the read/write head of the IO device is somewhere before the end position.

QTextStream & QTextStream::operator<< (char c)

Writes a char to the stream and returns a reference to the stream.

QTextStream & QTextStream::operator<< (signed short i)

Writes a signed short integer to the stream and returns a reference to the stream.

QTextStream & QTextStream::operator<< (unsigned short i)

Writes an unsigned short integer to the stream and returns a reference to the stream.

QTextStream & QTextStream::operator<< (signed int i)

Writes a signed int to the stream and returns a reference to the stream.

QTextStream & QTextStream::operator<< (unsigned int i)

Writes an unsigned int to the stream and returns a reference to the stream.

QTextStream & QTextStream::operator<< (signed long i)

Writes a signed long int to the stream and returns a reference to the stream.

QTextStream & QTextStream::operator<< (unsigned long i)

Writes an unsigned long int to the stream and returns a reference to the stream.

QTextStream & QTextStream::operator<< (float f)

Writes a float to the stream and returns a reference to the stream.

QTextStream & QTextStream::operator<< (double f)

Writes a double to the stream and returns a reference to the stream.

QTextStream & QTextStream::operator<< (const char *s)

Writes a string to the stream and returns a reference to the stream.

QTextStream & QTextStream::operator<< (void *ptr)

Writes a pointer to the stream and returns a reference to the stream.

The ptr is output as an unsigned long hexadecimal integer.

QTextStream & QTextStream::operator>> (char &c)

Reads a char from the stream and returns a reference to the stream.

QTextStream & QTextStream::operator>> (signed short &i)

Reads a signed short integer from the stream and returns a reference to the stream.

QTextStream & QTextStream::operator>> (unsigned short &i)

Reads an unsigned short integer from the stream and returns a reference to the stream.

QTextStream & QTextStream::operator>> (signed int &i)

Reads a signed int from the stream and returns a reference to the stream.

QTextStream & QTextStream::operator>> (unsigned int &i)

Reads an unsigned int from the stream and returns a reference to the stream.

QTextStream & QTextStream::operator>> (signed long &i)

Reads a signed long int from the stream and returns a reference to the stream.

QTextStream & QTextStream::operator>> (unsigned long &i)

Reads an unsigned long int from the stream and returns a reference to the stream.

QTextStream & QTextStream::operator>> (float &f)

Reads a float from the stream and returns a reference to the stream.

QTextStream & QTextStream::operator>> (double &)

Reads a double from the stream and returns a reference to the stream.

QTextStream & QTextStream::operator>> (char *&)

Reads a string from the stream and returns a reference to the stream.

QTextStream & QTextStream::readRawBytes (char *s, uint len)

Reads len bytes from the stream into e s and returns a reference to the stream.

The buffer s must be preallocated.

See also: QIODevice::readBlock().

void QTextStream::reset ()

Resets the text stream.

See also: setf() width(), fill() and precision().

void QTextStream::setDevice (QIODevice *d)

Sets the IO device to d.

void QTextStream::unsetDevice ()

Unsets the IO device.

Same as calling setDevice( 0 ).

QTextStream & QTextStream::writeRawBytes (const char *s, uint len)

Writes the len bytes from s to the stream and returns a reference to the stream.

See also: QIODevice::writeBlock().


This file is part of the Qt toolkit, copyright 1995 Troll Tech, all rights reserved.

It was generated from the following files:


Generated at 16:17, 1995/06/30 by the webmaster at Troll Tech