ewmscp  ..
Public Member Functions | Private Attributes | List of all members
options::single< bool > Class Reference

class specialisation for options of type bool More...

#include <Options.h>

Inheritance diagram for options::single< bool >:
[legend]
Collaboration diagram for options::single< bool >:
[legend]

Public Member Functions

 single (char aShortName, const std::string &aLongName, const std::string &aExplanation, bool aDefault=false)
 
 single (const single &)=delete
 
bool operator= (const bool &aValue)
 
void fWriteValue (std::ostream &aStream) const override
 write textual representation of value to a std::ostream More...
 
void fSetMeNoarg (const internal::sourceItem &aSource) override
 
void fSetMe (std::istream &aStream, const internal::sourceItem &aSource) override
 function to set the value from a string, remembering the source More...
 
void fCheckRange () const override
 
void fAddToRangeFromStream (std::istream &) override
 special for use in the shellScriptOptionParser More...
 
void fAddDefaultFromStream (std::istream &aStream) override
 special for use in the shellScriptOptionParser More...
 
bool fGetValue () const
 
- Public Member Functions inherited from options::fundamental_wrapper< bool >
 fundamental_wrapper ()
 
 fundamental_wrapper (bool aValue)
 
fundamental_wrapperoperator= (const bool aValue)
 
bool operator= (const bool &aValue)
 
 operator bool & ()
 
 operator const bool & () const
 
- Public Member Functions inherited from options::base
 base (char aShortName, const std::string &aLongName, const std::string &aExplanation, short aNargs)
 construct an object of type base More...
 
virtual ~base ()
 
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...
 

Private Attributes

bool lDefault
 

Additional Inherited Members

- Protected Member Functions inherited from options::base
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 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 inherited from options::base
static std::map< std::string, base * > & fGetOptionMap ()
 
static std::map< char, base * > & fGetShortOptionMap ()
 
- Protected Attributes inherited from options::fundamental_wrapper< bool >
bool lValue
 
- Protected Attributes inherited from options::base
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
 

Detailed Description

class specialisation for options of type bool

in this class in cases that there is no argument, i.e. when parsing the comand line the value is set to the oppsoite of the default value. If an argument is given, which is always the case in config files, then the value is read as std::boolalpha (when no locale nonsense is done 'true' or 'false')

Definition at line 595 of file Options.h.

Constructor & Destructor Documentation

◆ single() [1/2]

options::single< bool >::single ( char  aShortName,
const std::string &  aLongName,
const std::string &  aExplanation,
bool  aDefault = false 
)
inline

Definition at line 599 of file Options.h.

599  :
600  fundamental_wrapper(aDefault),
601  base(aShortName, aLongName, aExplanation, 0),
602  lDefault(aDefault) {
603  }

◆ single() [2/2]

options::single< bool >::single ( const single< bool > &  )
delete

Member Function Documentation

◆ fAddDefaultFromStream()

void options::single< bool >::fAddDefaultFromStream ( std::istream &  aStream)
overridevirtual

special for use in the shellScriptOptionParser

read a value from aStram and set that as default

Implements options::base.

Definition at line 927 of file Options.cpp.

927  {
928  aStream >> std::boolalpha >> lValue;
929  lDefault = lValue;
930  }

◆ fAddToRangeFromStream()

void options::single< bool >::fAddToRangeFromStream ( std::istream &  aStream)
inlineoverridevirtual

special for use in the shellScriptOptionParser

read values from aStream and add them to the range vector

Implements options::base.

Definition at line 615 of file Options.h.

615 {};

◆ fCheckRange()

void options::single< bool >::fCheckRange ( ) const
inlineoverridevirtual

Implements options::base.

Definition at line 613 of file Options.h.

613  {
614  };

◆ fGetValue()

bool options::single< bool >::fGetValue ( ) const
inline

Definition at line 618 of file Options.h.

618  {
619  return lValue;
620  }

◆ fSetMe()

void options::single< bool >::fSetMe ( std::istream &  aStream,
const internal::sourceItem aSource 
)
overridevirtual

function to set the value from a string, remembering the source

Implements options::base.

Reimplemented in options::withAction< options::single< bool > >, and options::internal::OptionHelp.

Definition at line 923 of file Options.cpp.

923  {
924  aStream >> std::boolalpha >> lValue;
925  fSetSource(aSource);
926  }

References options::base::fSetSource().

Here is the call graph for this function:

◆ fSetMeNoarg()

void options::single< bool >::fSetMeNoarg ( const internal::sourceItem aSource)
overridevirtual

Reimplemented from options::base.

Reimplemented in options::internal::OptionHelp, and options::withAction< options::single< bool > >.

Definition at line 919 of file Options.cpp.

919  {
920  lValue = ! lDefault;
921  fSetSource(aSource);
922  }

References options::base::fSetSource().

Here is the call graph for this function:

◆ fWriteValue()

void options::single< bool >::fWriteValue ( std::ostream &  aStream) const
overridevirtual

write textual representation of value to a std::ostream

Implements options::base.

Definition at line 916 of file Options.cpp.

916  {
917  aStream << std::boolalpha << lValue;
918  }

◆ operator=()

bool options::single< bool >::operator= ( const bool &  aValue)
inline

Definition at line 605 of file Options.h.

605  {
606  lValue = aValue;
607  return lValue;
608  }

Member Data Documentation

◆ lDefault

bool options::single< bool >::lDefault
private

Definition at line 597 of file Options.h.


The documentation for this class was generated from the following files:
options::fundamental_wrapper< bool >::fundamental_wrapper
fundamental_wrapper()
Definition: Options.h:86
options::fundamental_wrapper< bool >::lValue
bool lValue
Definition: Options.h:84
options::base::base
base(char aShortName, const std::string &aLongName, const std::string &aExplanation, short aNargs)
construct an object of type base
Definition: Options.cpp:529
options::single< bool >::lDefault
bool lDefault
Definition: Options.h:597
options::base::fSetSource
virtual void fSetSource(const internal::sourceItem &aSource)
remember the source that provided the value, e.g. commandline or a config file
Definition: Options.cpp:561