KI
 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[])
 
std::string getAddress () const
 
std::string getConfigPath () const
 
std::string getLobbyName () const
 
std::string getUName () const
 
std::string getPw () const
 
int getPort () const
 
int getDifficulty () const
 
int getVerbosity () const
 

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

std::string util::ArgumentParser::getAddress ( ) const

Get the address

Returns
the value given to the address flag
std::string util::ArgumentParser::getConfigPath ( ) const

Get the config path

Returns
the value given to the teamConfig flag
int util::ArgumentParser::getDifficulty ( ) const

Return the difficulty

Returns
the value given to the difficulty flag or 0
std::string util::ArgumentParser::getLobbyName ( ) const

Return the lobby

Returns
the value given to the lobby flag or "hogwarts"
int util::ArgumentParser::getPort ( ) const

Return the port

Returns
the value given to the port flag or 4488
std::string util::ArgumentParser::getPw ( ) const

Return the password

Returns
the value given to the password flag or "password"
std::string util::ArgumentParser::getUName ( ) const

Return the username

Returns
the value given to the username flag or "Team10Ki"
int util::ArgumentParser::getVerbosity ( ) const

Return the verbosity

Returns
the value given to the verbosity flag or 0
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: