OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
BoolCmdLineOptionParser Class Reference

#include <CmdLineOptionParser.hh>

Inheritance diagram for BoolCmdLineOptionParser:
Inheritance graph
Collaboration diagram for BoolCmdLineOptionParser:
Collaboration graph

Public Member Functions

 BoolCmdLineOptionParser (std::string name, std::string desc, std::string alias="", bool hidden=false)
 
virtual ~BoolCmdLineOptionParser ()
 
virtual OptionValuecopy () const
 
virtual bool parseValue (std::string arguments, std::string prefix)
 
virtual bool isFlagOn () const
 
virtual bool isFlagOff () const
 
- Public Member Functions inherited from CmdLineOptionParser
 CmdLineOptionParser (std::string name, std::string desc, std::string alias, bool hidden=false)
 
virtual ~CmdLineOptionParser ()
 
std::string longName () const
 
std::string shortName () const
 
std::string description () const
 
bool isHidden ()
 
bool isDefined ()
 
virtual int integer (int index=0) const
 
virtual unsigned unsignedInteger (int index=0) const
 
virtual std::string String (int index=0) const
 
virtual double real () const
 
virtual int listSize () const
 

Private Member Functions

 BoolCmdLineOptionParser (const BoolCmdLineOptionParser &)
 Copying not allowed.
 
BoolCmdLineOptionParseroperator= (const BoolCmdLineOptionParser &)
 Assignment not allowed.
 

Private Attributes

bool value_
 The value of option.
 

Additional Inherited Members

- Protected Member Functions inherited from CmdLineOptionParser
void setDefined ()
 

Detailed Description

CmdLineOptionParser that has a boolean value.

This option is also called 'flag'.

Definition at line 278 of file CmdLineOptionParser.hh.

Constructor & Destructor Documentation

◆ BoolCmdLineOptionParser() [1/2]

BoolCmdLineOptionParser::BoolCmdLineOptionParser ( std::string  name,
std::string  desc,
std::string  alias = "",
bool  hidden = false 
)

Constructor.

Parameters
nameThe name of the option.
descThe description of the option.
aliasThe short name of the option.

Definition at line 591 of file CmdLineOptionParser.cc.

595 :
596 CmdLineOptionParser(name, desc, alias, hidden), value_(false) {
597}
bool value_
The value of option.

◆ ~BoolCmdLineOptionParser()

BoolCmdLineOptionParser::~BoolCmdLineOptionParser ( )
virtual

Destructor.

Definition at line 602 of file CmdLineOptionParser.cc.

602 {
603}

◆ BoolCmdLineOptionParser() [2/2]

BoolCmdLineOptionParser::BoolCmdLineOptionParser ( const BoolCmdLineOptionParser )
private

Copying not allowed.

Member Function Documentation

◆ copy()

OptionValue * BoolCmdLineOptionParser::copy ( ) const
virtual

Copies the option value into a OptionValue object.

Client is responsible of deallocating the memeory reserved for the returned object.

Returns
A copy of the option value.

Implements CmdLineOptionParser.

Definition at line 614 of file CmdLineOptionParser.cc.

614 {
616 return copy;
617}
virtual OptionValue * copy() const

References copy(), and value_.

Referenced by copy().

Here is the call graph for this function:

◆ isFlagOff()

bool BoolCmdLineOptionParser::isFlagOff ( ) const
virtual

Returns true if the flag is not set.

Returns
Inverse of the boolean flag.
Exceptions
WrongSubclassIs never thrown by this function.

Reimplemented from CmdLineOptionParser.

Definition at line 666 of file CmdLineOptionParser.cc.

666 {
667 return !value_;
668}

References value_.

◆ isFlagOn()

bool BoolCmdLineOptionParser::isFlagOn ( ) const
virtual

Returns true if the flag is set.

Returns
The boolean flag value.
Exceptions
WrongSubclassIs never thrown by this function.

Reimplemented from CmdLineOptionParser.

Definition at line 655 of file CmdLineOptionParser.cc.

655 {
656 return value_;
657}

References value_.

◆ operator=()

BoolCmdLineOptionParser & BoolCmdLineOptionParser::operator= ( const BoolCmdLineOptionParser )
private

Assignment not allowed.

◆ parseValue()

bool BoolCmdLineOptionParser::parseValue ( std::string  arguments,
std::string  prefix 
)
virtual

Parses the value of option.

Parameters
argumentsThe arguments for option.
prefixThe prefix of option.
Returns
True if parsing is ready, otherwise false.
Exceptions
IllegalCommandLineIf the prefix or arguments are invalid.

Implements CmdLineOptionParser.

Definition at line 628 of file CmdLineOptionParser.cc.

628 {
629 if (prefix == "no-") {
630 value_ = false;
631 } else if (prefix == "") {
632 value_ = true;
633 } else {
634 string msg = "Illegal prefix for boolean option " + longName() +
635 ": " + prefix;
636 string method = "BoolCmdLineOptionParser::parseValue()";
637 throw IllegalCommandLine(__FILE__, __LINE__, method, msg);
638 }
639
640 if (arguments != "") {
641 return false;
642 } else {
643 setDefined();
644 return true;
645 }
646}
std::string longName() const

References CmdLineOptionParser::longName(), CmdLineOptionParser::setDefined(), and value_.

Here is the call graph for this function:

Member Data Documentation

◆ value_

bool BoolCmdLineOptionParser::value_
private

The value of option.

Definition at line 300 of file CmdLineOptionParser.hh.

Referenced by copy(), isFlagOff(), isFlagOn(), and parseValue().


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