Nemo
2.3.56
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
|
A global class to handle string conversions and operations. More...
#include <tstring.h>
Static Public Member Functions | |
static unsigned int | str2uint (const string &str) |
Converts a string into an unsigned integer. More... | |
static unsigned long | str2ulong (const string &str) |
Converts a string into an unsigned integer. More... | |
static int | str2int (const string &str) |
Converts a string into an integer. More... | |
static double | str2dble (const string &str) |
Converts a string into a double. More... | |
static string | int2str (const int i) |
Writes an integer value into a string. More... | |
static string | ulong2str (const unsigned long i) |
Writes an integer value into a string. More... | |
static string | dble2str (const double d) |
Writes a floating-point value into a string. More... | |
static vector< string > | split (const string &str, const char delim, bool splitOnce=false) |
splits a string into substrings (tokens) delimited by a single character. More... | |
static vector< string > | splitExcludeEnclosedDelimiters (const string &str, const char delim=',', const string &encloser="([{\"") |
Splits a string into substrings (tokens) delimited by a single character. More... | |
static string | getBlock (const string &str, const char start_c, const char end_c='\0', bool includeEnclosing=true) |
Reads a substring delimited by two enclosing character from a string. More... | |
static string | __get_block (istringstream &IN, const char start_c, const char end_c) |
Internal function used by getBlock to recursively read nested blocks. More... | |
static string | removeChar (const string &str, const char c) |
Removes a given character from a string. More... | |
static string | removeFirstCharOf (const string &str, const char c) |
Removes the first of a character found in a string. More... | |
static string | removeLastCharOf (const string &str, const char c) |
Removes the last of a character found in a string. More... | |
static string | removeEnclosingChar (const string &str, const char o, const char c, bool allowMissing=false) |
Removes characters enclosing a string. More... | |
static bool | isanumber (const string &str) |
Check whether the string is a number. More... | |
static bool | isNA (const string &str) |
Check whether the string is NA | NaN. More... | |
Private Member Functions | |
tstring () | |
A global class to handle string conversions and operations.
Allows to parse the parameters argument strings into various tokens and to remove encolsing characters from a string.
|
inlineprivate |
|
inlinestatic |
Internal function used by getBlock to recursively read nested blocks.
References __get_block(), and fatal().
Referenced by __get_block(), and getBlock().
|
inlinestatic |
Writes a floating-point value into a string.
Referenced by TTQFreqExtractor::FHwrite(), ParamsParser::rbernoul(), TTProtoWithMap::recordRandomMap(), ParamsParser::rexp(), ParamsParser::rgamma(), ParamsParser::rlognorm(), ParamsParser::rnorm(), ParamsParser::rpoiss(), ParamsParser::runif(), ParamsParser::seq(), and TTProtoWithMap::setRecombinationMapRandom().
|
inlinestatic |
Reads a substring delimited by two enclosing character from a string.
May or may not retain the enclosing characters.
References __get_block(), error(), fatal(), and removeEnclosingChar().
Referenced by splitExcludeEnclosedDelimiters().
|
inlinestatic |
Writes an integer value into a string.
Referenced by TTQuantiSH::addAvgPerPatch(), TTQuantiSH::addCovarPerPatch(), TTDispersalSH::addDispPerPatch(), TTQuantiSH::addEigen(), TTQuantiSH::addEigenPerPatch(), TTQuantiSH::addEigenValues(), TTQuantiSH::addEigenValuesPerPatch(), TTQuantiSH::addEigenVect1(), TTQuantiSH::addEigenVect1PerPatch(), MPStatHandler::addIndNumPerPatch(), LCE_SelectionSH::addMeanPerPatch(), TTQuantiSH::addQuanti(), TTQuantiSH::addSkewPerPatch(), LCE_SelectionSH::addVarPerPatch(), TTQuantiSH::addVarPerPatch(), LCE_Resize::execute(), BinaryDataLoader::extractPop(), LCE_SelectionFH::FHwrite(), TTQFreqExtractor::FHwrite(), Metapop::loadPopFromBinarySource(), SimRunner::runPostExecReplicateWise(), TTNeutralGenesSH::setDxyRecorders(), TTNeutralGenesSH::setFreqRecorders(), and TTNeutralGenesSH::setNeiGeneticDistanceRecorders().
|
inlinestatic |
Check whether the string is a number.
Referenced by FHPedigreeReader::FHread(), ParamsParser::getMacroSepParamChar(), ParamsParser::rbernoul(), ParamsParser::rep(), ParamsParser::rexp(), ParamsParser::rgamma(), ParamsParser::rlognorm(), ParamsParser::rnorm(), ParamsParser::rpoiss(), ParamsParser::runif(), ParamsParser::seq(), Param::set(), and ParamsParser::sym_matrix().
|
inlinestatic |
Check whether the string is NA | NaN.
Referenced by FHPedigreeReader::FHread().
|
inlinestatic |
Removes a given character from a string.
|
inlinestatic |
Removes characters enclosing a string.
Can be used to remove parenthesis/brackets or trailing whitespace characters.
str | the string |
o | the opening (front) character |
c | the closing (back) character |
allowMissing | if trus, allows to ignore a missing enclosing character |
References error().
Referenced by ParamsParser::concat(), ParamsParser::diag_matrix(), getBlock(), ParamsParser::getMacroSepParamChar(), ParamsParser::matrix(), Param::parseArgument(), ParamsParser::rep(), split(), splitExcludeEnclosedDelimiters(), ParamsParser::sym_matrix(), and ParamsParser::tempseq().
|
inlinestatic |
Removes the first of a character found in a string.
Referenced by Param::getArgumentFromFile(), and Param::parseTemporalArgument().
|
inlinestatic |
Removes the last of a character found in a string.
Referenced by ParamsParser::rep().
|
inlinestatic |
splits a string into substrings (tokens) delimited by a single character.
str | the input string |
delim | the token delimiter |
splitOnce | if true, return the first token only |
References removeEnclosingChar().
Referenced by ParamsParser::diag_matrix(), ParamsParser::matrix(), Param::parseTemporalArgument(), ParamsParser::rep(), splitExcludeEnclosedDelimiters(), ParamsParser::sym_matrix(), and ParamsParser::tempseq().
|
inlinestatic |
Splits a string into substrings (tokens) delimited by a single character.
The tokens may contain the delimiter character if it is enclosed. For instance: ‘(@g0 {{0,1,0,10}}, @g10 {{1,0,2,2}})’ --> [0] = ‘@g0 {{0,1,0,10}}’ and [1] = ‘@g10 {{1,0,2,2}}’
str | the input string |
delim | the token delimiter, is a comma by default |
encloser | the character that starts an enclosed string |
References getBlock(), removeEnclosingChar(), and split().
Referenced by ParamsParser::getMacroArgs(), ParamsParser::getMacroParamValue(), ParamsParser::getMacroSepParamChar(), Param::parseArgument(), ParamsParser::rbernoul(), ParamsParser::rexp(), ParamsParser::rgamma(), ParamsParser::rlognorm(), ParamsParser::rnorm(), ParamsParser::rpoiss(), and ParamsParser::runif().
|
inlinestatic |
Converts a string into a double.
Referenced by ParamsParser::rbernoul(), ParamsParser::rexp(), ParamsParser::rgamma(), ParamsParser::rlognorm(), ParamsParser::rnorm(), ParamsParser::rpoiss(), ParamsParser::runif(), ParamsParser::seq(), Param::set(), and ParamsParser::sym_matrix().
|
inlinestatic |
Converts a string into an integer.
Referenced by ParamsParser::rep(), Param::set(), LCE_StatServiceNotifier::setOccurence(), LCE_Cross::setParameters(), and ParamsParser::sym_matrix().
|
inlinestatic |
Converts a string into an unsigned integer.
Referenced by ParamsParser::diag_matrix(), ParamsParser::matrix(), Param::parseTemporalArgument(), ParamsParser::rbernoul(), ParamsParser::rexp(), ParamsParser::rgamma(), ParamsParser::rlognorm(), ParamsParser::rnorm(), ParamsParser::rpoiss(), and ParamsParser::runif().
|
inlinestatic |
Converts a string into an unsigned integer.
Referenced by FHPedigreeReader::FHread().
|
inlinestatic |
Writes an integer value into a string.
Referenced by SimRunner::run().