Documentation of MARTY
A Modern ARtificial Theoretical phYsicist
Static Public Member Functions | Static Public Attributes | Static Private Member Functions
mty::lha::Reader Class Reference

Class the reads .lha file, parses them and create a LHAFileData containing all blocks with their elements. More...

#include <lha.h>

Static Public Member Functions

static LHAFileData readFile (std::string const &fileName)
 Reads a .lha file and returns its data. More...
 
static LHAFileData readFile (std::ifstream &in)
 Reads a .lha file and returns its data. More...
 

Static Public Attributes

static bool verbose = false
 Tells if warning messages must be printed during the read of .lha files.
 

Static Private Member Functions

static std::string nextLine (std::ifstream &in)
 Reads a line in in and removes comments (with '#'). More...
 
static std::vector< std::string > split (std::string const &line)
 Splits a string into pieces, separating by space and line break. More...
 
static bool isBlockLine (std::vector< std::string > const &line)
 Tells if a line (vector of string) is a block line. More...
 
static bool isPositiveInteger (std::string const &str)
 Tells if a string corresponds to a positive integer. More...
 
static bool isNumber (std::string const &str)
 Tells if a string corresponds to a number, integer or floating point (standard or scientific notation). More...
 
static bool isValueLine (std::vector< std::string > const &line)
 Tells if a line contains a value. More...
 
static LHAElement readValue (std::vector< std::string > const &line)
 Reads a line and returns the LHAElement corresponding to it. More...
 

Detailed Description

Class the reads .lha file, parses them and create a LHAFileData containing all blocks with their elements.

Member Function Documentation

◆ isBlockLine()

bool mty::lha::Reader::isBlockLine ( std::vector< std::string > const &  line)
staticprivate

Tells if a line (vector of string) is a block line.

A line is considered as the beginning of a block if there is at least two words and the first is exactly (case-sensitive) "BLOCK".

Parameters
lineLine of the file.
Returns
True if the line is a block definition.
False else.

◆ isNumber()

bool mty::lha::Reader::isNumber ( std::string const &  str)
staticprivate

Tells if a string corresponds to a number, integer or floating point (standard or scientific notation).

Parameters
strString to test.
Returns
True if the string is a number.
False else.

◆ isPositiveInteger()

bool mty::lha::Reader::isPositiveInteger ( std::string const &  str)
staticprivate

Tells if a string corresponds to a positive integer.

Parameters
strString to test.
Returns
True if the string is a positive integer.
False else.

◆ isValueLine()

bool mty::lha::Reader::isValueLine ( std::vector< std::string > const &  line)
staticprivate

Tells if a line contains a value.

This function considers that the line defines a value if words befire the last are positive integers (there must be at least one) and if the last is a number.

Parameters
lineLine to test.
Returns
True if the line is the definition of a value.
See also
isPositiveInteger(), isNumber()

◆ nextLine()

std::string mty::lha::Reader::nextLine ( std::ifstream &  in)
staticprivate

Reads a line in in and removes comments (with '#').

Parameters
inInput file stream.
Returns
A string with the next line in the file with comments removed.

◆ readFile() [1/2]

LHAFileData mty::lha::Reader::readFile ( std::string const &  fileName)
static

Reads a .lha file and returns its data.

Parameters
fileNameName of the file.
Returns
A LHAFileData object containing the file data, block by block.

◆ readFile() [2/2]

LHAFileData mty::lha::Reader::readFile ( std::ifstream &  in)
static

Reads a .lha file and returns its data.

Parameters
inInput file stream for the .lha file.
Returns
A LHAFileData object containing the file data, block by block.

◆ readValue()

LHAElement mty::lha::Reader::readValue ( std::vector< std::string > const &  line)
staticprivate

Reads a line and returns the LHAElement corresponding to it.

This function must only be called if isValueLine() returns true for it. Otherwise it is undefined behaviour.

Parameters
lineLine to parse into a LHAElement.
Returns
The corresponding LHAElement, including ids and the value.
See also
LHAElement, isValueLine()

◆ split()

std::vector< std::string > mty::lha::Reader::split ( std::string const &  line)
staticprivate

Splits a string into pieces, separating by space and line break.

Parameters
lineLine to split.
Returns
The splitted line, in a std::vector.

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