OpenASIP  2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
OptionalStringCmdLineOptionParser Class Reference

#include <CmdLineOptionParser.hh>

Inheritance diagram for OptionalStringCmdLineOptionParser:
Inheritance graph
Collaboration diagram for OptionalStringCmdLineOptionParser:
Collaboration graph

Public Member Functions

 OptionalStringCmdLineOptionParser (std::string name, std::string desc, std::string alias="")
 
virtual ~OptionalStringCmdLineOptionParser ()
 
virtual OptionValuecopy () const
 
virtual bool parseValue (std::string arguments, std::string prefix)
 
virtual std::string String (int index=0) const
 
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 double real () const
 
virtual int listSize () const
 

Private Member Functions

 OptionalStringCmdLineOptionParser (const OptionalStringCmdLineOptionParser &)
 Copying not allowed. More...
 
OptionalStringCmdLineOptionParseroperator= (const OptionalStringCmdLineOptionParser &)
 Assignment not allowed. More...
 

Private Attributes

std::string value_
 The value of the option. More...
 
bool flag_
 The flag status. More...
 

Additional Inherited Members

- Protected Member Functions inherited from CmdLineOptionParser
void setDefined ()
 

Detailed Description

CmdLineOptionParser that acts as flag with optional string value.

Definition at line 210 of file CmdLineOptionParser.hh.

Constructor & Destructor Documentation

◆ OptionalStringCmdLineOptionParser() [1/2]

OptionalStringCmdLineOptionParser::OptionalStringCmdLineOptionParser ( std::string  name,
std::string  desc,
std::string  alias = "" 
)

Constructor.

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

Definition at line 419 of file CmdLineOptionParser.cc.

421  : CmdLineOptionParser(name, desc, alias), value_(""), flag_(false) {
422 }

◆ ~OptionalStringCmdLineOptionParser()

OptionalStringCmdLineOptionParser::~OptionalStringCmdLineOptionParser ( )
virtual

Destructor.

Definition at line 427 of file CmdLineOptionParser.cc.

427  {
428 }

◆ OptionalStringCmdLineOptionParser() [2/2]

OptionalStringCmdLineOptionParser::OptionalStringCmdLineOptionParser ( const OptionalStringCmdLineOptionParser )
private

Copying not allowed.

Member Function Documentation

◆ copy()

OptionValue * OptionalStringCmdLineOptionParser::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 439 of file CmdLineOptionParser.cc.

439  {
441  return copy;
442 }

References value_.

◆ isFlagOff()

bool OptionalStringCmdLineOptionParser::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 492 of file CmdLineOptionParser.cc.

492  {
493  return !flag_;
494 }

References flag_.

◆ isFlagOn()

bool OptionalStringCmdLineOptionParser::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 481 of file CmdLineOptionParser.cc.

481  {
482  return flag_;
483 }

References flag_.

◆ operator=()

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

Assignment not allowed.

◆ parseValue()

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

Parses the value of option.

Parameters
argumentsThe arguments of option.
prefixThe prefix of option.
Returns
True when parsing is ready.
Exceptions
IllegalCommandLineNot thrown.

Implements CmdLineOptionParser.

Definition at line 453 of file CmdLineOptionParser.cc.

454  {
455  if (prefix != "") {
456  string msg = "Illegal prefix for string option";
457  string method = "StringCmdLineOptionParser::parseValue()";
458  throw IllegalCommandLine(__FILE__, __LINE__, method, msg);
459  }
460 
461  value_ = arguments;
462  flag_ = true;
463 
464  setDefined();
465  return true;
466 }

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

Here is the call graph for this function:

◆ String()

string OptionalStringCmdLineOptionParser::String ( int  index = 0) const
virtual

This implementation should be never called.

Returns
Nothing.
Exceptions
WrongSubclassCalled for a wrong subclass.

Reimplemented from CmdLineOptionParser.

Definition at line 469 of file CmdLineOptionParser.cc.

469  {
470  assert(index == 0);
471  return value_;
472 }

References assert, and value_.

Member Data Documentation

◆ flag_

bool OptionalStringCmdLineOptionParser::flag_
private

The flag status.

Definition at line 236 of file CmdLineOptionParser.hh.

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

◆ value_

std::string OptionalStringCmdLineOptionParser::value_
private

The value of the option.

Definition at line 234 of file CmdLineOptionParser.hh.

Referenced by copy(), parseValue(), and String().


The documentation for this class was generated from the following files:
CmdLineOptionParser::setDefined
void setDefined()
Definition: CmdLineOptionParser.cc:159
IllegalCommandLine
Definition: Exception.hh:438
assert
#define assert(condition)
Definition: Application.hh:86
CmdLineOptionParser::CmdLineOptionParser
CmdLineOptionParser(std::string name, std::string desc, std::string alias, bool hidden=false)
Definition: CmdLineOptionParser.cc:62
OptionalStringCmdLineOptionParser::flag_
bool flag_
The flag status.
Definition: CmdLineOptionParser.hh:236
StringOptionValue
Definition: OptionValue.hh:133
OptionalStringCmdLineOptionParser::copy
virtual OptionValue * copy() const
Definition: CmdLineOptionParser.cc:439
OptionalStringCmdLineOptionParser::value_
std::string value_
The value of the option.
Definition: CmdLineOptionParser.hh:234