ewmscp  ..
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
options::single< std::chrono::system_clock::time_point > Class Reference

#include <OptionsChrono.h>

Inheritance diagram for options::single< std::chrono::system_clock::time_point >:
[legend]
Collaboration diagram for options::single< std::chrono::system_clock::time_point >:
[legend]

Public Types

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

Public Member Functions

 single (char aShortName, const std::string &aLongName, const std::string &aExplanation, valueType aDefault=valueType::clock::now(), const std::vector< valueType > &aRange={}, valuePrinterType aValuePrinter=fDefaultValuePrinter)
 
 single (char aShortName, const std::string &aLongName, const std::string &aExplanation, const std::string &aDefault, const std::vector< std::string > &aRange={}, valuePrinterType aValuePrinter=fDefaultValuePrinter)
 
void fAddDefaultFromStream (std::istream &aStream) override
 special for use in the shellScriptOptionParser More...
 
void fWriteRange (std::ostream &aStream) const override
 
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::system_clock::time_point >
 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::originalStringKeeper
void fWriteOriginalString (std::ostream &aStream) const
 
const std::string & fGetOriginalString () const
 
- Public Member Functions inherited from options::valuePrinter< std::chrono::system_clock::time_point >
 valuePrinter ()
 
 valuePrinter (valuePrinterType aValuePrinter)
 
virtual void fSetValuePrinter (valuePrinterType aValuePrinter)
 

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::system_clock::time_point >
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::originalStringKeeper
std::string lOriginalString
 
- Protected Attributes inherited from options::valuePrinter< std::chrono::system_clock::time_point >
valuePrinterType lValuePrinter
 

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

Definition at line 68 of file OptionsChrono.h.

Member Typedef Documentation

◆ valueType

typedef rangeValueType options::single< std::chrono::system_clock::time_point >::valueType

Definition at line 74 of file OptionsChrono.h.

Constructor & Destructor Documentation

◆ single() [1/2]

options::single< std::chrono::system_clock::time_point >::single ( char  aShortName,
const std::string &  aLongName,
const std::string &  aExplanation,
valueType  aDefault = valueType::clock::now(),
const std::vector< valueType > &  aRange = {},
valuePrinterType  aValuePrinter = fDefaultValuePrinter 
)

Definition at line 399 of file OptionsChrono.cpp.

399  :
400  internal::typed_base<std::chrono::system_clock::time_point>(aShortName, aLongName, aExplanation, 1),
401  valuePrinter(aValuePrinter) {
402  *static_cast<valueType*>(this) = aDefault;
403  if (!aRange.empty()) {
404  fAddToRange(aRange);
405  }
406  }

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

Here is the call graph for this function:

◆ single() [2/2]

options::single< std::chrono::system_clock::time_point >::single ( char  aShortName,
const std::string &  aLongName,
const std::string &  aExplanation,
const std::string &  aDefault,
const std::vector< std::string > &  aRange = {},
valuePrinterType  aValuePrinter = fDefaultValuePrinter 
)

Definition at line 407 of file OptionsChrono.cpp.

407  :
408  internal::typed_base<std::chrono::system_clock::time_point>(aShortName, aLongName, aExplanation, 1),
409  valuePrinter(aValuePrinter) {
410  try {
411  *static_cast<valueType*>(this) = internal::fParseTimePointString(aDefault);
412  } catch (const std::runtime_error& e) {
413  throw internal::optionError(this, e.what());
414  }
415  lOriginalString = aDefault;
416  if (!aRange.empty()) {
417  fAddToRange(aRange);
418  }
419  }

References options::internal::typed_base< T >::fAddToRange(), and options::internal::fParseTimePointString().

Here is the call graph for this function:

Member Function Documentation

◆ fAddDefaultFromStream()

void options::single< std::chrono::system_clock::time_point >::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 421 of file OptionsChrono.cpp.

421  {
422  std::getline(aStream, lOriginalString);
423  try {
425  } catch (const std::runtime_error& e) {
426  throw internal::optionError(this, e.what());
427  }
428  }

References options::internal::fParseTimePointString().

Here is the call graph for this function:

◆ fCheckRange()

void options::single< std::chrono::system_clock::time_point >::fCheckRange ( ) const
inlineoverridevirtual

Implements options::base.

Definition at line 89 of file OptionsChrono.h.

89  {
90  this->fCheckValueForRange(*this);
91  }

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

Here is the call graph for this function:

◆ fDefaultValuePrinter()

void options::single< std::chrono::system_clock::time_point >::fDefaultValuePrinter ( std::ostream &  aStream,
const valueType aValue 
)
static

Definition at line 393 of file OptionsChrono.cpp.

393  {
394  auto flags(aStream.flags());
395  aStream << std::fixed;
396  aStream << std::chrono::duration<double>(aValue.time_since_epoch()).count();
397  aStream.flags(flags);
398  }

◆ fSetMe()

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

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

Implements options::base.

Definition at line 452 of file OptionsChrono.cpp.

452  {
453  using escapedIO::operator>>;
454  aStream >> lOriginalString;
455  try {
457  } catch (const std::runtime_error& e) {
458  throw internal::optionError(this, e.what());
459  }
460  fSetSource(aSource);
461  }

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

Here is the call graph for this function:

◆ fWriteRange()

void options::single< std::chrono::system_clock::time_point >::fWriteRange ( std::ostream &  aStream) const
overridevirtual

Reimplemented from options::base.

Definition at line 430 of file OptionsChrono.cpp.

430  {
431  if (! lRange.empty()) {
432  aStream << "# allowed range is";
433  if (lRange.size() == 2) {
434  aStream << " [";
435  lValuePrinter(aStream, lRange[0]);
436  aStream << ", ";
437  lValuePrinter(aStream, lRange[1]);
438  aStream << "]\n";
439  } else {
440  for (auto& rangeElement : lRange) {
441  lValuePrinter(aStream, rangeElement);
442  aStream << "\n";
443  }
444  aStream << "\n";
445  }
446  }
447  }

References options::internal::typed_base< T >::lRange.

◆ fWriteValue()

void options::single< std::chrono::system_clock::time_point >::fWriteValue ( std::ostream &  aStream) const
overridevirtual

write textual representation of value to a std::ostream

Implements options::base.

Definition at line 449 of file OptionsChrono.cpp.

449  {
450  lValuePrinter(aStream, *this);
451  }

Referenced by main().

Here is the caller graph for this function:

Member Data Documentation

◆ lRange

std::vector<valueType> options::single< std::chrono::system_clock::time_point >::lRange
protected

Definition at line 76 of file OptionsChrono.h.


The documentation for this class was generated from the following files:
options::internal::typed_base< std::chrono::system_clock::time_point >::fAddToRange
virtual void fAddToRange(rangeValueType aValue)
add a value to the range of allowed values
Definition: Options.h:458
options::valuePrinter< std::chrono::system_clock::time_point >::valuePrinter
valuePrinter()
Definition: Options.h:180
options::internal::typed_base< std::chrono::system_clock::time_point >::fCheckValueForRange
virtual void fCheckValueForRange(const compareValueType &aValue) const
Definition: Options.h:506
options::originalStringKeeper::lOriginalString
std::string lOriginalString
Definition: Options.h:866
options::single< std::chrono::system_clock::time_point >::lRange
std::vector< valueType > lRange
Definition: OptionsChrono.h:76
options::internal::fParseTimePointString
std::chrono::system_clock::time_point fParseTimePointString(const std::string &aString)
Definition: OptionsChrono.cpp:183
options::single< std::chrono::system_clock::time_point >::valueType
rangeValueType valueType
Definition: OptionsChrono.h:74
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::system_clock::time_point >::lValuePrinter
valuePrinterType lValuePrinter
Definition: Options.h:178