ewmscp
..
|
base class for options More...
#include <Options.h>
Public Member Functions | |
base (char aShortName, const std::string &aLongName, const std::string &aExplanation, short aNargs) | |
construct an object of type base More... | |
virtual | ~base () |
virtual void | fAddToRangeFromStream (std::istream &aStream)=0 |
special for use in the shellScriptOptionParser More... | |
virtual void | fAddDefaultFromStream (std::istream &aStream)=0 |
special for use in the shellScriptOptionParser More... | |
virtual void | fWriteValue (std::ostream &aStream) const =0 |
write textual representation of value to a std::ostream More... | |
virtual void | fRequire (const base *aOtherOption) |
require aOtherOption when this option is set More... | |
virtual void | fRequire (std::vector< const base * > aOtherOptions) |
add vector of other options, particlularly nice for use with initializer list More... | |
template<typename InputIt > | |
void | fRequire (InputIt aBegin, InputIt aEnd) |
add all options from the pair of iterators [aBegin,aEnd) to the list of required options More... | |
virtual void | fForbid (const base *aOtherOption) |
forbid aOtherOption when this option is set More... | |
virtual void | fForbid (std::vector< const base * > aOtherOptions) |
add vector of other options, particlularly nice for use with initializer list More... | |
template<typename InputIt > | |
void | fForbid (InputIt aBegin, InputIt aEnd) |
add all options from the pair of iterators [aBegin,aEnd) to the list of forbidden options More... | |
virtual bool | fIsSet () const |
check if this option was set, regardless of from command line or config file More... | |
virtual bool | fIsContainer () const |
const std::string & | fGetLongName () const |
returns long name of option, usually only for internal use. More... | |
Protected Member Functions | |
virtual void | fSetMe (std::istream &aStream, const internal::sourceItem &aSource)=0 |
function to set the value from a string, remembering the source More... | |
virtual void | fSetMeNoarg (const internal::sourceItem &) |
virtual void | fSetSource (const internal::sourceItem &aSource) |
remember the source that provided the value, e.g. commandline or a config file More... | |
virtual void | fWriteCfgLines (std::ostream &aStream, const char *aPrefix) const |
virtual void | fCheckRange () const =0 |
virtual void | fWriteRange (std::ostream &) const |
void | fSetPreserveWorthyStuff (std::vector< std::string > *aStuff) |
void | fHide () |
hide option, will be respected by help More... | |
bool | fIsHidden () const |
void | fDisable () |
disable option by removing it from the maps More... | |
Static Protected Member Functions | |
static std::map< std::string, base * > & | fGetOptionMap () |
static std::map< char, base * > & | fGetShortOptionMap () |
Protected Attributes | |
char | lShortName |
const std::string | lLongName |
const std::string | lExplanation |
internal::sourceItem | lSource |
short | lNargs |
bool | lHidden |
std::vector< std::string > * | lPreserveWorthyStuff |
std::vector< const base * > | lRequiredOptions |
std::vector< const base * > | lForbiddenOptions |
Private Member Functions | |
virtual void | fHandleOption (int argc, const char *argv[], int *i) |
Friends | |
class | parser |
base class for options
Only the templated classes that derive from this base class can contain values. This base class only contains members that are generally usable and do not depend on the type of the option.
options::base::base | ( | char | aShortName, |
const std::string & | aLongName, | ||
const std::string & | aExplanation, | ||
short | aNargs | ||
) |
construct an object of type base
The newly created object is inserted into the maps sorted by long name and by short name, (short name only if it is not '\0') If a clash wopuld occur, i.e. either long or short name is already taken an exception is thrown.
[in] | aShortName | short option without the -, use '\0' to have only a long form |
[in] | aLongName | long option without the –, must always be given |
[in] | aExplanation | explanation for help output |
[in] | aNargs | number of arguments/parameters. May be 0 ot 1. |
Definition at line 529 of file Options.cpp.
References options::internal::conCat(), options::parser::fGetInstance(), fGetOptionMap(), fGetShortOptionMap(), lLongName, lPreserveWorthyStuff, and lShortName.
|
virtual |
Definition at line 554 of file Options.cpp.
References fGetOptionMap(), fGetShortOptionMap(), and lPreserveWorthyStuff.
|
pure virtual |
special for use in the shellScriptOptionParser
read a value from aStram and set that as default
Implemented in options::internal::baseForContainer< T >, options::internal::baseForContainer< std::string >, options::internal::baseForContainer< unsigned int >, options::internal::baseForMap< T >, options::internal::baseForMap< std::string >, options::single< bool >, options::single< T >, options::single< std::chrono::nanoseconds >, options::single< unsigned long >, options::single< std::chrono::duration< double > >, options::single< double >, options::single< std::string >, options::single< int >, options::single< unsigned int >, options::single< U >, options::single< options::postFixedNumber< size_t > >, options::single< copyRequest::clock_type::duration >, options::single< size_t >, options::single< unsigned >, options::single< std::chrono::seconds >, options::single< std::chrono::duration< Rep, Period > >, options::single< std::chrono::system_clock::time_point >, options::ForeignOption, and options::single< std::regex >.
|
pure virtual |
special for use in the shellScriptOptionParser
read values from aStream and add them to the range vector
Implemented in options::internal::typed_base< T, forceRangeValueTypeString >, options::internal::typed_base< std::chrono::nanoseconds >, options::internal::typed_base< std::chrono::system_clock::time_point >, options::internal::typed_base< unsigned long >, options::internal::typed_base< std::chrono::duration< double > >, options::internal::typed_base< double >, options::internal::typed_base< std::string >, options::internal::typed_base< int >, options::internal::typed_base< unsigned int >, options::internal::typed_base< T >, options::internal::typed_base< U >, options::internal::typed_base< options::postFixedNumber< size_t > >, options::internal::typed_base< copyRequest::clock_type::duration >, options::internal::typed_base< size_t >, options::internal::typed_base< std::regex, true >, options::internal::typed_base< unsigned >, options::internal::typed_base< std::chrono::duration< Rep, Period > >, options::internal::typed_base< std::chrono::seconds >, options::ForeignOption, and options::single< bool >.
|
protectedpure virtual |
Implemented in options::container< T, Container >, options::map< T, Container >, options::single< bool >, options::single< T >, options::single< std::chrono::duration< Rep, Period > >, options::single< std::chrono::system_clock::time_point >, options::ForeignOption, and options::single< std::regex >.
Referenced by fHandleOption().
|
protected |
disable option by removing it from the maps
Definition at line 605 of file Options.cpp.
References fGetOptionMap(), fGetShortOptionMap(), fHide(), lLongName, and lShortName.
|
virtual |
forbid aOtherOption when this option is set
Definition at line 617 of file Options.cpp.
References lForbiddenOptions.
Referenced by davixCfgX509::davixCfgX509(), dCapCfgPar< T >::fForbid(), fForbid(), and baseTest::setUpOptions().
|
inline |
|
virtual |
add vector of other options, particlularly nice for use with initializer list
Definition at line 620 of file Options.cpp.
References lForbiddenOptions.
|
inline |
returns long name of option, usually only for internal use.
Definition at line 273 of file Options.h.
References lLongName.
Referenced by options::parser::fParse(), options::parser::fPrintOptionHelp(), and mapOption< T >::fWriteValue().
|
inlinestaticprotected |
Definition at line 196 of file Options.h.
Referenced by base(), options::parser::fCheckConsistency(), fDisable(), options::parser::fHelp(), options::parser::fParse(), options::parser::fReadCfgFile(), options::parser::fWriteCfgFile(), and ~base().
|
inlinestaticprotected |
Definition at line 200 of file Options.h.
Referenced by base(), fDisable(), options::parser::fParse(), and ~base().
|
privatevirtual |
Definition at line 566 of file Options.cpp.
References options::internal::conCat(), fCheckRange(), fSetMe(), fSetMeNoarg(), options::internal::sourceFile::gCmdLine, and lNargs.
|
protected |
hide option, will be respected by help
Definition at line 596 of file Options.cpp.
References lHidden.
Referenced by fDisable().
|
inlinevirtual |
Reimplemented in options::internal::baseForContainer< T >, and options::internal::baseForMap< T >.
Definition at line 267 of file Options.h.
Referenced by options::internal::positional_base::positional_base().
|
protected |
Definition at line 600 of file Options.cpp.
References lHidden.
Referenced by options::parser::fPrintOptionHelp().
|
inlinevirtual |
check if this option was set, regardless of from command line or config file
Reimplemented in options::internal::baseForContainer< T >, and options::internal::baseForMap< T >.
Definition at line 263 of file Options.h.
References options::internal::sourceItem::fIsUnset(), and lSource.
Referenced by dCapCfgTimePar< T >::applySingle(), davixCfgPar< struct timespec * >::applySingle(), davixCfgEnum< const Davix::RequestProtocol::Protocol >::applySingle(), davixCfgX509::applySingle(), followJsonRequestProvider::followStream(), messageQueue::kafka::init(), main(), libsshCommon::openSessions(), cmdLineRequestProvider::prepareMappings(), and followJsonRequestProvider::processJson().
|
virtual |
require aOtherOption when this option is set
Definition at line 611 of file Options.cpp.
References lRequiredOptions.
Referenced by davixCfgX509::davixCfgX509(), fRequire(), and main().
|
inline |
add all options from the pair of iterators [aBegin,aEnd) to the list of required options
Definition at line 247 of file Options.h.
References fRequire().
|
virtual |
add vector of other options, particlularly nice for use with initializer list
Definition at line 614 of file Options.cpp.
References lRequiredOptions.
|
protectedpure virtual |
function to set the value from a string, remembering the source
Implemented in options::internal::OptionReadCfgFile< mayBeMissing >, options::internal::OptionWriteCfgFile, options::withAction< options::single< std::string > >, options::withAction< options::single< bool > >, options::container< T, Container >, options::container< std::string >, options::container< unsigned int >, options::container< T >, options::map< T, Container >, options::map< std::string, pathMapType >, options::map< std::string >, options::map< std::string, std::map< int, std::string > >, options::map< T >, options::single< bool >, options::single< T >, options::single< std::chrono::nanoseconds >, options::single< unsigned long >, options::single< std::chrono::duration< double > >, options::single< double >, options::single< std::string >, options::single< int >, options::single< unsigned int >, options::single< U >, options::single< options::postFixedNumber< size_t > >, options::single< copyRequest::clock_type::duration >, options::single< size_t >, options::single< unsigned >, options::single< std::chrono::seconds >, options::single< std::chrono::duration< Rep, Period > >, options::single< std::chrono::system_clock::time_point >, options::single< std::regex >, options::ForeignOption, and options::internal::OptionHelp.
Referenced by options::internal::baseForMap< std::string >::fAddDefaultFromStream(), options::internal::baseForContainer< unsigned int >::fAddDefaultFromStream(), and fHandleOption().
|
inlineprotectedvirtual |
Reimplemented in options::internal::OptionHelp, options::withAction< options::single< std::string > >, options::withAction< options::single< bool > >, options::single< bool >, and options::ForeignOption.
Definition at line 218 of file Options.h.
Referenced by fHandleOption().
|
protected |
Definition at line 591 of file Options.cpp.
References lPreserveWorthyStuff.
|
protectedvirtual |
remember the source that provided the value, e.g. commandline or a config file
Definition at line 561 of file Options.cpp.
References lSource.
Referenced by options::single< std::regex >::fSetMe(), options::ForeignOption::fSetMe(), options::single< std::chrono::system_clock::time_point >::fSetMe(), options::single< std::chrono::duration< Rep, Period > >::fSetMe(), options::single< std::chrono::seconds >::fSetMe(), options::single< bool >::fSetMe(), options::ForeignOption::fSetMeNoarg(), and options::single< bool >::fSetMeNoarg().
|
protectedvirtual |
Reimplemented in options::container< T, Container >, options::container< std::string >, options::container< unsigned int >, options::container< T >, options::map< T, Container >, options::map< std::string, pathMapType >, options::map< std::string >, options::map< std::string, std::map< int, std::string > >, options::map< T >, options::internal::OptionReadCfgFile< mayBeMissing >, options::internal::supressed< T >, options::internal::supressed< std::string >, and options::internal::supressed< bool >.
Definition at line 580 of file Options.cpp.
References options::originalStringKeeper::fWriteOriginalString(), fWriteValue(), and lLongName.
Referenced by options::internal::supressed< bool >::fWriteCfgLines(), and options::internal::OptionReadCfgFile< mayBeMissing >::fWriteCfgLines().
|
inlineprotectedvirtual |
Reimplemented in options::internal::typed_base< T, forceRangeValueTypeString >, options::internal::typed_base< std::chrono::nanoseconds >, options::internal::typed_base< std::chrono::system_clock::time_point >, options::internal::typed_base< unsigned long >, options::internal::typed_base< std::chrono::duration< double > >, options::internal::typed_base< double >, options::internal::typed_base< std::string >, options::internal::typed_base< int >, options::internal::typed_base< unsigned int >, options::internal::typed_base< T >, options::internal::typed_base< U >, options::internal::typed_base< options::postFixedNumber< size_t > >, options::internal::typed_base< copyRequest::clock_type::duration >, options::internal::typed_base< size_t >, options::internal::typed_base< std::regex, true >, options::internal::typed_base< unsigned >, options::internal::typed_base< std::chrono::duration< Rep, Period > >, options::internal::typed_base< std::chrono::seconds >, and options::single< std::chrono::system_clock::time_point >.
Definition at line 226 of file Options.h.
Referenced by options::parser::fParse().
|
pure virtual |
write textual representation of value to a std::ostream
Implemented in options::container< T, Container >, options::container< std::string >, options::container< unsigned int >, options::container< T >, options::map< T, Container >, options::map< std::string, pathMapType >, options::map< std::string >, options::map< std::string, std::map< int, std::string > >, options::map< T >, options::single< bool >, options::single< T >, options::single< std::chrono::nanoseconds >, options::single< unsigned long >, options::single< std::chrono::duration< double > >, options::single< double >, options::single< std::string >, options::single< int >, options::single< unsigned int >, options::single< U >, options::single< options::postFixedNumber< size_t > >, options::single< copyRequest::clock_type::duration >, options::single< size_t >, options::single< unsigned >, options::single< std::chrono::seconds >, options::single< std::chrono::duration< Rep, Period > >, options::single< std::chrono::system_clock::time_point >, listOption< T >, options::ForeignOption, mapOption< T >, options::single< std::regex >, and arrayOption< T >.
Referenced by options::parser::fPrintOptionHelp(), and fWriteCfgLines().
|
protected |
Definition at line 207 of file Options.h.
Referenced by options::parser::fPrintOptionHelp().
|
protected |
Definition at line 214 of file Options.h.
Referenced by fForbid(), and options::parser::fPrintOptionHelp().
|
protected |
Definition at line 210 of file Options.h.
Referenced by fHide(), and fIsHidden().
|
protected |
Definition at line 206 of file Options.h.
Referenced by base(), fDisable(), fGetLongName(), options::parser::fPrintOptionHelp(), fWriteCfgLines(), options::map< T >::fWriteCfgLines(), and options::container< T >::fWriteCfgLines().
|
protected |
Definition at line 209 of file Options.h.
Referenced by options::ForeignOption::fAddArgs(), and fHandleOption().
|
protected |
Definition at line 211 of file Options.h.
Referenced by base(), fSetPreserveWorthyStuff(), and ~base().
|
protected |
Definition at line 213 of file Options.h.
Referenced by options::parser::fPrintOptionHelp(), and fRequire().
|
protected |
Definition at line 203 of file Options.h.
Referenced by base(), fDisable(), and options::parser::fPrintOptionHelp().
|
protected |
Definition at line 208 of file Options.h.
Referenced by fIsSet(), and fSetSource().