Class for reading ASCII data files. More...
#include <readascii.hpp>
Public Member Functions | |
ReadAscii () | |
Constructor for empty class. | |
ReadAscii (const std::string &filename, int columns=-1) | |
Constructor for class from file. | |
~ReadAscii () | |
Destructor. | |
void | read (const std::string &filename, int columns=-1) |
Read ASCII data file. | |
void | clear (void) |
Clear data. | |
uint32_t | columns (void) const |
Return number of columns in data. | |
uint32_t | rows (void) const |
Return number of rows in data. | |
const std::vector< double > & | operator[] (uint32_t i) const |
Return const reference to the vector containing column i. | |
Class for reading ASCII data files.
Reads ASCII data file formatted into N columns skipping empty lines and lines starting with '#' character. The number of columns may be given to read function, in which case it is checked to be correct or the number of columns may be determined from the start of the file. The number of columns must be fixed and may not change during the file. Data is stored into N double-type vectors, which can be read from the object after reading a datafile.
ReadAscii::ReadAscii | ( | ) |
Constructor for empty class.
ReadAscii::ReadAscii | ( | const std::string & | filename, |
int | columns = -1 |
||
) |
Constructor for class from file.
Read ASCII data file from filename. If columns is -1 the number of data columns is determined from the file. If the number of columns is given the file is checked to have the columns.
ReadAscii::~ReadAscii | ( | ) |
Destructor.
void ReadAscii::clear | ( | void | ) |
Clear data.
|
inline |
Return number of columns in data.
const std::vector<double>& ReadAscii::operator[] | ( | uint32_t | i | ) | const |
Return const reference to the vector containing column i.
void ReadAscii::read | ( | const std::string & | filename, |
int | columns = -1 |
||
) |
Read ASCII data file.
Read ASCII data file from filename. If columns is -1 the number of data columns is determined from the file. If the number of columns is given the file is checked to have the columns.
|
inline |
Return number of rows in data.