This class handles reading and writing of files with comments using Qt. More...
#include <DGVFile.h>
Public Member Functions | |
DGVFile () | |
Constructor. | |
DGVFile (QString name, QString mode) | |
virtual | ~DGVFile () |
bool | open (QString name, QString mode) |
Open file with filename. Mode is either "r" for read, "w" for write or "a" for append. | |
void | close () |
Close the current file. | |
void | writeLine (QString data) |
Write the line given by "data" to the current file. | |
void | writeIntegerArrayAsLine (Array< long, 1 > &data) |
Write the line given by the array "data" to the current file. | |
void | writeDoubleArrayAsLine (Array< double, 1 > &data) |
Write the line given by the array "data" to the current file. | |
void | writeComment (QString comment) |
Write the comment to the current file. | |
QString | readNextString () |
Read the next element as a string from the current file. NOT IMPLEMENTED! | |
long | readNextInteger () |
Read the next element as an integer from the current file. NOT IMPLEMENTED! | |
double | readNextDouble () |
Read the next element as an double from the current file. NOT IMPLEMENTED! | |
QStringList | readLine () |
Read the next line as a string list from the current file. Same as readNextLine(). | |
QStringList | readNextLine () |
Read the next line as a string list from the current file. | |
void | readNextLineAsIntegers (Array< long, 1 > &values) |
Read the next line as a integer list from the current file. Array is automatically resized to correct size. | |
void | readNextLineAsDoubles (Array< double, 1 > &values) |
Read the next line as a double list from the current file. Array is automatically resized to correct size. | |
void | setSeparator (QString symbol) |
Set the separator of the data in the current file. | |
void | setCommentSymbol (QString symbol) |
Set the comment symbol of the data in the current file. | |
void | ignoreComments (bool ignore) |
Ignore comments in the current file. Default is true. | |
bool | atEnd () |
Return true if the end of the current file is reached. | |
void | setVerboseMode (bool verbose) |
Read as much of the file as possible. Useful in comment ignore mode if file has empty entries. | |
Protected Attributes | |
QString | commentSymbol |
QString | separator |
bool | comments |
bool | openedIn |
bool | openedOut |
bool | openedAppend |
bool | verboseMode |
QString | fileName |
QString | fileMode |
QFile | file |
QTextStream * | in |
QTextStream * | out |
QTextStream * | append |
This class handles reading and writing of files with comments using Qt.
It is mainly used to read/write CSV and Diophantine (to setup a system using DGVLatticeVTK and DGVDiophantineVTK classes) files.
Mode needs to be set for the operation that needs to be done. Mode is either "r" for read, "w" for write or "a" for append.
Definition at line 40 of file DGVFile.h.
DGVFile::DGVFile | ( | ) |
Constructor.
Constructor with filename and mode pass in. Mode is either "r" for read, "w" for write or "a" for append.
Equivalent to calling open().
Definition at line 24 of file DGVFile.cpp.
DGVFile::DGVFile | ( | QString | name, | |
QString | mode | |||
) |
Definition at line 35 of file DGVFile.cpp.
DGVFile::~DGVFile | ( | ) | [virtual] |
Definition at line 48 of file DGVFile.cpp.
bool DGVFile::atEnd | ( | ) |
Return true if the end of the current file is reached.
Definition at line 252 of file DGVFile.cpp.
void DGVFile::close | ( | ) |
Close the current file.
Definition at line 101 of file DGVFile.cpp.
DGVFile::ignoreComments | ( | bool | ignore | ) | [inline] |
bool DGVFile::open | ( | QString | name, | |
QString | mode | |||
) |
Open file with filename. Mode is either "r" for read, "w" for write or "a" for append.
Definition at line 53 of file DGVFile.cpp.
DGVFile::readLine | ( | ) | [inline] |
Read the next line as a string list from the current file. Same as readNextLine().
DGVFile::readNextDouble | ( | ) |
Read the next element as an double from the current file. NOT IMPLEMENTED!
DGVFile::readNextInteger | ( | ) |
Read the next element as an integer from the current file. NOT IMPLEMENTED!
QStringList DGVFile::readNextLine | ( | ) |
Read the next line as a string list from the current file.
Check for comments Ignore if present and told to ignore
Remove comment (everything after comment symbol
Definition at line 196 of file DGVFile.cpp.
void DGVFile::readNextLineAsDoubles | ( | Array< double, 1 > & | values | ) |
Read the next line as a double list from the current file. Array is automatically resized to correct size.
Definition at line 241 of file DGVFile.cpp.
void DGVFile::readNextLineAsIntegers | ( | Array< long, 1 > & | values | ) |
Read the next line as a integer list from the current file. Array is automatically resized to correct size.
Definition at line 230 of file DGVFile.cpp.
DGVFile::readNextString | ( | ) |
Read the next element as a string from the current file. NOT IMPLEMENTED!
DGVFile::setCommentSymbol | ( | QString | symbol | ) | [inline] |
DGVFile::setSeparator | ( | QString | symbol | ) | [inline] |
DGVFile::setVerboseMode | ( | bool | verbose | ) | [inline] |
void DGVFile::writeComment | ( | QString | comment | ) | [inline] |
Write the comment to the current file.
Definition at line 152 of file DGVFile.cpp.
void DGVFile::writeDoubleArrayAsLine | ( | Array< double, 1 > & | data | ) |
Write the line given by the array "data" to the current file.
Definition at line 142 of file DGVFile.cpp.
void DGVFile::writeIntegerArrayAsLine | ( | Array< long, 1 > & | data | ) |
Write the line given by the array "data" to the current file.
Definition at line 132 of file DGVFile.cpp.
void DGVFile::writeLine | ( | QString | data | ) |
Write the line given by "data" to the current file.
Definition at line 119 of file DGVFile.cpp.
QTextStream* DGVFile::append [protected] |
bool DGVFile::comments [protected] |
QString DGVFile::commentSymbol [protected] |
QFile DGVFile::file [protected] |
QString DGVFile::fileMode [protected] |
QString DGVFile::fileName [protected] |
QTextStream* DGVFile::in [protected] |
bool DGVFile::openedAppend [protected] |
bool DGVFile::openedIn [protected] |
bool DGVFile::openedOut [protected] |
QTextStream* DGVFile::out [protected] |
QString DGVFile::separator [protected] |
bool DGVFile::verboseMode [protected] |