tfel
Loading...
Searching...
No Matches
tfel::utilities::TextData Struct Reference

class in charge of reading data in a text file More...

#include </home/runner/work/tfel/tfel/include/TFEL/Utilities/TextData.hxx>

Classes

struct  Line
 helper class in charge of storing of line of data line starting with '#' ared considered comments and not stored. If the first line begins with a '#', the following words are intepreted as the title of each column More...

Public Types

using size_type = Token::size_type
 a simple alias

Public Member Functions

 TextData (const std::string &, const std::string &="")
 constructor
 TextData (TextData &&)=delete
 TextData (const TextData &)=delete
TextData & operator= (TextData &&)=delete
TextData & operator= (const TextData &)=delete
std::vector< double > getColumn (const size_type) const
void getColumn (std::vector< double > &, const size_type) const
 extract the specified column, converting all values to double
size_type findColumn (const std::string &) const
const std::vector< std::string > & getLegends () const
std::string getLegend (const size_type c) const
std::vector< Line >::const_iterator begin () const
std::vector< Line >::const_iterator end () const
const std::vector< std::string > & getPreamble () const
void skipLines (const Token::size_type)

Detailed Description

class in charge of reading data in a text file

Constructor & Destructor Documentation

◆ TextData()

tfel::utilities::TextData::TextData ( const std::string & ,
const std::string & = "" )
explicit

constructor

Parameters
[in]file: file name
[in]format: file format Available file formats include:
  • the default. If the first line is a comment, column legends are extracted out of it. If the next lines are comments, they are added to the preamble.
  • gnuplot (also called alcyone). The first line is not a comment but column legends are extracted out of it. This is the behaviour of gnuplot when the following command is used: set key autotitle columnhead

Member Function Documentation

◆ begin()

std::vector< Line >::const_iterator tfel::utilities::TextData::begin ( ) const
nodiscard
Returns
an iterator to the first line

◆ end()

std::vector< Line >::const_iterator tfel::utilities::TextData::end ( ) const
nodiscard
Returns
an iterator past the last line

◆ findColumn()

size_type tfel::utilities::TextData::findColumn ( const std::string & ) const
nodiscard
Returns
the column having the specified title
Parameters
[in]name: column title
Exceptions
std::runtime_errorif no column with the specified title is found

◆ getColumn() [1/2]

std::vector< double > tfel::utilities::TextData::getColumn ( const size_type ) const
nodiscard
Parameters
[in]i: column number
Returns
the specified column, converting all values to double
Exceptions
std::runtime_errorif a line is shorter than the specified column number or if a value can't be converted to a double

◆ getColumn() [2/2]

void tfel::utilities::TextData::getColumn ( std::vector< double > & ,
const size_type  ) const

extract the specified column, converting all values to double

Parameters
[out]tab: column values
[in]i: column number
Exceptions
std::runtime_errorif a line is shorter than the specified column number or if a value can't be converted to a double

◆ getLegend()

std::string tfel::utilities::TextData::getLegend ( const size_type c) const
nodiscard
Returns
the title of the specified column
Parameters
[in]c: column number
Exceptions
std::runtime_errorif no title is found

◆ getLegends()

const std::vector< std::string > & tfel::utilities::TextData::getLegends ( ) const
nodiscard
Returns
the legend associated to the curves

◆ getPreamble()

const std::vector< std::string > & tfel::utilities::TextData::getPreamble ( ) const
nodiscard

get the first commented lines

◆ skipLines()

void tfel::utilities::TextData::skipLines ( const Token::size_type )

skip the first lines of the file

Parameters
[in]n: number of lines to be skipped

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