tfel
Loading...
Searching...
No Matches
tfel::utilities::ArgumentParser Struct Referenceabstract

class used to parser command line arguments More...

#include </home/runner/work/tfel/tfel/include/TFEL/Utilities/ArgumentParser.hxx>

Inheritance diagram for tfel::utilities::ArgumentParser:
tfel::utilities::ArgumentParserBase< DocumentationGeneratorBase > tfel::utilities::ArgumentParserBase< MFront > tfel::utilities::ArgumentParserBase< QueryHandlerBase > tfel::utilities::ArgumentParserBase< TestDocMain > tfel::utilities::ArgumentParserBase< Child > mfront::DocumentationGeneratorBase mfront::MFront mfront::QueryHandlerBase tfel::utilities::TestDocMain mfront::BehaviourDocumentationGenerator mfront::MaterialPropertyDocumentationGenerator mfront::BehaviourQuery mfront::MaterialPropertyQuery mfront::ModelQuery

Classes

struct  CallBack
 structure describing an action to be performed when a argument is treated More...

Public Types

using CallBacksContainer = std::map<std::string, CallBack>
 a simple alias

Public Member Functions

 ArgumentParser ()
 default constructor
 ArgumentParser (const int, const char *const *const)
 constructor
 ArgumentParser (const ArgumentParser &)=delete
 copy constructor
 ArgumentParser (ArgumentParser &&)=delete
 move constructor
ArgumentParser & operator= (const ArgumentParser &)=delete
 standard assignement
ArgumentParser & operator= (ArgumentParser &&)=delete
 move assignement
virtual void setArguments (const int, const char *const *const)
 set the arguments to be parsed
virtual void registerCallBack (const std::string &, const CallBack &)
 register a new callback
virtual void registerCallBack (const std::string &, const std::string &, const CallBack &)
 register a new callback
virtual void parseArguments ()
 parse arguments using registred methods.
const CallBacksContainer & getRegistredCallBacks () const
virtual ~ArgumentParser ()
 destructor

Protected Types

using AliasContainer = std::map<std::string, std::string>
 a simple alias
using ArgsContainer = std::vector<Argument>
 a simple alias

Protected Member Functions

virtual void treatUnknownArgument ()
 method called while parsing unregistred command line arguments.
virtual void treatHelp ()
 method associated with the '–help' command line argument.
virtual void treatVersion ()
 method associated with the '–version' command line argument
virtual std::string getVersionDescription () const =0
virtual std::string getUsageDescription () const =0

Protected Attributes

CallBacksContainer callBacksContainer
 container of all the call-backs
AliasContainer alias
 container of all the alias
ArgsContainer args
 container of all the command line arguments
ArgsContainer::iterator currentArgument
 an iterator to the argument being treated
std::string programName
 program name

Detailed Description

class used to parser command line arguments

Constructor & Destructor Documentation

◆ ArgumentParser()

tfel::utilities::ArgumentParser::ArgumentParser ( const int ,
const char *const * const  )

constructor

Parameters
argc: number of arguments given at command line
argv: arguments list

Member Function Documentation

◆ getRegistredCallBacks()

const CallBacksContainer & tfel::utilities::ArgumentParser::getRegistredCallBacks ( ) const
nodiscard
Returns
the list of registred callbacks

◆ getUsageDescription()

virtual std::string tfel::utilities::ArgumentParser::getUsageDescription ( ) const
nodiscardprotectedpure virtual
Returns
the usage of the program being used

Implemented in mfront::MFront, and mfront::QueryHandlerBase.

◆ getVersionDescription()

virtual std::string tfel::utilities::ArgumentParser::getVersionDescription ( ) const
nodiscardprotectedpure virtual
Returns
the version of the program being used

Implemented in mfront::MFront, and mfront::QueryHandlerBase.

◆ registerCallBack() [1/2]

virtual void tfel::utilities::ArgumentParser::registerCallBack ( const std::string & ,
const CallBack &  )
virtual

register a new callback

Parameters
key: command line argument name
f: callback

◆ registerCallBack() [2/2]

virtual void tfel::utilities::ArgumentParser::registerCallBack ( const std::string & ,
const std::string & ,
const CallBack &  )
virtual

register a new callback

Parameters
key: command line argument name
aliasName: command line argument alias
f: callback

◆ setArguments()

virtual void tfel::utilities::ArgumentParser::setArguments ( const int ,
const char *const * const  )
virtual

set the arguments to be parsed

Parameters
argc: number of arguments given at command line
argv: arguments list

◆ treatHelp()

virtual void tfel::utilities::ArgumentParser::treatHelp ( )
protectedvirtual

method associated with the '–help' command line argument.

This method uses the getUsageDescription() method to get a more helpfull message.

This method stops the execution by calling the exit method.

◆ treatUnknownArgument()

virtual void tfel::utilities::ArgumentParser::treatUnknownArgument ( )
protectedvirtual

method called while parsing unregistred command line arguments.

Exceptions
runtime_error

Reimplemented in mfront::MFront, mfront::QueryHandlerBase, and tfel::utilities::TestDocMain.


The documentation for this struct was generated from the following file: