Static Value-Flow Analysis
Loading...
Searching...
No Matches
OptionMultiple< T > Class Template Reference

#include <CommandLine.h>

Inheritance diagram for OptionMultiple< T >:
OptionBase

Public Types

typedef std::vector< OptionPossibility< T > > OptionPossibilities

Public Member Functions

 OptionMultiple (std::string description, OptionPossibilities possibilities)
virtual bool canSet (void) const override
 Can this option be set?
virtual bool parseAndSetValue (const std::string s) override
 From a given string, set the value of this option.
virtual bool isMultiple (void) const override
 Whether this option is an OptionMultiple.
bool nothingSet (void) const
 If the bitset is empty.
bool operator() (const T v) const
 Returns whether the value v had been set as an option.

Private Attributes

std::unordered_map< T, bool > optionValues
OptionPossibilities possibilities

Additional Inherited Members

Static Public Member Functions inherited from OptionBase
static std::vector< std::string > parseOptions (int argc, char *argv[], std::string description, std::string callFormat)
Protected Types inherited from OptionBase
typedef std::pair< std::string, std::string > PossibilityDescription
 Name/description pairs.
typedef std::vector< std::pair< std::string, std::string > > PossibilityDescriptions
template<typename T>
using OptionPossibility = std::tuple<T, std::string, std::string>
Protected Member Functions inherited from OptionBase
 OptionBase (std::string name, std::string description)
 OptionBase (std::string name, std::string description, PossibilityDescriptions possibilityDescriptions)
virtual bool isBool (void) const
Static Protected Member Functions inherited from OptionBase
template<typename T>
static PossibilityDescriptions extractPossibilityDescriptions (const std::vector< OptionPossibility< T > > possibilities)
static std::map< std::string, OptionBase * > & getOptionsMap (void)
Protected Attributes inherited from OptionBase
std::string name
std::string description
PossibilityDescriptions possibilityDescriptions
 For when we have possibilities like in an OptionMap.

Detailed Description

template<typename T>
class OptionMultiple< T >

Options which form a kind of bit set. There are multiple names and n of them can be set. Opt(v) tests whether v had been set, aborting if v is invalid.

Definition at line 462 of file CommandLine.h.

Member Typedef Documentation

◆ OptionPossibilities

template<typename T>
typedef std::vector<OptionPossibility<T> > OptionMultiple< T >::OptionPossibilities

Definition at line 465 of file CommandLine.h.

Constructor & Destructor Documentation

◆ OptionMultiple()

template<typename T>
OptionMultiple< T >::OptionMultiple ( std::string description,
OptionPossibilities possibilities )
inline

Definition at line 467 of file CommandLine.h.

469 {
471 {
472 optionValues[std::get<0>(op)] = false;
473 }
474
476 {
479 }
480 }
static PossibilityDescriptions extractPossibilityDescriptions(const std::vector< OptionPossibility< T > > possibilities)
std::tuple< T, std::string, std::string > OptionPossibility
Definition CommandLine.h:30
std::string description
OptionBase(std::string name, std::string description)
Definition CommandLine.h:33
static std::map< std::string, OptionBase * > & getOptionsMap(void)
std::unordered_map< T, bool > optionValues
OptionPossibilities possibilities

Member Function Documentation

◆ canSet()

template<typename T>
virtual bool OptionMultiple< T >::canSet ( void ) const
inlineoverridevirtual

Can this option be set?

Implements OptionBase.

Definition at line 482 of file CommandLine.h.

483 {
484 return true;
485 }

◆ isMultiple()

template<typename T>
virtual bool OptionMultiple< T >::isMultiple ( void ) const
inlineoverridevirtual

Whether this option is an OptionMultiple.

Reimplemented from OptionBase.

Definition at line 502 of file CommandLine.h.

503 {
504 return true;
505 }

◆ nothingSet()

template<typename T>
bool OptionMultiple< T >::nothingSet ( void ) const
inline

If the bitset is empty.

Definition at line 508 of file CommandLine.h.

509 {
511 {
512 if (tb.second) return false;
513 }
514
515 return true;
516 }

◆ operator()()

template<typename T>
bool OptionMultiple< T >::operator() ( const T v) const
inline

Returns whether the value v had been set as an option.

Definition at line 519 of file CommandLine.h.

520 {
522 // TODO: disabled as we check for "invalid" values in some places.
523 // assert(ovIt != optionValues.end() && "OptionMultiple: bad value checked");
524 if (ovIt == optionValues.end()) return false;
525 return ovIt->second;
526 }

◆ parseAndSetValue()

template<typename T>
virtual bool OptionMultiple< T >::parseAndSetValue ( const std::string value)
inlineoverridevirtual

From a given string, set the value of this option.

Implements OptionBase.

Definition at line 487 of file CommandLine.h.

488 {
489 // Like in OptionMap basically, except we can have many values.
491 {
492 if (s == std::get<1>(op))
493 {
494 optionValues[std::get<0>(op)] = true;
495 return true;
496 }
497 }
498
499 return false;
500 }

Member Data Documentation

◆ optionValues

template<typename T>
std::unordered_map<T, bool> OptionMultiple< T >::optionValues
private

Is the option set? Use a map rather than a set because it's now easier in one DS to determine whether something is 1) valid, and 2) set.

Definition at line 531 of file CommandLine.h.

◆ possibilities

template<typename T>
OptionPossibilities OptionMultiple< T >::possibilities
private

Definition at line 532 of file CommandLine.h.


The documentation for this class was generated from the following file: