Public Member Functions | List of all members
ReadAscii Class Reference

Class for reading ASCII data files. More...

#include <readascii.hpp>

Public Member Functions

 ReadAscii ()
 Constructor for empty class. More...
 
 ReadAscii (const std::string &filename, int columns=-1)
 Constructor for class from file. More...
 
 ~ReadAscii ()
 Destructor. More...
 
void read (const std::string &filename, int columns=-1)
 Read ASCII data file. More...
 
void clear (void)
 Clear data. More...
 
uint32_t columns (void) const
 Return number of columns in data. More...
 
uint32_t rows (void) const
 Return number of rows in data. More...
 
const std::vector< double > & operator[] (uint32_t i) const
 Return const reference to the vector containing column i. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

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.

Member Function Documentation

void ReadAscii::clear ( void  )

Clear data.

uint32_t ReadAscii::columns ( void  ) const
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.

uint32_t ReadAscii::rows ( void  ) const
inline

Return number of rows in data.


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