Nemo
2.3.56
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
|
Provides interface to read input parameters from various sources and parses them. More...
#include <paramsparser.h>
Public Member Functions | |
ParamsParser (const char *name) | |
virtual | ~ParamsParser () |
void | setName (const char *name) |
map< string, string > | get_inputParams () |
map< string, vector< string > > & | getParsedParameters (const char *stream_name) |
map< string, vector< string > > & | getParsedParameters () |
map< string, string > & | getParameters (const char *stream_name) |
map< string, string > & | getParameters () |
virtual bool | read (const char *stream)=0 |
Read/parse params & args from a file or a string or an R object. More... | |
void | parse () |
Builds the _parsedParams from the _inputParams. More... | |
string | replaceMacro (const string &arg) |
Macros. More... | |
string | parseMacroFunctionBlock (const string &in_arg) |
string | callMacro (const string &name, const string &argstr) |
vector< string > | getMacroArgs (const string &args, const int min_arg, const size_t max_arg, const string macro_name, const string syntax, bool lastArgIsSeparatorChar=true) |
string | getMacroSepParamChar (const string &sep_in, const string macro_name) |
string | getMacroParamValue (const string &str_in, const string &par_name, const string ¯o_name) |
string | quote (const string &argstr) |
Macro "q" returns a quoted string. More... | |
string | concat (const string &argstr) |
Macro "c" returns a character-delimited string of atomic arguments. More... | |
string | rep (const string &argstr) |
string | seq (const string &argstr) |
string | tempseq (const string &argstr) |
string | matrix (const string &argstr) |
string | diag_matrix (const string &argstr) |
string | sym_matrix (const string &argstr) |
string | runif (const string &argstr) |
string | rnorm (const string &argstr) |
string | rpoiss (const string &argstr) |
string | rbernoul (const string &argstr) |
string | rgamma (const string &argstr) |
string | rlognorm (const string &argstr) |
string | rexp (const string &argstr) |
Static Public Member Functions | |
static void | getBlockArgument (istream &IN, char &c, string &arg) |
static void | getArguments (string &arg_str, vector< string > &arg_vect) |
Protected Member Functions | |
void | reset_inputParams () |
void | add_inputParam (string ¶m, const string &arg) |
Private Attributes | |
const char * | _sname |
Attached file of stream name. More... | |
map< string, string > | _inputParams |
The whole, unparsed set of input parameters. More... | |
map< string, vector< string > > | _parsedParams |
The parsed set of simulation parameters after sequential parameters have been separated. More... | |
map< string, string(ParamsParser::*)(const string &)> | _macroMap |
The macro table, mapping call name to caller. More... | |
Provides interface to read input parameters from various sources and parses them.
ParamsParser::ParamsParser | ( | const char * | name | ) |
References _macroMap, _sname, concat(), diag_matrix(), matrix(), quote(), rbernoul(), rep(), rgamma(), rlognorm(), rnorm(), rpoiss(), runif(), seq(), sym_matrix(), and tempseq().
|
inlinevirtual |
|
inlineprotected |
References _inputParams.
Referenced by StreamParser::read().
string ParamsParser::callMacro | ( | const string & | name, |
const string & | argstr | ||
) |
References _macroMap, fatal(), and message().
Referenced by parseMacroFunctionBlock().
string ParamsParser::concat | ( | const string & | argstr | ) |
Macro "c" returns a character-delimited string of atomic arguments.
Can be passed as arguments to other macros.
References getMacroArgs(), and tstring::removeEnclosingChar().
Referenced by ParamsParser().
string ParamsParser::diag_matrix | ( | const string & | argstr | ) |
References fatal(), getMacroArgs(), tstring::removeEnclosingChar(), tstring::split(), and tstring::str2uint().
Referenced by ParamsParser().
|
inline |
References _inputParams.
|
static |
References getBlockArgument(), and StreamParser::removeSpaceAndComment().
Referenced by parse().
|
static |
References StreamParser::readUntilCharacter().
Referenced by getArguments().
vector< string > ParamsParser::getMacroArgs | ( | const string & | args, |
const int | min_arg, | ||
const size_t | max_arg, | ||
const string | macro_name, | ||
const string | syntax, | ||
bool | lastArgIsSeparatorChar = true |
||
) |
References fatal(), getMacroSepParamChar(), and tstring::splitExcludeEnclosedDelimiters().
Referenced by concat(), diag_matrix(), matrix(), quote(), rbernoul(), rep(), rexp(), rgamma(), rlognorm(), rnorm(), rpoiss(), runif(), seq(), sym_matrix(), and tempseq().
string ParamsParser::getMacroParamValue | ( | const string & | str_in, |
const string & | par_name, | ||
const string & | macro_name | ||
) |
References fatal(), and tstring::splitExcludeEnclosedDelimiters().
Referenced by rep(), sym_matrix(), and tempseq().
string ParamsParser::getMacroSepParamChar | ( | const string & | sep_in, |
const string | macro_name | ||
) |
References fatal(), tstring::isanumber(), tstring::removeEnclosingChar(), and tstring::splitExcludeEnclosedDelimiters().
Referenced by getMacroArgs().
|
inline |
References _inputParams.
Referenced by getParsedParameters().
map< string, string > & ParamsParser::getParameters | ( | const char * | stream_name | ) |
References _inputParams, _sname, fatal(), and read().
Referenced by BinaryDataLoader::extractPop().
|
inline |
References _parsedParams.
map< string, vector< string > > & ParamsParser::getParsedParameters | ( | const char * | stream_name | ) |
References _parsedParams, getParameters(), and parse().
Referenced by SimRunner::run().
string ParamsParser::matrix | ( | const string & | argstr | ) |
References fatal(), getMacroArgs(), tstring::removeEnclosingChar(), tstring::split(), and tstring::str2uint().
Referenced by ParamsParser().
void ParamsParser::parse | ( | ) |
Builds the _parsedParams from the _inputParams.
This defines rules of sequential, matricial params, etc.
References _inputParams, _parsedParams, getArguments(), message(), and replaceMacro().
Referenced by getParsedParameters().
string ParamsParser::parseMacroFunctionBlock | ( | const string & | in_arg | ) |
References callMacro(), fatal(), and parseMacroFunctionBlock().
Referenced by parseMacroFunctionBlock(), and replaceMacro().
string ParamsParser::quote | ( | const string & | argstr | ) |
Macro "q" returns a quoted string.
Useful to quote result of call to enclosed macro.
References getMacroArgs().
Referenced by ParamsParser().
string ParamsParser::rbernoul | ( | const string & | argstr | ) |
References RAND::Bernoulli(), tstring::dble2str(), fatal(), getMacroArgs(), tstring::isanumber(), tstring::splitExcludeEnclosedDelimiters(), tstring::str2dble(), and tstring::str2uint().
Referenced by ParamsParser().
|
pure virtual |
Read/parse params & args from a file or a string or an R object.
Params and their args are put in the _inputParams.
Implemented in FileParser, BinaryFileParser, and StreamParser.
Referenced by getParameters().
string ParamsParser::rep | ( | const string & | argstr | ) |
References fatal(), getMacroArgs(), getMacroParamValue(), tstring::isanumber(), tstring::removeEnclosingChar(), tstring::removeLastCharOf(), tstring::split(), and tstring::str2int().
Referenced by ParamsParser().
string ParamsParser::replaceMacro | ( | const string & | arg | ) |
Macros.
References parseMacroFunctionBlock().
Referenced by parse().
|
inlineprotected |
References _inputParams.
Referenced by StreamParser::read().
string ParamsParser::rexp | ( | const string & | argstr | ) |
References tstring::dble2str(), RAND::Exponential(), fatal(), getMacroArgs(), tstring::isanumber(), tstring::splitExcludeEnclosedDelimiters(), tstring::str2dble(), and tstring::str2uint().
string ParamsParser::rgamma | ( | const string & | argstr | ) |
References tstring::dble2str(), fatal(), RAND::Gamma(), getMacroArgs(), tstring::isanumber(), tstring::splitExcludeEnclosedDelimiters(), tstring::str2dble(), and tstring::str2uint().
Referenced by ParamsParser().
string ParamsParser::rlognorm | ( | const string & | argstr | ) |
References tstring::dble2str(), fatal(), getMacroArgs(), tstring::isanumber(), RAND::LogNormal(), tstring::splitExcludeEnclosedDelimiters(), tstring::str2dble(), and tstring::str2uint().
Referenced by ParamsParser().
string ParamsParser::rnorm | ( | const string & | argstr | ) |
References tstring::dble2str(), fatal(), RAND::Gaussian(), getMacroArgs(), tstring::isanumber(), tstring::splitExcludeEnclosedDelimiters(), tstring::str2dble(), and tstring::str2uint().
Referenced by ParamsParser().
string ParamsParser::rpoiss | ( | const string & | argstr | ) |
References tstring::dble2str(), fatal(), getMacroArgs(), tstring::isanumber(), RAND::Poisson(), tstring::splitExcludeEnclosedDelimiters(), tstring::str2dble(), and tstring::str2uint().
Referenced by ParamsParser().
string ParamsParser::runif | ( | const string & | argstr | ) |
References tstring::dble2str(), fatal(), getMacroArgs(), tstring::isanumber(), tstring::splitExcludeEnclosedDelimiters(), tstring::str2dble(), tstring::str2uint(), and RAND::Uniform().
Referenced by ParamsParser().
string ParamsParser::seq | ( | const string & | argstr | ) |
References tstring::dble2str(), fatal(), getMacroArgs(), tstring::isanumber(), and tstring::str2dble().
Referenced by ParamsParser().
|
inline |
References _sname.
Referenced by BinaryDataLoader::extractPop().
string ParamsParser::sym_matrix | ( | const string & | argstr | ) |
References fatal(), TMatrix::get(), getMacroArgs(), getMacroParamValue(), tstring::isanumber(), tstring::removeEnclosingChar(), TMatrix::set(), tstring::split(), tstring::str2dble(), tstring::str2int(), and TMatrix::to_string().
Referenced by ParamsParser().
string ParamsParser::tempseq | ( | const string & | argstr | ) |
References fatal(), getMacroArgs(), getMacroParamValue(), tstring::removeEnclosingChar(), and tstring::split().
Referenced by ParamsParser().
|
private |
The whole, unparsed set of input parameters.
Referenced by add_inputParam(), get_inputParams(), getParameters(), parse(), and reset_inputParams().
|
private |
The macro table, mapping call name to caller.
Referenced by callMacro(), and ParamsParser().
|
private |
The parsed set of simulation parameters after sequential parameters have been separated.
Referenced by getParsedParameters(), and parse().
|
private |
Attached file of stream name.
Referenced by getParameters(), ParamsParser(), and setName().