Home · All Classes · All Functions ·

QVersitReader Class Reference

The QVersitReader class provides an interface for reading versit documents such as vCards from a stream. More...

    #include <QVersitReader>

Inherits QObject.


Public Functions

QVersitReader ()
~QVersitReader ()
QIODevice * device () const
bool readAll ()
QList<QVersitDocument> result () const
void setDevice ( QIODevice * device )
bool startReading ()

Signals

void readingDone ()

Additional Inherited Members


Detailed Description

The QVersitReader class provides an interface for reading versit documents such as vCards from a stream.

QVersitReader reads 0..n versit documents such as vCards from a text stream into 0..n QVersitDocument instances. QVersitReader supports reading from an abstract I/O device which can be for example a file or a memory buffer. The reading can be done synchronously or asynchronously.

    // An example of reading a simple vCard from a memory buffer:
    QBuffer vCardBuffer;
    vCardBuffer.open(QBuffer::ReadWrite);
    QByteArray vCard =
        "BEGIN:VCARD\r\nVERSION:2.1\r\nN:Citizen;John;Q;;\r\nEND:VCARD\r\n";
    vCardBuffer.write(vCard);
    vCardBuffer.seek(0);
    QVersitReader reader;
    reader.setDevice(&vCardBuffer);
    if (reader.readAll()) {
        QList<QVersitDocument> versitDocuments = reader.result();
        // Use the resulting document(s)...
    }

See also QVersitDocument.


Member Function Documentation

QVersitReader::QVersitReader ()

Constructs a new reader.

QVersitReader::~QVersitReader ()

Frees the memory used by the reader. Waits until a pending asynchronous reading has been completed.

QIODevice * QVersitReader::device () const

Returns the device used for reading input.

See also setDevice().

bool QVersitReader::readAll ()

Reads the input synchronously. Returns false if the input device has not been set or opened or if there is an asynchronous read operation pending. Using this function may block the user thread for an undefined period. In most cases asynchronous startReading() should be used instead.

void QVersitReader::readingDone ()   [signal]

The signal is emitted by the reader when the asynchronous reading has been completed.

QList<QVersitDocument> QVersitReader::result () const

Returns the reading result or an empty list if the reading was not completed successfully.

void QVersitReader::setDevice ( QIODevice * device )

Sets the device used for reading the input to be the given device device.

See also device().

bool QVersitReader::startReading ()

Starts reading the input asynchronously. Returns false if the input device has not been set or opened or if there is another asynchronous read operation already pending. Signal readingDone() is emitted when the reading has finished.


Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies) Trademarks
Qt Mobility Project 1.0.0 (Technology Preview)