Qx v0.5.8
Qt Extensions Library
Loading...
Searching...
No Matches
Qx::DsvTable Class Reference

The DsvTable class provides a mutable representation of delimiter-separated values. More...

#include <qx/core/qx-dsvtable.h>

Collaboration diagram for Qx::DsvTable:
[legend]

Public Member Functions

 DsvTable ()
 
 DsvTable (QSize size)
 
 DsvTable (QSize size, const QVariant &value)
 
 DsvTable (std::initializer_list< std::initializer_list< QVariant > > table)
 
QByteArray toDsv (QChar delim=',', QChar esc='"')
 
- Public Member Functions inherited from Qx::Table< QVariant >
 Table ()
 
 Table (QSize size)
 
 Table (QSize size, const QVariant &value)
 
 Table (std::initializer_list< std::initializer_list< QVariant > > table)
 
void addColumns (qsizetype c)
 
void addRows (qsizetype r)
 
void appendColumn (const QList< QVariant > &c)
 
void appendRow (const QList< QVariant > &r)
 
QVariantat (qsizetype r, qsizetype c)
 
const QVariantat (qsizetype r, qsizetype c) const
 
QSize capacity () const
 
QList< QVariantcolumnAt (qsizetype i) const
 
qsizetype columnCount () const
 
void fill (const QVariant &value, QSize size)
 
QList< QVariantfirstColumn () const
 
const QList< QVariant > & firstRow () const
 
qsizetype height () const
 
void insertColumn (qsizetype i, const QList< QVariant > &c)
 
void insertRow (qsizetype i, const QList< QVariant > &r)
 
bool isEmpty () const
 
QList< QVariantlastColumn () const
 
const QList< QVariant > & lastRow () const
 
bool operator!= (const Table &other) const
 
bool operator== (const Table &other) const
 
void removeColumnAt (qsizetype i)
 
void removeColumns (qsizetype i, qsizetype n=1)
 
void removeFirstColumn ()
 
void removeFirstRow ()
 
void removeLastColumn ()
 
void removeLastRow ()
 
void removeRowAt (qsizetype i)
 
void removeRows (qsizetype i, qsizetype n=1)
 
void replaceColumn (qsizetype i, const QList< QVariant > &c)
 
void replaceRow (qsizetype i, const QList< QVariant > &r)
 
void reserve (QSize size)
 
void resize (QSize size)
 
void resizeColumns (qsizetype size)
 
void resizeRows (qsizetype size)
 
const QList< QVariant > & rowAt (qsizetype i) const
 
row_iterator rowBegin () const
 
qsizetype rowCount () const
 
row_iterator rowEnd () const
 
Table section (qsizetype r, qsizetype c, qsizetype height, qsizetype width) const
 
QSize size () const
 
void squeeze ()
 
QList< QVarianttakeColumnAt (qsizetype i)
 
QList< QVarianttakeFirstColumn ()
 
QList< QVarianttakeFirstRow ()
 
QList< QVarianttakeLastColumn ()
 
QList< QVarianttakeLastRow ()
 
QList< QVarianttakeRowAt (qsizetype i)
 
QVariant value (qsizetype r, qsizetype c) const
 
QVariant value (qsizetype r, qsizetype c, const QVariant &defaultValue) const
 
qsizetype width () const
 

Static Public Member Functions

static DsvTable fromDsv (const QByteArray &dsv, QChar delim=',', QChar esc='"', DsvParseError* error = nullptr)
 

Additional Inherited Members

- Public Types inherited from Qx::Table< QVariant >
typedef QList< QList< QVariant > >::const_iterator row_iterator
 
- Protected Attributes inherited from Qx::Table< QVariant >
QList< QList< QVariant > > mTable
 

Detailed Description

Delimiter-separated values is a format for storing two-dimensional arrays of arbitrary data by separating the fields in each row with a given delimiter character, and separating each row via a line break.

DSV is human readable, flexible, and widely supported.

The most common form of DSV, CSV, uses the comma character , as the delimiter.

DsvTable provides a variety of methods for data manipulation, as well as RFC4180 compliant parsing and serialization of DSV data via fromDsv() and toDsv().

It's data is stored and accessed as instances of QVariant for convenient conversion of each field to its true data type.

See also
DSV (on Wikipedia).

Constructor & Destructor Documentation

◆ DsvTable() [1/4]

Qx::DsvTable::DsvTable ( )

Constructs an empty DsvTable.

◆ DsvTable() [2/4]

Qx::DsvTable::DsvTable ( QSize size)

Constructs a DsvTable with of size size, with every field set to an invalid QVariant.

◆ DsvTable() [3/4]

Qx::DsvTable::DsvTable ( QSize size,
const QVariant & value )

Constructs a DsvTable of size size, with every field set to value.

◆ DsvTable() [4/4]

Qx::DsvTable::DsvTable ( std::initializer_list< std::initializer_list< QVariant > > table)

Constructs a DsvTable with a copy of each row in the initializer list list.

If all rows in the list are not the same size, this constructor will produce an empty table.

Member Function Documentation

◆ fromDsv()

DsvTable Qx::DsvTable::fromDsv ( const QByteArray & dsv,
QChar delim = ',',
QChar esc = '"',
DsvParseError * error = nullptr )
static

Parses dsv as a delimiter-separated values table, using delim as the delimiter and esc as the quote/escape character, and creates a DsvTable from it.

If parsing fails, the returned table will be empty and the optional error variable will contain further details about the error.

See also
toDsv(), DsvTableParseError, and isEmpty().

◆ toDsv()

QByteArray Qx::DsvTable::toDsv ( QChar delim = ',',
QChar esc = '"' )

Converts the DsvTable to a serialized delimiter-separated values byte array, using delim as the delimiter and esc as the quote/escape character.


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