Qx v0.7
Qt Extensions Library
Loading...
Searching...
No Matches
Qx::TextStream Class Reference

The TextStream class is a more robust variant of QTextStream, which provides a convenient interface for reading and writing text. More...

#include <qx/io/qx-textstream.h>

Public Member Functions

 TextStream (const QByteArray &array, QIODevice::OpenMode openMode=QIODevice::ReadOnly)
 
 TextStream (FILE *fileHandle, QIODevice::OpenMode openMode=QIODevice::ReadWrite)
 
 TextStream (QByteArray *array, QIODevice::OpenMode openMode=QIODevice::ReadWrite)
 
 TextStream (QIODevice *device)
 
 TextStream (QString *string, QIODevice::OpenMode openMode=QIODevice::ReadWrite)
 
bool precedingBreak ()
 
QString readLineWithBreak (qint64 maxlen=0)
 

Detailed Description

TextStream derives from QTextStream and therefore shares all of its functionality, but this Qx variant provides additional facilities not present in its base class.

Constructor & Destructor Documentation

◆ TextStream() [1/5]

Qx::TextStream::TextStream ( const QByteArray & array,
QIODevice::OpenMode openMode = QIODevice::ReadOnly )

Constructs a QTextStream that operates on array, using openMode to define the open mode. The array is accessed as read-only, regardless of the values in openMode.

See also
QTextStream::QTextStream(const QByteArray &array, QIODevice::OpenMode openMode).

◆ TextStream() [2/5]

Qx::TextStream::TextStream ( QByteArray * array,
QIODevice::OpenMode openMode = QIODevice::ReadWrite )

Constructs a QTextStream that operates on array, using openMode to define the open mode. Internally, the array is wrapped by a QBuffer.

◆ TextStream() [3/5]

Qx::TextStream::TextStream ( QString * string,
QIODevice::OpenMode openMode = QIODevice::ReadWrite )

Constructs a QTextStream that operates on string, using openMode to define the open mode.

◆ TextStream() [4/5]

Qx::TextStream::TextStream ( FILE * fileHandle,
QIODevice::OpenMode openMode = QIODevice::ReadWrite )

Constructs a QTextStream that operates on fileHandle, using openMode to define the open mode. Internally, a QFile is created to handle the FILE pointer.

See also
QTextStream::TextStream(FILE* fileHandle, QIODevice::OpenMode openMode).

◆ TextStream() [5/5]

Qx::TextStream::TextStream ( QIODevice * device)

Constructs a QTextStream that operates on device.

Member Function Documentation

◆ precedingBreak()

bool Qx::TextStream::precedingBreak ( )

Returns true if the character at the stream's current position - 1 is the line feed character ('\n'), or rather, that the stream is currently positioned immediately after a line break; otherwise returns false.

Warning
This function should be used conservatively as it temporarily seeks within the stream and may require a rebuild of its internal buffer.

◆ readLineWithBreak()

QString Qx::TextStream::readLineWithBreak ( qint64 maxlen = 0)

Same as readLine() except that trailing new line characters are not discarded.

Warning
If maxlen is > 0, this function temporarily seeks within the stream and may require a rebuild of its internal buffer. This significantly hinders the performance of the stream when used in rapid succession (e.g. in a loop), so great care should be taken to use this function with such an argument sparingly.

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