|
Nemo
2.4.1
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>
Inheritance diagram for ParamsParser:
Collaboration diagram for ParamsParser: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) |
| string | expandMacros (const string &arg) |
| Public entry point to expand macros in a string, used to expand macros that were preserved by P() once the random seed has been set (see SimRunner::expandPreservedMacros). More... | |
| 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) |
| string | sample (const string &argstr) |
| string | sort (const string &argstr) |
| string | round (const string &argstr) |
| string | ceiling (const string &argstr) |
| string | floor (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) |
Static Private Member Functions | |
| static size_t | matchClosingParen (const string &s) |
| Given a string positioned just after an opening '(', returns the index of the matching closing ')', accounting for nested parentheses. More... | |
| static bool | containsPreserveMacro (const string &s) |
| Returns true if 's' contains a P() preserve-macro call, i.e. More... | |
Private Attributes | |
| bool | _hasPreservedMacro = false |
| Set true by parseMacroFunctionBlock when a P() preserve-macro is encountered while parsing a parameter value; read and reset per-parameter in parse(). More... | |
| 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 ceiling(), concat(), diag_matrix(), floor(), matrix(), quote(), rbernoul(), rep(), rexp(), rgamma(), rlognorm(), rnorm(), round(), rpoiss(), runif(), sample(), seq(), sort(), sym_matrix(), and tempseq().
|
inlineprotected |
Referenced by StreamParser::read().
Here is the caller graph for this function:| string ParamsParser::callMacro | ( | const string & | name, |
| const string & | argstr | ||
| ) |
| string ParamsParser::ceiling | ( | const string & | argstr | ) |
References fatal(), tstring::isanumber(), and tstring::str2dble().
Referenced by ParamsParser().
Here is the caller graph for this function:| 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 tstring::removeEnclosingChar().
Referenced by ParamsParser().
Here is the caller graph for this function:
|
staticprivate |
Returns true if 's' contains a P() preserve-macro call, i.e.
"P(" where 'P' begins a macro name (at the start of the string or right after a macro-name delimiter). Used to reject nested P(), which cannot be expanded correctly.
| string ParamsParser::diag_matrix | ( | const string & | argstr | ) |
References fatal(), and tstring::str2uint().
Referenced by ParamsParser().
Here is the caller graph for this function:
|
inline |
Public entry point to expand macros in a string, used to expand macros that were preserved by P() once the random seed has been set (see SimRunner::expandPreservedMacros).
Referenced by SimRunner::expandPreservedMacros().
Here is the caller graph for this function:| string ParamsParser::floor | ( | const string & | argstr | ) |
References fatal(), tstring::isanumber(), and tstring::str2dble().
Referenced by ParamsParser().
Here is the caller graph for this function:
|
inline |
|
static |
References StreamParser::removeSpaceAndComment().
|
static |
References StreamParser::readUntilCharacter().
| 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(), and tstring::splitExcludeEnclosedDelimiters().
| string ParamsParser::getMacroParamValue | ( | const string & | str_in, |
| const string & | par_name, | ||
| const string & | macro_name | ||
| ) |
References fatal(), and tstring::splitExcludeEnclosedDelimiters().
| string ParamsParser::getMacroSepParamChar | ( | const string & | sep_in, |
| const string | macro_name | ||
| ) |
References fatal(), tstring::isanumber(), tstring::removeEnclosingChar(), and tstring::splitExcludeEnclosedDelimiters().
|
inline |
| map< string, string > & ParamsParser::getParameters | ( | const char * | stream_name | ) |
References fatal().
Referenced by BinaryDataLoader::extractPop().
Here is the caller graph for this function:
|
inline |
| map< string, vector< string > > & ParamsParser::getParsedParameters | ( | const char * | stream_name | ) |
Referenced by SimRunner::run().
Here is the caller graph for this function:
|
staticprivate |
Given a string positioned just after an opening '(', returns the index of the matching closing ')', accounting for nested parentheses.
Returns string::npos if unbalanced. Used to capture the raw argument of a preserved P() macro.
| string ParamsParser::matrix | ( | const string & | argstr | ) |
References fatal(), and tstring::str2uint().
Referenced by ParamsParser().
Here is the caller graph for this function:| void ParamsParser::parse | ( | ) |
Builds the _parsedParams from the _inputParams.
This defines rules of sequential, matricial params, etc.
References MACRO_PRESERVE_TAG, and message().
| string ParamsParser::parseMacroFunctionBlock | ( | const string & | in_arg | ) |
References fatal().
| string ParamsParser::quote | ( | const string & | argstr | ) |
Macro "q" returns a quoted string.
Useful to quote result of call to enclosed macro.
Referenced by ParamsParser().
Here is the caller graph for this function:| string ParamsParser::rbernoul | ( | const string & | argstr | ) |
References RAND::Bernoulli(), fatal(), tstring::int2str(), tstring::isanumber(), tstring::splitExcludeEnclosedDelimiters(), tstring::str2dble(), and tstring::str2uint().
Referenced by ParamsParser().
Here is the caller graph for this function:
|
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 StreamParser, BinaryFileParser, and FileParser.
| string ParamsParser::rep | ( | const string & | argstr | ) |
References fatal(), tstring::isanumber(), tstring::removeEnclosingChar(), tstring::removeLastCharOf(), tstring::split(), and tstring::str2int().
Referenced by ParamsParser().
Here is the caller graph for this function:| string ParamsParser::replaceMacro | ( | const string & | arg | ) |
Macros.
|
inlineprotected |
| string ParamsParser::rexp | ( | const string & | argstr | ) |
References tstring::dble2str(), RAND::Exponential(), fatal(), tstring::isanumber(), tstring::splitExcludeEnclosedDelimiters(), tstring::str2dble(), and tstring::str2uint().
Referenced by ParamsParser().
Here is the caller graph for this function:| string ParamsParser::rgamma | ( | const string & | argstr | ) |
References tstring::dble2str(), fatal(), RAND::Gamma(), tstring::isanumber(), tstring::splitExcludeEnclosedDelimiters(), tstring::str2dble(), and tstring::str2uint().
Referenced by ParamsParser().
Here is the caller graph for this function:| string ParamsParser::rlognorm | ( | const string & | argstr | ) |
References tstring::dble2str(), fatal(), tstring::isanumber(), RAND::LogNormal(), tstring::splitExcludeEnclosedDelimiters(), tstring::str2dble(), and tstring::str2uint().
Referenced by ParamsParser().
Here is the caller graph for this function:| string ParamsParser::rnorm | ( | const string & | argstr | ) |
References tstring::dble2str(), fatal(), RAND::Gaussian(), tstring::isanumber(), tstring::splitExcludeEnclosedDelimiters(), tstring::str2dble(), and tstring::str2uint().
Referenced by ParamsParser().
Here is the caller graph for this function:| string ParamsParser::round | ( | const string & | argstr | ) |
References fatal(), tstring::isanumber(), tstring::str2dble(), and tstring::str2int().
Referenced by ParamsParser().
Here is the caller graph for this function:| string ParamsParser::rpoiss | ( | const string & | argstr | ) |
References tstring::dble2str(), fatal(), tstring::isanumber(), RAND::Poisson(), tstring::splitExcludeEnclosedDelimiters(), tstring::str2dble(), and tstring::str2uint().
Referenced by ParamsParser().
Here is the caller graph for this function:| string ParamsParser::runif | ( | const string & | argstr | ) |
References tstring::dble2str(), fatal(), tstring::isanumber(), tstring::splitExcludeEnclosedDelimiters(), tstring::str2dble(), tstring::str2uint(), and RAND::Uniform().
Referenced by ParamsParser().
Here is the caller graph for this function:| string ParamsParser::sample | ( | const string & | argstr | ) |
References fatal(), tstring::isanumber(), RAND::Sample(), tstring::str2uint(), and RAND::Uniform().
Referenced by ParamsParser().
Here is the caller graph for this function:| string ParamsParser::seq | ( | const string & | argstr | ) |
References tstring::dble2str(), fatal(), tstring::isanumber(), and tstring::str2dble().
Referenced by ParamsParser().
Here is the caller graph for this function:
|
inline |
| string ParamsParser::sort | ( | const string & | argstr | ) |
References fatal(), and tstring::isanumber().
Referenced by ParamsParser().
Here is the caller graph for this function:| string ParamsParser::sym_matrix | ( | const string & | argstr | ) |
References fatal(), TMatrix::get(), tstring::isanumber(), TMatrix::set(), tstring::str2dble(), tstring::str2int(), and TMatrix::to_string().
Referenced by ParamsParser().
Here is the caller graph for this function:| string ParamsParser::tempseq | ( | const string & | argstr | ) |
References fatal().
Referenced by ParamsParser().
Here is the caller graph for this function:
|
private |
Set true by parseMacroFunctionBlock when a P() preserve-macro is encountered while parsing a parameter value; read and reset per-parameter in parse().
|
private |
The whole, unparsed set of input parameters.
|
private |
The macro table, mapping call name to caller.
|
private |
The parsed set of simulation parameters after sequential parameters have been separated.
|
private |
Attached file of stream name.
1.9.1