Server
 All Data Structures Files Functions Variables
Public Member Functions | Static Public Member Functions
util::ArgumentParser Class Reference

#include <ArgumentParser.hpp>

Public Member Functions

 ArgumentParser (int argc, char *argv[])
 
auto getMatch () const -> std::string
 
auto getPort () const -> uint16_t
 
auto getVerbosity () const -> unsigned int
 

Static Public Member Functions

static void printHelp ()
 

Detailed Description

Implements a basic argument parser according to the standard using GNU-Getopt

Constructor & Destructor Documentation

util::ArgumentParser::ArgumentParser ( int  argc,
char *  argv[] 
)

CTor, parses the arguments and fills all fields. If –help is found printHelp() is called and the program gets terminated. If no argument is passed the help is printed as well.

Exceptions
std::runtime_errorif any of the required flags doesn't exist or contains an invalid value
Parameters
argcthe number of arguments, as passed into main
argvan array of all arguments, as passed into main

Member Function Documentation

auto util::ArgumentParser::getMatch ( ) const -> std::string

Get the match-config file name as passed by -m or –match. It is guaranteed that this is a valid string but not that the file actually exists or is valid.

Returns
a string containing the argument passed with -m or –match
auto util::ArgumentParser::getPort ( ) const -> uint16_t

Returns the port if provided by -p or –port, else returns the default port of 8080.

Returns
a uint16_t containing the port
auto util::ArgumentParser::getVerbosity ( ) const -> unsigned int

Returns the verbosity if provided by -v or –verbosity, else the default verbosity of 0

Returns
a unsigned int containing the verbosity
void util::ArgumentParser::printHelp ( )
static

Prints the help message, gets called by the CTor if the -h or –help flag is set.


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