OpenM++ runtime library (libopenm)
|
arguments reader to get runtime arguments from command line and ini-file. More...
#include <argReader.h>
Public Member Functions | |
ArgReader (void) | |
initialize empty list of run arguments. | |
ArgReader (int argc, char **argv, const size_t i_keyArrSize, const char **i_keyArr, const size_t i_shortArrSize=0, const pair< const char *, const char * > *i_shortPairArr=nullptr) | |
initialize run arguments from command line and ini-file. More... | |
~ArgReader (void) noexcept | |
cleanup argument holder resources | |
bool | isOptionExist (const char *i_key) const noexcept |
return true if option with this key exist. | |
string | strOption (const char *i_key, const string &i_default="") const noexcept |
return string value by key or default value if not found. | |
bool | boolOption (const char *i_key) const noexcept |
return boolean value by key or false if not found or value not "yes", "1", "true" (case insensitive). | |
int | boolOptionToInt (const char *i_key) const noexcept |
return 1 if key found and value is one of: "yes", "1", "true" or empty value, return 0 if key found and value is one of: "no", "0", "false", return -1 if key not found, return -2 otherwise. | |
int | intOption (const char *i_key, int i_default) const noexcept |
return int value by key or default if not found or can not be converted to int. | |
long long | longOption (const char *i_key, long long i_default) const noexcept |
return long value by key or default if not found or can not be converted to long. | |
double | doubleOption (const char *i_key, double i_default) const noexcept |
return double value by key or default if not found or can not be converted to double. | |
void | parseCommandLine (int argc, char **argv, bool i_isThrowUnknown, bool i_isStoreUnknown, const size_t i_keyArrSize, const char **i_keyArr, const size_t i_shortArrSize=0, const pair< const char *, const char * > *i_shortPairArr=nullptr, const size_t i_prefixSize=0, const char **i_prefixArr=nullptr, const size_t i_suffixSize=0, const char **i_suffixArr=nullptr) |
get run options from command line, ie: number of cases. More... | |
void | loadIniFile (const char *i_filePath, const size_t i_keyArrSize, const char **i_keyArr, bool i_isStoreUnknown=false, const size_t i_sectionToMergeSize=0, const char **i_sectionToMergeArr=nullptr, const size_t i_multiKeySize=0, const char **i_multiKeyArr=nullptr) |
read ini-file and merge command line arguments. More... | |
void | adjustLogSettings (int argc, char **argv) |
adjust log file settings, ie: make default log file path if required. | |
Public Attributes | |
NoCaseMap | args |
arguments as key-value string pairs with case-neutral search | |
arguments reader to get runtime arguments from command line and ini-file.
ArgReader::ArgReader | ( | int | argc, |
char ** | argv, | ||
const size_t | i_keyArrSize, | ||
const char ** | i_keyArr, | ||
const size_t | i_shortArrSize = 0 , |
||
const pair< const char *, const char * > * | i_shortPairArr = nullptr |
||
) |
initialize run arguments from command line and ini-file.
[in] | argc | number of command line arguments |
[in] | argv | array of command line arguments |
[in] | i_keyArrSize | size of i_keyArr, must be positive |
[in] | i_keyArr | array of allowed keys: full key names |
[in] | i_shortArrSize | size of i_shortPairArr, can be zero |
[in] | i_shortPairArr | array of short and full key names to remap from short to full name |
void ArgReader::loadIniFile | ( | const char * | i_filePath, |
const size_t | i_keyArrSize, | ||
const char ** | i_keyArr, | ||
bool | i_isStoreUnknown = false , |
||
const size_t | i_sectionToMergeSize = 0 , |
||
const char ** | i_sectionToMergeArr = nullptr , |
||
const size_t | i_multiKeySize = 0 , |
||
const char ** | i_multiKeyArr = nullptr |
||
) |
read ini-file and merge command line arguments.
read ini-file and merge with command line arguments.
[in] | i_filePath | path to ini-file |
[in] | i_keyArrSize | size of i_keyArr, must be positive |
[in] | i_keyArr | array of allowed keys: full key names |
[in] | i_isStoreUnknown | if true then store unknown key values |
[in] | i_sectionToMergeSize | number of section names to merge |
[in] | i_sectionToMergeArr | if not NULL then merge section from ini-file, ex: "Parameter" or "SubValue" |
[in] | i_multiKeySize | size of i_multiKeyArr array |
[in] | i_multiKeyArr | array of keys which can be used in any sections, ex: "EN.RunDescription" |
void ArgReader::parseCommandLine | ( | int | argc, |
char ** | argv, | ||
bool | i_isThrowUnknown, | ||
bool | i_isStoreUnknown, | ||
const size_t | i_keyArrSize, | ||
const char ** | i_keyArr, | ||
const size_t | i_shortArrSize = 0 , |
||
const pair< const char *, const char * > * | i_shortPairArr = nullptr , |
||
const size_t | i_prefixSize = 0 , |
||
const char ** | i_prefixArr = nullptr , |
||
const size_t | i_suffixSize = 0 , |
||
const char ** | i_suffixArr = nullptr |
||
) |
get run options from command line, ie: number of cases.
[in] | argc | number of command line arguments |
[in] | argv | array of command line arguments |
[in] | i_isThrowUnknown | if true then throw exception when key is unknown (except i_prefixToCopy below) |
[in] | i_isStoreUnknown | if true then store unknown key values (always stored i_prefixToCopy below) |
[in] | i_keyArrSize | size of i_keyArr, must be positive |
[in] | i_keyArr | array of allowed keys: full key names |
[in] | i_shortArrSize | size of i_shortPairArr, can be zero |
[in] | i_shortPairArr | array of short and full key names to remap from short to full name |
[in] | i_prefixSize | size of options "prefix." array to be allowed |
[in] | i_prefixArr | allow options started from "prefix." i.e.: "Parameter." or "SubValue." |
[in] | i_suffixSize | size of options ".suffix" array to be allowed |
[in] | i_suffixArr | allow options ended with ".suffix" i.e.: "EN.RunDescription" |