dlinear  0.0.1
Delta-complete SMT solver for linear programming
Loading...
Searching...
No Matches
dlinear::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

 ArgParser ()
 Construct a new argparser object.
 
void Parse (int argc, const char **argv)
 Parse the command line arguments.
 
std::string prompt () const
 Get read-only access to the printable console prompt of the program.
 
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.
 

Static Public Member Functions

static std::string version ()
 Get read-only access to the version of the program.
 
static std::string repository_status ()
 Get read-only access to the hash status of the repository.
 

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.
 
int verbosity_
 Verbosity level of the program.
 
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.
 

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 27 of file ArgParser.h.

Member Function Documentation

◆ get()

template<class T >
T dlinear::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 61 of file ArgParser.h.

◆ Parse()

void dlinear::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.

◆ prompt()

std::string dlinear::ArgParser::prompt ( ) const
nodiscard

Get read-only access to the printable console prompt of the program.

Returns
printable console prompt of the program

Definition at line 276 of file ArgParser.cpp.

◆ repository_status()

std::string dlinear::ArgParser::repository_status ( )
staticnodiscard

Get read-only access to the hash status of the repository.

Returns
hash status of the repository

Definition at line 274 of file ArgParser.cpp.

◆ ToConfig()

Config dlinear::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 185 of file ArgParser.cpp.

◆ ValidateOptions()

void dlinear::ArgParser::ValidateOptions ( )
private

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

Exceptions
std::invalid_argumentif the options are inconsistent or incorrect.
std::runtime_errorif an error occurs during parsing.

Definition at line 230 of file ArgParser.cpp.

◆ version()

std::string dlinear::ArgParser::version ( )
staticnodiscard

Get read-only access to the version of the program.

Returns
version of the program

Definition at line 272 of file ArgParser.cpp.


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