CEPS
24.01
Cardiac ElectroPhysiology Simulator
|
Reads and stores simulation configuration.
This class reads and stores parameters key: value <additional value ...>
Only lines with the colon (:) character will be considered as parameters lines. All other lines are commentary.
keys and values will be trimmed from any white spaces.
If the line ends with a backslash character (), options can be continued on the next line
For compatibility with old CEPS input file, a key can be given several times. The value CepsString will be appended to the previous lines with a comma separator.
There is no type management in this class anymore, nor in the input file. This is up to the calling class to do this, with the getReal, getString, getInt functions.
Finally, for compatibility with old ceps files, std::strings with double quotes will have the quotes removed. This removes the possibility of using double quotes in std::strings for new input files, but the 'damage' should not be problematic. CAN BE DISCUSSED.
Definition at line 70 of file InputParameters.hpp.
#include <InputParameters.hpp>
Public Member Functions | |
InputParameters () | |
Empty constructor. More... | |
InputParameters (const CepsString &inputFile, CepsBool warnDefault=false) | |
Constructor with file name. More... | |
InputParameters (const InputParameters &that)=default | |
Copy constructor. More... | |
InputParameters & | operator= (const InputParameters &that)=default |
Assignment operator. More... | |
~InputParameters () override | |
Destructor. More... | |
void | read () |
Reads all available parameters in specified file. More... | |
CepsReal | getReal (const keyType &key) const |
Reads a floating point value from configuration. More... | |
CepsMathVertex | getMathVertex (const keyType &key) const |
Reads 3 floating point values from configuration. More... | |
CepsInt | getInt (const keyType &key) const |
Reads an integer value from configuration. More... | |
CepsString | getString (const keyType &key) const |
Reads a CepsString from configuration. More... | |
CepsString | operator() (const keyType &key) const |
Reads a CepsString from configuration. More... | |
CepsReal | getReal (const keyType &key, const CepsReal &dval) const |
Reads a floating point value from configuration. More... | |
CepsMathVertex | getMathVertex (const keyType &key, const CepsMathVertex &dval) const |
Reads 3 floating point values from configuration. More... | |
CepsInt | getInt (const keyType &key, const CepsInt &dval) const |
Reads an integer value from configuration. More... | |
CepsString | getString (const keyType &key, const CepsString &dval) const |
Reads a CepsString from configuration. More... | |
CepsString | operator() (const keyType &key, const CepsString &dval) const |
Reads a CepsString from configuration. More... | |
void | set (const keyType &key, const CepsString &value) |
Adds or modifies an entry in the configuration. More... | |
void | set (const keyType &key, const CepsReal &value) |
Adds or modifies an entry in the configuration. More... | |
void | set (const keyType &key, const CepsInt &value) |
Adds or modifies an entry in the configuration. More... | |
void | erase (const keyType &key) |
Removes an entry in the configuration. More... | |
CepsBool | hasKey (const keyType &key) const |
Tells if key exists in input file. More... | |
CepsBool | isActiveOption (const keyType &key) const |
Tells if key exists in configuration and is of "1","YES","ON" or "TRUE". More... | |
CepsBool | isInactiveOption (const keyType &key) const |
Tells if key exists in configuration and is of "0","NO","OFF" or "FALSE". More... | |
Public Member Functions inherited from FileReader | |
FileReader () | |
Alternative constructor. More... | |
FileReader (const CepsString &fileName) | |
Default constructor. More... | |
FileReader (const FileReader &that) | |
Copy constructor. More... | |
FileReader & | operator= (const FileReader &that) |
Copy constructor. More... | |
virtual | ~FileReader () |
Destructor. Calls FileReader::close. More... | |
void | setFileName (const CepsString &fileName) |
Set file to read. More... | |
virtual CepsBool | open () |
Opens the designated file in read mode. More... | |
virtual void | close () |
Close the file. More... | |
virtual CepsBool | good () |
true if stream is still readable More... | |
void | reset () |
Set file stream to the beginning of the file. More... | |
CepsUInt | find (const CepsString &pattern) |
Advance stream until pattern is found. More... | |
CepsBool | findNext (const CepsString &pattern) |
Advance stream until pattern is found. More... | |
CepsUInt | findNextOf (const CepsVector< CepsString > &patterns) |
Advance stream until one of patterns is found. More... | |
CepsString | getFileName () |
Name of parsed file. More... | |
CepsUInt | skipLines (CepsUInt nbLines) |
Skip given number of lines. More... | |
void | oneLine (CepsString &line) |
Get one line from the stream. More... | |
template<typename T > | |
FileReader & | operator>> (T &var) |
Reading operator. More... | |
CepsInt | lineIndex (const CepsString &word) |
Index of first line starting with word, search starting from the current stream position. More... | |
CepsUInt | checkEOF () |
Checks if the reader reached end of file. More... | |
Protected Member Functions | |
void | errIfNoKey (const keyType &key, const CepsString &type) const |
Prints an error message if file misses a key. More... | |
void | warnNoKey (const keyType &key, const CepsString &defValue, const CepsString &type) const |
Prints an warning message if file misses a key and use the default value. More... | |
Private Types | |
using | keyType = CepsString |
Private Attributes | |
CepsMap< keyType, CepsString > | m_keyVals |
The parameters stored as std::strings. More... | |
CepsBool | m_warnDefault |
Print missing values warnings if true. More... | |
Additional Inherited Members | |
Protected Attributes inherited from FileReader | |
CepsString | m_fileName |
file to open More... | |
std::ifstream | m_file |
stream More... | |
|
private |
Definition at line 73 of file InputParameters.hpp.
InputParameters::InputParameters | ( | ) |
Empty constructor.
Definition at line 42 of file InputParameters.cpp.
|
explicit |
Constructor with file name.
[in] | inputFile | Can be absolute or relative file name |
[in] | warnDefault | Print messages for using default values when a key is missing |
Definition at line 47 of file InputParameters.cpp.
|
default |
Copy constructor.
|
override |
Destructor.
Definition at line 55 of file InputParameters.cpp.
void InputParameters::erase | ( | const keyType & | key | ) |
Removes an entry in the configuration.
Definition at line 291 of file InputParameters.cpp.
|
protected |
Prints an error message if file misses a key.
[in] | key | The missing key. :( |
[in] | type | expected type of value |
Definition at line 253 of file InputParameters.cpp.
Reads an integer value from configuration.
[in] | key | Not case sensitive, trailing spaces trimmed. |
Interrupts the program if key is not provided.
Definition at line 179 of file InputParameters.cpp.
Reads an integer value from configuration.
[in] | key | Not case sensitive, trailing spaces trimmed. |
[in] | dval | Default value used if key is not found in config. |
Definition at line 187 of file InputParameters.cpp.
CepsMathVertex InputParameters::getMathVertex | ( | const keyType & | key | ) | const |
Reads 3 floating point values from configuration.
[in] | key | Not case sensitive, trailing spaces trimmed. |
Interrupts the program if key is not provided.
Definition at line 157 of file InputParameters.cpp.
CepsMathVertex InputParameters::getMathVertex | ( | const keyType & | key, |
const CepsMathVertex & | dval | ||
) | const |
Reads 3 floating point values from configuration.
[in] | key | Not case sensitive, trailing spaces trimmed. |
[in] | dval | Default value used if key is not found in config. |
Definition at line 165 of file InputParameters.cpp.
Reads a floating point value from configuration.
[in] | key | Not case sensitive, trailing spaces trimmed. |
Interrupts the program if key is not provided.
Definition at line 137 of file InputParameters.cpp.
Reads a floating point value from configuration.
[in] | key | Not case sensitive, trailing spaces trimmed. |
[in] | dval | Default value used if key is not found in config. |
Definition at line 145 of file InputParameters.cpp.
CepsString InputParameters::getString | ( | const keyType & | key | ) | const |
Reads a CepsString from configuration.
[in] | key | Not case sensitive, trailing spaces trimmed. |
Interrupts the program if key is not provided.
Definition at line 199 of file InputParameters.cpp.
CepsString InputParameters::getString | ( | const keyType & | key, |
const CepsString & | dval | ||
) | const |
Reads a CepsString from configuration.
[in] | key | Not case sensitive, trailing spaces trimmed. |
[in] | dval | Default value used if key is not found in config. |
Definition at line 207 of file InputParameters.cpp.
Tells if key exists in input file.
[in] | key | Not case sensitive, trailing spaces trimmed. |
Definition at line 231 of file InputParameters.cpp.
Tells if key exists in configuration and is of "1","YES","ON" or "TRUE".
[in] | key | Not case sensitive, trailing spaces trimmed. |
Definition at line 237 of file InputParameters.cpp.
Tells if key exists in configuration and is of "0","NO","OFF" or "FALSE".
[in] | key | Not case sensitive, trailing spaces trimmed. |
Definition at line 245 of file InputParameters.cpp.
CepsString InputParameters::operator() | ( | const keyType & | key | ) | const |
Reads a CepsString from configuration.
[in] | key | Not case sensitive, trailing spaces trimmed. |
Interrupts the program if key is not provided.
Definition at line 219 of file InputParameters.cpp.
CepsString InputParameters::operator() | ( | const keyType & | key, |
const CepsString & | dval | ||
) | const |
Reads a CepsString from configuration.
[in] | key | Not case sensitive, trailing spaces trimmed. |
[in] | dval | Default value used if key is not found in config. |
Definition at line 225 of file InputParameters.cpp.
|
default |
Assignment operator.
void InputParameters::read | ( | ) |
Reads all available parameters in specified file.
Definition at line 60 of file InputParameters.cpp.
Adds or modifies an entry in the configuration.
Definition at line 284 of file InputParameters.cpp.
Adds or modifies an entry in the configuration.
Definition at line 277 of file InputParameters.cpp.
void InputParameters::set | ( | const keyType & | key, |
const CepsString & | value | ||
) |
Adds or modifies an entry in the configuration.
Definition at line 270 of file InputParameters.cpp.
|
protected |
Prints an warning message if file misses a key and use the default value.
[in] | key | The missing key. :( |
[in] | defValue | the value used instead of |
[in] | type | expected type of value |
Definition at line 262 of file InputParameters.cpp.
|
private |
The parameters stored as std::strings.
Definition at line 246 of file InputParameters.hpp.
|
private |
Print missing values warnings if true.
Definition at line 247 of file InputParameters.hpp.