8#ifndef OM_H_ARG_READER_H
9#define OM_H_ARG_READER_H
21 static constexpr const char *
iniFile =
"OpenM.IniFile";
24 static constexpr const char *
iniAnyKey =
"OpenM.IniAnyKey";
27 static constexpr const char *
runStamp =
"OpenM.RunStamp";
33 static constexpr const char *
logToFile =
"OpenM.LogToFile";
36 static constexpr const char *
logFilePath =
"OpenM.LogFilePath";
39 static constexpr const char *
logToStamped =
"OpenM.LogToStampedFile";
42 static constexpr const char *
logUseTs =
"OpenM.LogUseTimeStamp";
45 static constexpr const char *
logUsePid =
"OpenM.LogUsePidStamp";
51 static constexpr const char *
logSql =
"OpenM.LogSql";
64 const size_t i_keyArrSize,
65 const char ** i_keyArr,
66 const size_t i_shortArrSize = 0,
67 const pair<const char *, const char *> * i_shortPairArr =
nullptr
80 string strOption(
const char * i_key,
const string & i_default =
"") const noexcept;
83 bool boolOption(const
char * i_key) const noexcept;
94 int intOption(const
char * i_key,
int i_default) const noexcept {
return (
int)
longOption(i_key, i_default); }
97 long long longOption(
const char * i_key,
long long i_default)
const noexcept;
100 double doubleOption(
const char * i_key,
double i_default)
const noexcept;
106 bool i_isThrowUnknown,
107 bool i_isStoreUnknown,
108 const size_t i_keyArrSize,
109 const char ** i_keyArr,
110 const size_t i_shortArrSize = 0,
111 const pair<const char *, const char *> * i_shortPairArr =
nullptr,
112 const size_t i_prefixSize = 0,
113 const char ** i_prefixArr =
nullptr,
114 const size_t i_suffixSize = 0,
115 const char ** i_suffixArr =
nullptr
120 const char * i_filePath,
121 const size_t i_keyArrSize,
122 const char ** i_keyArr,
123 bool i_isStoreUnknown =
false,
124 const size_t i_sectionToMergeSize = 0,
125 const char ** i_sectionToMergeArr =
nullptr,
126 const size_t i_multiKeySize = 0,
127 const char ** i_multiKeyArr =
nullptr
openM++ namespace
Definition: log.h:32
std::map< std::string, std::string, LessNoCase > NoCaseMap
map of key-value strings with case neutral key search
Definition: omHelper.h:224
OpenM++ common helper utilities.
common openM++ keys for runtime arguments
Definition: argReader.h:19
static constexpr const char * logSql
log sql
Definition: argReader.h:51
static constexpr const char * logNoMsgTime
do not prefix log messages with date-time
Definition: argReader.h:48
static constexpr const char * iniFile
run ini file name, ie: model.ini
Definition: argReader.h:21
static constexpr const char * iniAnyKey
if true then allow any key in the ini-file, read all ini-file entries and pass it to the model
Definition: argReader.h:24
static constexpr const char * logUseTs
use time-stamp in log "stamped" file name
Definition: argReader.h:42
static constexpr const char * logFilePath
log file path
Definition: argReader.h:36
static constexpr const char * runStamp
process run stamp, usually time stamp
Definition: argReader.h:27
static constexpr const char * logToStamped
log to "stamped" file
Definition: argReader.h:39
static constexpr const char * logToConsole
log to console
Definition: argReader.h:30
static constexpr const char * logUsePid
use pid-stamp in log "stamped" file name
Definition: argReader.h:45
static constexpr const char * logToFile
log to file
Definition: argReader.h:33
arguments reader to get runtime arguments from command line and ini-file.
Definition: argReader.h:56
void adjustLogSettings(int argc, char **argv)
adjust log file settings, ie: make default log file path if required.
Definition: argReader.cpp:312
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.
Definition: argReader.cpp:249
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 a...
Definition: argReader.cpp:89
string strOption(const char *i_key, const string &i_default="") const noexcept
return string value by key or default value if not found.
Definition: argReader.cpp:58
ArgReader(void)
initialize empty list of run arguments.
Definition: argReader.h:58
bool isOptionExist(const char *i_key) const noexcept
return true if option with this key exist.
Definition: argReader.cpp:47
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.
Definition: argReader.cpp:100
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).
Definition: argReader.cpp:73
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.
Definition: argReader.cpp:141
NoCaseMap args
arguments as key-value string pairs with case-neutral search
Definition: argReader.h:74
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.
Definition: argReader.h:94
~ArgReader(void) noexcept
cleanup argument holder resources
Definition: argReader.h:71
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.
Definition: argReader.cpp:113