Utility classes for program configuration.
std::vector<string> pni::core::cliargs2vector |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
This function stores CLI options and arguments in a vector.
- Parameters
-
argc | number of arguments |
argv | argument values |
- Returns
- vector with arguments and options
std::ostream& pni::core::operator<< |
( |
std::ostream & |
ostr, |
|
|
const cli_args & |
args |
|
) |
| |
Write an instance of cli_args to an output stream.
- Parameters
-
ostr | reference to output stream |
args | reference to arguments |
- Returns
- reference to output stream
std::vector<string> pni::core::parse |
( |
configuration & |
c, |
|
|
const std::vector< string > & |
args, |
|
|
bool |
unregistered = false |
|
) |
| |
This function parses CLI options an arguments from a vector. Unlike the original pointer approach the vector must not contain the program name (usually passed as the first argument to a program). A utilty function can be used to convert the defautl CLI argument pointer to a vector
int main(int argc,char **argv)
{
......
configuration config;
......
......
}
!
- Parameters
-
c | reference to the configuration to be parsed |
args | command line arguments in a vector |
unregistered | flag to allow unregistered options |
- Returns
- a vector with uncrecognized options
void pni::core::parse |
( |
configuration & |
c, |
|
|
const string & |
fname |
|
) |
| |
Function to read configuration from a configuration file.
- Parameters
-
c | reference to the configuration object |
fname | name of the configuration file |