A simple class for loading CSV documents. More...
#include <Radiant/CSVDocument.hpp>
Public Types | |
| typedef std::vector< QString > | Row |
| A single row of data. | |
| typedef std::list< Row > | Rows |
| A list of rows. | |
Public Member Functions | |
| Row * | appendRow () |
| Adds a new row to the end of the table. More... | |
| Rows::iterator | begin () |
| Returns an iterator to the first row in the document. More... | |
| Rows::const_iterator | begin () const |
| Returns an iterator to the first row in the document. More... | |
| void | clear () |
| Clears (empties) the entire CSVDocument. | |
| CSVDocument () | |
| Constructor. | |
| Rows::iterator | end () |
| Returns an iterator after the last row of the document. More... | |
| Rows::const_iterator | end () const |
| Returns an iterator after the last row of the document. More... | |
| int | findColumnOnRow (const QString &key, unsigned rowIndex) |
| Finds column on a given row. More... | |
| Row * | findRow (const QString &key, unsigned col) |
| Finds a row in the document. More... | |
| int | load (const QString &filename, const char *delimiter=",", bool removeQuotations=true) |
| Load a file, and return the number of lines read. More... | |
| int | loadFromString (const QString &csv, const char *delimiter=",", bool removeQuotations=true) |
| Row * | row (unsigned i) |
| Returns a given row. More... | |
| unsigned | rowCount () const |
| Returns the number of rows in the document. More... | |
| bool | save (const QString &filename, const char *delimiter=",", bool useQuotations=true) |
| ~CSVDocument () | |
| Destructor. | |
A simple class for loading CSV documents.
CSV (Comma-Separeted Values) documents are basically spreadsheets, with information placed on rows, with an agreed separator between the cells. The Cells are expected to have quotation marks around the main content. The quotation marks are removed in the reading process, as are leading-, and trailing spaces.
| Row* Radiant::CSVDocument::appendRow | ( | ) |
Adds a new row to the end of the table.
|
inline |
Returns an iterator to the first row in the document.
|
inline |
Returns an iterator to the first row in the document.
|
inline |
Returns an iterator after the last row of the document.
|
inline |
Returns an iterator after the last row of the document.
| int Radiant::CSVDocument::findColumnOnRow | ( | const QString & | key, |
| unsigned | rowIndex | ||
| ) |
Finds column on a given row.
| key | Valy of ccell to be searched |
| rowIndex | Row to search |
| Row* Radiant::CSVDocument::findRow | ( | const QString & | key, |
| unsigned | col | ||
| ) |
Finds a row in the document.
For each row in the document, this function checks if the text in the cell at that column matches the argument key.
| key | The key to match |
| col | The column that is used for matching |
| int Radiant::CSVDocument::load | ( | const QString & | filename, |
| const char * | delimiter = ",", |
||
| bool | removeQuotations = true |
||
| ) |
Load a file, and return the number of lines read.
The file is assumed to be in the UTF-8 format.
| filename | filename to read |
| delimiter | column delimiter |
| removeQuotations | Are the quotations around the value removed |
| Row* Radiant::CSVDocument::row | ( | unsigned | i | ) |
Returns a given row.
If the index is out of range, zero pointer is returned.
This method is quite slow, since it must iterate through each row to find the correct one. If performance is an issue you should use the iterator-functions instead.
| i | index of the row |
|
inline |
Returns the number of rows in the document.