kaddressbook
#include <qcsvreader.h>
Public Member Functions | |
QCsvReader (QCsvBuilderInterface *builder) | |
~QCsvReader () | |
QChar | delimiter () const |
bool | read (QIODevice *device) |
void | setDelimiter (const QChar &delimiter) |
void | setStartRow (uint startRow) |
void | setTextCodec (QTextCodec *textCodec) |
void | setTextQuote (const QChar &textQuote) |
uint | startRow () const |
void | terminate () |
QTextCodec * | textCodec () const |
QChar | textQuote () const |
Public Member Functions inherited from QObject | |
QObject (QObject *parent) | |
QObject (QObject *parent, const char *name) | |
virtual | ~QObject () |
bool | blockSignals (bool block) |
QObject * | child (const char *objName, const char *inheritsClass, bool recursiveSearch) const |
const QObjectList & | children () const |
const char * | className () const |
bool | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const |
void | deleteLater () |
void | destroyed (QObject *obj) |
bool | disconnect (const QObject *receiver, const char *method) |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) |
void | dumpObjectInfo () |
void | dumpObjectTree () |
QList< QByteArray > | dynamicPropertyNames () const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name) const |
QList< T > | findChildren (const QRegExp ®Exp) const |
QList< T > | findChildren (const QString &name) const |
bool | inherits (const char *className) const |
void | insertChild (QObject *object) |
void | installEventFilter (QObject *filterObj) |
bool | isA (const char *className) const |
bool | isWidgetType () const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const |
void | moveToThread (QThread *targetThread) |
const char * | name () const |
const char * | name (const char *defaultName) const |
QString | objectName () const |
QObject * | parent () const |
QVariant | property (const char *name) const |
void | removeChild (QObject *object) |
void | removeEventFilter (QObject *obj) |
void | setName (const char *name) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | signalsBlocked () const |
int | startTimer (int interval) |
QThread * | thread () const |
Properties | |
QChar | delimiter |
uint | startRow |
QChar | textQuote |
Properties inherited from QObject | |
objectName | |
Additional Inherited Members | |
Static Public Member Functions inherited from QObject | |
bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
Protected Member Functions inherited from QObject | |
bool | checkConnectArgs (const char *signal, const QObject *object, const char *method) |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const char *signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const char *signal) |
int | receivers (const char *signal) const |
QObject * | sender () const |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *event) |
Static Protected Member Functions inherited from QObject | |
QByteArray | normalizeSignalSlot (const char *signalSlot) |
Detailed Description
A parser for comma separated value data.
QCsvReader is a class that reads a comma separated value list (csv) from a device and parses it into its fields. The parsed data are passed to a QCsvBuilderInterface instance, which can build up arbitrary data structures from it.
Definition at line 91 of file qcsvreader.h.
Constructor & Destructor Documentation
|
explicit |
Creates a new csv reader.
- Parameters
-
builder The builder to use.
Definition at line 78 of file qcsvreader.cpp.
QCsvReader::~QCsvReader | ( | ) |
Destroys the csv reader.
Definition at line 84 of file qcsvreader.cpp.
Member Function Documentation
QChar QCsvReader::delimiter | ( | ) | const |
Returns the delimiter that is used as delimiter for fields.
bool QCsvReader::read | ( | QIODevice * | device | ) |
Parses the csv data from device
.
- Returns
- true on success, false otherwise.
We use the following state machine to parse CSV:
digraph { StartLine -> StartLine [label="\\r\\n"] StartLine -> QuotedField [label="Quote"] StartLine -> EmptyField [label="Delimiter"] StartLine -> NormalField [label="Other Char"]
QuotedField -> QuotedField [label="\\r\\n"] QuotedField -> QuotedFieldEnd [label="Quote"] QuotedField -> QuotedField [label="Delimiter"] QuotedField -> QuotedField [label="Other Char"]
QuotedFieldEnd -> StartLine [label="\\r\\n"] QuotedFieldEnd -> QuotedField [label="Quote"] QuotedFieldEnd -> EmptyField [label="Delimiter"] QuotedFieldEnd -> EmptyField [label="Other Char"]
EmptyField -> StartLine [label="\\r\\n"] EmptyField -> QuotedField [label="Quote"] EmptyField -> EmptyField [label="Delimiter"] EmptyField -> NormalField [label="Other Char"]
NormalField -> StartLine [label="\\r\\n"] NormalField -> NormalField [label="Quote"] NormalField -> EmptyField [label="Delimiter"] NormalField -> NormalField [label="Other Char"] }
Definition at line 89 of file qcsvreader.cpp.
void QCsvReader::setDelimiter | ( | const QChar & | delimiter | ) |
Sets the character that is used as delimiter for fields.
The default is ' '.
Definition at line 277 of file qcsvreader.cpp.
void QCsvReader::setStartRow | ( | uint | startRow | ) |
Sets the row from where the parsing shall be started.
Some csv files have some kind of header in the first line with the column titles. To retrieve only the real data, set the start row to '1' in this case.
The default start row is 0.
Definition at line 287 of file qcsvreader.cpp.
void QCsvReader::setTextCodec | ( | QTextCodec * | textCodec | ) |
Sets the text codec that shall be used for parsing the csv list.
The default is the system locale.
Definition at line 297 of file qcsvreader.cpp.
void QCsvReader::setTextQuote | ( | const QChar & | textQuote | ) |
Sets the character that is used for quoting.
The default is '"'.
Definition at line 267 of file qcsvreader.cpp.
uint QCsvReader::startRow | ( | ) | const |
Returns the start row.
void QCsvReader::terminate | ( | ) |
Terminates the parsing of the csv data.
Definition at line 307 of file qcsvreader.cpp.
QTextCodec * QCsvReader::textCodec | ( | ) | const |
Returns the text codec that is used for parsing the csv list.
Definition at line 302 of file qcsvreader.cpp.
QChar QCsvReader::textQuote | ( | ) | const |
Returns the character that is used for quoting.
Property Documentation
|
readwrite |
Definition at line 96 of file qcsvreader.h.
|
readwrite |
Definition at line 97 of file qcsvreader.h.
|
readwrite |
Definition at line 95 of file qcsvreader.h.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:32:34 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.