Public Member Functions | List of all members
openfluid::tools::ColumnTextParser Class Reference

#include <tools/ColumnTextParser.hpp>

Public Member Functions

 ColumnTextParser (const std::string &CommentLineSymbol="", const std::string &Delimiter=" \\)
 
 ~ColumnTextParser ()
 
bool loadFromFile (const std::string &Filename)
 
bool setFromString (const std::string &Contents, unsigned int ColumnsNbr)
 
std::string getValue (unsigned int Line, unsigned int Column) const
 
bool getStringValue (unsigned int Line, unsigned int Column, std::string *Value) const
 
bool getLongValue (unsigned int Line, unsigned int Column, long *Value) const
 
bool getDoubleValue (unsigned int Line, unsigned int Column, double *Value) const
 
std::vector< std::string > getValues (unsigned int Line) const
 
unsigned int getLinesCount () const
 
unsigned int getColsCount () const
 
void streamContents (std::ostream &OStream) const
 

Detailed Description

Class for column file management and handling

Constructor & Destructor Documentation

◆ ColumnTextParser()

openfluid::tools::ColumnTextParser::ColumnTextParser ( const std::string &  CommentLineSymbol = "")

Constructor

◆ ~ColumnTextParser()

openfluid::tools::ColumnTextParser::~ColumnTextParser ( )

Destructor

Member Function Documentation

◆ getColsCount()

unsigned int openfluid::tools::ColumnTextParser::getColsCount ( ) const
inline

Returns the number of columns

Returns
the number of columns

◆ getDoubleValue()

bool openfluid::tools::ColumnTextParser::getDoubleValue ( unsigned int  Line,
unsigned int  Column,
double *  Value 
) const

Gets the value at a specified row-column, as a double precision float

Parameters
[in]Linethe line number of the value (first line is 0)
[in]Columnthe column number of the value (first column is 0)
[out]Valuethe requested value if exists
Returns
true if the value has been found, false otherwise

◆ getLinesCount()

unsigned int openfluid::tools::ColumnTextParser::getLinesCount ( ) const
inline

Returns the number of lines

Returns
the number of lines

◆ getLongValue()

bool openfluid::tools::ColumnTextParser::getLongValue ( unsigned int  Line,
unsigned int  Column,
long *  Value 
) const

Gets the value at a specified row-column, as a long int

Parameters
[in]Linethe line number of the value (first line is 0)
[in]Columnthe column number of the value (first column is 0)
[out]Valuethe requested value if exists
Returns
true if the value has been found, false otherwise

◆ getStringValue()

bool openfluid::tools::ColumnTextParser::getStringValue ( unsigned int  Line,
unsigned int  Column,
std::string *  Value 
) const

Gets the value at a specified row-column, as a string

Parameters
[in]Linethe line number of the value (first line is 0)
[in]Columnthe column number of the value (first column is 0)
[out]Valuethe requested value if exists
Returns
true if the value has been found, false otherwise

◆ getValue()

std::string openfluid::tools::ColumnTextParser::getValue ( unsigned int  Line,
unsigned int  Column 
) const

Returns the value at a specified row-column, as a string

Parameters
[in]Linethe line number of the value (first line is 0)
[in]Columnthe column number of the value (first column is 0)
Returns
the requested value

◆ getValues()

std::vector<std::string> openfluid::tools::ColumnTextParser::getValues ( unsigned int  Line) const

Returns the values at a specified line

Parameters
[in]Linethe line number of the value (first line is 0)
Returns
the requested values

◆ loadFromFile()

bool openfluid::tools::ColumnTextParser::loadFromFile ( const std::string &  Filename)

Loads a column text file

Parameters
[in]Filenamethe full path of the file to load
Returns
true if everything went fine

◆ setFromString()

bool openfluid::tools::ColumnTextParser::setFromString ( const std::string &  Contents,
unsigned int  ColumnsNbr 
)

Parses a one-line delimiter-separated string to set contents ex: "147.2 18 15 25 36 51.3 25.1 15", for 4 columns

Parameters
[in]Contentsthe string to parse
[in]ColumnsNbrthe number of columns (for splitting the sting into lines)
Returns
true if everything went fine

◆ streamContents()

void openfluid::tools::ColumnTextParser::streamContents ( std::ostream &  OStream) const

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