ewmscp  ..
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
options::single< std::chrono::duration< Rep, Period > > Class Template Reference

template specialisation for options that are std::chrono::durations More...

#include <OptionsChrono.h>

Inheritance diagram for options::single< std::chrono::duration< Rep, Period > >:
[legend]
Collaboration diagram for options::single< std::chrono::duration< Rep, Period > >:
[legend]

Public Types

typedef std::chrono::duration< Rep, Period > valueType
 
- Public Types inherited from options::internal::typed_base< std::chrono::duration< Rep, Period > >
typedef std::chrono::duration< Rep, Period > valueType
 
typedef std::conditional< std::is_same< std::chrono::duration< Rep, Period >, const char * >::value||false, std::string, std::chrono::duration< Rep, Period > >::type rangeValueType
 
typedef std::conditional< false, std::string, std::chrono::duration< Rep, Period > >::type compareValueType
 
- Public Types inherited from options::valuePrinter< std::chrono::duration< Rep, Period > >
typedef void(* valuePrinterType) (std::ostream &, const std::chrono::duration< Rep, Period > &)
 

Public Member Functions

 single (char aShortName, const std::string &aLongName, const std::string &aExplanation, valueType aDefault=valueType::zero(), const std::vector< valueType > &aRange={}, typename valuePrinter< valueType >::valuePrinterType aValuePrinter=fDefaultValuePrinter)
 
void fAddDefaultFromStream (std::istream &aStream) override
 special for use in the shellScriptOptionParser More...
 
void fWriteValue (std::ostream &aStream) const override
 write textual representation of value to a std::ostream More...
 
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
 
- Public Member Functions inherited from options::internal::typed_base< std::chrono::duration< Rep, Period > >
 typed_base (Types ... args)
 
virtual void fAddToRange (rangeValueType aValue)
 add a value to the range of allowed values More...
 
std::enable_if<(!std::is_same< rangeValueType, std::string >::value) &&std::is_same< TT, std::string >::value, void >::type fAddToRange (const TT &aString)
 
void fAddToRange (InputIt aBegin, InputIt aEnd)
 add values from the iterator range [aBegin,aEnd) to the range of allowed values More...
 
void fAddToRange (const std::vector< TT > &aRange)
 add values from a vector (may be given as initializer list) to the range of allowed values More...
 
void fAddToRangeFromStream (std::istream &aStream) override
 
void fWriteRange (std::ostream &aStream) const override
 
virtual void fCheckValueForRange (const compareValueType &aValue) 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...
 
- Public Member Functions inherited from options::valuePrinter< std::chrono::duration< Rep, Period > >
 valuePrinter ()
 
 valuePrinter (valuePrinterType aValuePrinter)
 
virtual void fSetValuePrinter (valuePrinterType aValuePrinter)
 
- Public Member Functions inherited from options::originalStringKeeper
void fWriteOriginalString (std::ostream &aStream) const
 
const std::string & fGetOriginalString () const
 

Static Public Member Functions

static void fDefaultValuePrinter (std::ostream &aStream, const valueType &aValue)
 

Protected Attributes

std::vector< valueTypelRange
 
- Protected Attributes inherited from options::internal::typed_base< std::chrono::duration< Rep, Period > >
std::multiset< rangeValueTypelRange
 
- 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
 
- Protected Attributes inherited from options::valuePrinter< std::chrono::duration< Rep, Period > >
valuePrinterType lValuePrinter
 
- Protected Attributes inherited from options::originalStringKeeper
std::string lOriginalString
 

Additional Inherited Members

- Protected Member Functions inherited from options::base
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
 
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 ()
 

Detailed Description

template<class Rep, class Period>
class options::single< std::chrono::duration< Rep, Period > >

template specialisation for options that are std::chrono::durations

Definition at line 100 of file OptionsChrono.h.

Member Typedef Documentation

◆ valueType

template<class Rep , class Period >
typedef std::chrono::duration<Rep, Period> options::single< std::chrono::duration< Rep, Period > >::valueType

Definition at line 106 of file OptionsChrono.h.

Constructor & Destructor Documentation

◆ single()

template<class Rep , class Period >
options::single< std::chrono::duration< Rep, Period > >::single ( char  aShortName,
const std::string &  aLongName,
const std::string &  aExplanation,
valueType  aDefault = valueType::zero(),
const std::vector< valueType > &  aRange = {},
typename valuePrinter< valueType >::valuePrinterType  aValuePrinter = fDefaultValuePrinter 
)
inline

Definition at line 117 of file OptionsChrono.h.

118  valueType(aDefault),
119  internal::typed_base<valueType>(aShortName, aLongName, aExplanation, 1),
120  valuePrinter<valueType>(aValuePrinter) {
121  if (!aRange.empty()) {
122  this->fAddToRange(aRange);
123  }
124  }

Member Function Documentation

◆ fAddDefaultFromStream()

template<class Rep , class Period >
void options::single< std::chrono::duration< Rep, Period > >::fAddDefaultFromStream ( std::istream &  aStream)
inlineoverridevirtual

special for use in the shellScriptOptionParser

read a value from aStram and set that as default

Implements options::base.

Definition at line 125 of file OptionsChrono.h.

125  {
126  std::getline(aStream, lOriginalString);
127  try {
129  } catch (const std::runtime_error& e) {
130  throw internal::optionError(this, e.what());
131  }
132  }

References options::internal::parseDurationString().

Here is the call graph for this function:

◆ fCheckRange()

template<class Rep , class Period >
void options::single< std::chrono::duration< Rep, Period > >::fCheckRange ( ) const
inlineoverridevirtual

Implements options::base.

Definition at line 146 of file OptionsChrono.h.

146  {
147  this->fCheckValueForRange(*this);
148  }

References options::internal::typed_base< T >::fCheckValueForRange().

Here is the call graph for this function:

◆ fDefaultValuePrinter()

template<class Rep , class Period >
static void options::single< std::chrono::duration< Rep, Period > >::fDefaultValuePrinter ( std::ostream &  aStream,
const valueType aValue 
)
inlinestatic

Definition at line 111 of file OptionsChrono.h.

111  {
112  using escapedIO::operator<<;
113  aStream << aValue;
114  };

◆ fSetMe()

template<class Rep , class Period >
void options::single< std::chrono::duration< Rep, Period > >::fSetMe ( std::istream &  aStream,
const internal::sourceItem aSource 
)
inlineoverridevirtual

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

Implements options::base.

Definition at line 136 of file OptionsChrono.h.

136  {
137  using escapedIO::operator>>;
138  aStream >> lOriginalString;
139  try {
141  } catch (const std::runtime_error& e) {
142  throw internal::optionError(this, e.what());
143  }
144  this->fSetSource(aSource);
145  }

References options::base::fSetSource(), and options::internal::parseDurationString().

Here is the call graph for this function:

◆ fWriteValue()

template<class Rep , class Period >
void options::single< std::chrono::duration< Rep, Period > >::fWriteValue ( std::ostream &  aStream) const
inlineoverridevirtual

write textual representation of value to a std::ostream

Implements options::base.

Definition at line 133 of file OptionsChrono.h.

133  {
134  this->lValuePrinter(aStream, *this);
135  }

Member Data Documentation

◆ lRange

template<class Rep , class Period >
std::vector<valueType> options::single< std::chrono::duration< Rep, Period > >::lRange
protected

Definition at line 108 of file OptionsChrono.h.


The documentation for this class was generated from the following file:
options::single< std::chrono::duration< Rep, Period > >::fDefaultValuePrinter
static void fDefaultValuePrinter(std::ostream &aStream, const valueType &aValue)
Definition: OptionsChrono.h:111
options::internal::typed_base< std::chrono::duration< Rep, Period > >::fAddToRange
virtual void fAddToRange(rangeValueType aValue)
add a value to the range of allowed values
Definition: Options.h:458
options::internal::typed_base< std::chrono::duration< Rep, Period > >::fCheckValueForRange
virtual void fCheckValueForRange(const compareValueType &aValue) const
Definition: Options.h:506
options::originalStringKeeper::lOriginalString
std::string lOriginalString
Definition: Options.h:866
options::valuePrinter::valuePrinterType
void(* valuePrinterType)(std::ostream &, const T &)
Definition: Options.h:176
options::internal::parseDurationString
void parseDurationString(std::chrono::duration< Rep, Period > &aDuration, const std::string &aString, int *aMonths=nullptr, int *aYears=nullptr)
parse a string into a std::chrono::duration, if given set the years and months separately
Definition: OptionsChrono.h:22
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
options::valuePrinter< std::chrono::duration< Rep, Period > >::lValuePrinter
valuePrinterType lValuePrinter
Definition: Options.h:178
options::single< std::chrono::duration< Rep, Period > >::valueType
std::chrono::duration< Rep, Period > valueType
Definition: OptionsChrono.h:106