The QTextStream class provides basic functions for reading and writing text using a QIODevice. More...
#include <qtstream.h>
The text stream class has 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).
This class is not fully documented yet.
See also: QDataStream.
Constructs a text stream that operates on a byte array throught an internal QBuffer device.
Example:
QString str; QTextStream ts( str, IO_WriteOnly ); ts << "pi = " << 3.14; // str == "pi = 3.14"
Writing data to the text stream will modify the contents of the string. The string will be expanded when data is written beyond the end of the string.
Same example, using a QBuffer:
QString str; QBuffer buf( str ); buf.open( IO_ReadOnly ); QTextStream ts( &str, IO_WriteOnly ); ts << "pi = " << 3.14; // str == "pi = 3.14" buf.close();
Constructs a text stream that uses the IO device d.
Constructs a text stream that operates on an existing file handle fh throught an internal QFile device.
Example:
QTextStream cout( stdout, IO_WriteOnly ); QTextStream cin ( stdin, IO_ReadOnly ); QTextStream cerr( stderr, IO_WriteOnly );
Constructs a data stream that has no IO device.
[virtual]
Destroys the text stream.
The destructor will not affect the current IO device.
Returns the IO device currently set.
See also: setDevice() and unsetDevice().
Returns TRUE if the IO device has reached the end position (end of stream or file) 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.
See also: QIODevice::atEnd().
Sets the fill character to f. Returns the previous fill character.
Returns the fill character. The default value is ' ' (space).
Sets the stream flags to f. Returns the previous stream flags.
See also: setf() and unsetf().
Returns the current stream flags. The default value is 0.
See also: setf() and unsetf().
Writes a char
to the stream and returns a reference to the stream.
Writes a string to the stream and returns a reference to the stream.
Writes a double
to the stream and returns a reference to the stream.
Writes a float
to the stream and returns a reference to the stream.
Writes an int
to the stream and returns a reference to
the stream.
Writes a long int
to the stream and returns a reference to
the stream.
Writes a short
integer to the stream and returns a reference to
the stream.
Writes an unsigned int
to the stream and returns a reference to
the stream.
Writes an unsigned long int
to the stream and returns a reference to
the stream.
Writes an unsigned short
integer to the stream and returns a reference
to the stream.
Writes a pointer to the stream and returns a reference to the stream.
The ptr is output as an unsigned long hexadecimal integer.
Reads a word from the stream and returns a reference to the stream.
Reads a char
from the stream and returns a reference to the stream.
Reads a word from the stream and returns a reference to the stream.
Reads a double
from the stream and returns a reference to the stream.
Reads a float
from the stream and returns a reference to the stream.
Reads a signed int
from the stream and returns a reference to the
stream.
Reads a signed long
int from the stream and returns a reference to the
stream.
Reads a signed short
integer from the stream and returns a reference to
the stream.
Reads an unsigned int
from the stream and returns a reference to the
stream.
Reads an unsigned long
int from the stream and returns a reference to the
stream.
Reads an unsigned short
integer from the stream and returns a reference to
the stream.
Sets the precision to p. Returns the previous precision setting.
Returns the precision. The default value is 6.
Reads a line from the stream and returns a reference to the stream.
The returned string does not contain any trailing newline or carriage return. Note that this is different from QIODevice::readLine(), which does not strip the newline at the end of the line.
See also: QIODevice::readLine().
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().
Resets the text stream.
See also: setf(), width(), fill() and precision().
Sets the IO device to d.
See also: device() and unsetDevice().
Sets the stream flag bits bits. Returns the previous stream flags.
Equivalent to flags( flags() | bits )
.
See also: setf() and unsetf().
Sets the stream flag bits bits with a bit mask mask. Returns the previous stream flags.
Equivalent to flags( (flags() & ~mask) | (bits & mask) )
.
See also: setf() and unsetf().
Unsets the IO device. Equivalent to setDevice( 0 ).
See also: device() and setDevice().
Clears the stream flag bits bits. Returns the previous stream flags.
Equivalent to flags( flags() & ~mask )
.
See also: setf().
Sets the field width to w. Returns the previous field width.
Returns the field width. The default value is 0.
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-97 Troll Tech, all rights reserved.
It was generated from the following files: