tfel
Loading...
Searching...
No Matches
tfel::utilities::ArgumentParserBase< Child > Struct Template Reference

an helper class used for command line argument parsing. More...

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

Inheritance diagram for tfel::utilities::ArgumentParserBase< Child >:
tfel::utilities::ArgumentParser

Public Types

using MemberFuncPtr = void (Child::*)()
 a simple alias
Public Types inherited from tfel::utilities::ArgumentParser
using CallBacksContainer = std::map<std::string, CallBack>
 a simple alias

Public Member Functions

 ArgumentParserBase ()
 default constructor
 ArgumentParserBase (const int, const char *const *const)
 constructor
 ArgumentParserBase (const ArgumentParserBase &)=delete
 ArgumentParserBase (ArgumentParserBase &&)=delete
ArgumentParserBase & operator= (const ArgumentParserBase &)=delete
ArgumentParserBase & operator= (ArgumentParserBase &&)=delete
void registerNewCallBack (const std::string &, const MemberFuncPtr &, const std::string &="", const bool=false)
 register a new callback
void registerNewCallBack (const std::string &, const std::string &, const MemberFuncPtr &, const std::string &="", const bool=false)
 register a new callback
 ~ArgumentParserBase () override
 destructor
Public Member Functions inherited from tfel::utilities::ArgumentParser
 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

Additional Inherited Members

Protected Types inherited from tfel::utilities::ArgumentParser
using AliasContainer = std::map<std::string, std::string>
 a simple alias
using ArgsContainer = std::vector<Argument>
 a simple alias
Protected Member Functions inherited from tfel::utilities::ArgumentParser
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 inherited from tfel::utilities::ArgumentParser
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

template<typename Child>
struct tfel::utilities::ArgumentParserBase< Child >

an helper class used for command line argument parsing.

The CRTP pattern is used to enable ArgumentParserBase to used the method of its derivate class. Such a design was extremly usefull before std::function was introduced.

The class maps the command line arguments to method of the derivate class.

Parameters
Child

Constructor & Destructor Documentation

◆ ArgumentParserBase()

template<typename Child>
tfel::utilities::ArgumentParserBase< Child >::ArgumentParserBase ( const int argc,
const char *const * const argv )

constructor

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

Member Function Documentation

◆ registerNewCallBack() [1/2]

template<typename Child>
void tfel::utilities::ArgumentParserBase< Child >::registerNewCallBack ( const std::string & k,
const MemberFuncPtr & f,
const std::string & d = "",
const bool b = false )

register a new callback

Parameters
key: command line argument name
f: callback
description: description of the command line argument (used for the –help) options
b: This command line argument can have an option

◆ registerNewCallBack() [2/2]

template<typename Child>
void tfel::utilities::ArgumentParserBase< Child >::registerNewCallBack ( const std::string & k,
const std::string & a,
const MemberFuncPtr & f,
const std::string & d = "",
const bool b = false )

register a new callback

Parameters
key: command line argument name
aliasName: command line argument alias
f: callback
description: description of the command line argument (used for the –help) options
b: This command line argument can have an option

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