delpi  0.0.1
DElta-complete LP solver
Loading...
Searching...
No Matches
delpi::ArgParser Class Reference

Used to parse command line arguments and produce a corresponding Config object to be used throughout the execution. More...

#include <ArgParser.h>

Public Member Functions

void Parse (int argc, const char **argv)
 Parse the command line arguments.
Config ToConfig () const
 Convert the parser to a Config.
template<class T>
get (const std::string &key) const
 Get the value of a parameter from the internal parser.

Private Member Functions

void AddOptions ()
 Add all the options, positional arguments and flags to the parser.
void ValidateOptions ()
 Validate the options, ensuring the correctness of the parameters and the consistency of the options.

Private Attributes

argparse::ArgumentParser parser_
 The parser object.
const std::string qsoptex_hash_
 The hash of the QSoptEx library. Used in the prompt.
const std::string soplex_hash_
 The hash of the Soplex library. Used in the prompt.
int verbosity_
 Verbosity level of the program.

Detailed Description

Used to parse command line arguments and produce a corresponding Config object to be used throughout the execution.

The default values of each parameter are defined in the Config class. Besides parsing, a validation step is performed to ensure the correctness of the parameters. If an inconsistency is found, an explication of the error is printed to the console. Under the hood, it uses the argparse library.

Definition at line 26 of file ArgParser.h.

Member Function Documentation

◆ get()

template<class T>
T delpi::ArgParser::get ( const std::string & key) const
inlinenodiscard

Get the value of a parameter from the internal parser.

Template Parameters
Ttype of the parameter
Parameters
keyname of the parameter
Returns
value of the parameter
Exceptions
std::invalid_argumentif the key is not found

Definition at line 60 of file ArgParser.h.

◆ Parse()

void delpi::ArgParser::Parse ( int argc,
const char ** argv )

Parse the command line arguments.

Parameters
argcnumber of arguments
argvarray of arguments as strings

Definition at line 77 of file ArgParser.cpp.

◆ ToConfig()

Config delpi::ArgParser::ToConfig ( ) const
nodiscard

Convert the parser to a Config.

The Config object will be used throughout the program to pass the configuration to all the components.

Returns
configuration object

Definition at line 148 of file ArgParser.cpp.

◆ ValidateOptions()

void delpi::ArgParser::ValidateOptions ( )
private

Validate the options, ensuring the correctness of the parameters and the consistency of the options.

Exceptions
DelpiInvalidArgumentExceptionif the options are inconsistent or incorrect.
DelpiExceptionif an error occurs during parsing.

Definition at line 177 of file ArgParser.cpp.


The documentation for this class was generated from the following files: