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

#include <CmdLineOptionParser.hh>

Inheritance diagram for RealCmdLineOptionParser:
Inheritance graph
Collaboration diagram for RealCmdLineOptionParser:
Collaboration graph

Public Member Functions

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

Private Member Functions

 RealCmdLineOptionParser (const RealCmdLineOptionParser &)
 Copying not allowed.
 
RealCmdLineOptionParseroperator= (const RealCmdLineOptionParser &)
 Assignment not allowed.
 

Private Attributes

double value_
 The value of the option.
 

Additional Inherited Members

- Protected Member Functions inherited from CmdLineOptionParser
void setDefined ()
 

Detailed Description

CmdLineOptionParser that has a real value.

Definition at line 246 of file CmdLineOptionParser.hh.

Constructor & Destructor Documentation

◆ RealCmdLineOptionParser() [1/2]

RealCmdLineOptionParser::RealCmdLineOptionParser ( 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 507 of file CmdLineOptionParser.cc.

510 :
511 CmdLineOptionParser(name, desc, alias), value_(0) {
512}
double value_
The value of the option.

◆ ~RealCmdLineOptionParser()

RealCmdLineOptionParser::~RealCmdLineOptionParser ( )
virtual

Destructor.

Definition at line 517 of file CmdLineOptionParser.cc.

517 {
518}

◆ RealCmdLineOptionParser() [2/2]

RealCmdLineOptionParser::RealCmdLineOptionParser ( const RealCmdLineOptionParser )
private

Copying not allowed.

Member Function Documentation

◆ copy()

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

529 {
531 return copy;
532}
virtual OptionValue * copy() const

References copy(), and value_.

Referenced by copy().

Here is the call graph for this function:

◆ operator=()

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

Assignment not allowed.

◆ parseValue()

bool RealCmdLineOptionParser::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
IllegalCommandLineIf the argument is erronous.

Implements CmdLineOptionParser.

Definition at line 543 of file CmdLineOptionParser.cc.

543 {
544 if (prefix != "") {
545 string msg = "Illegal prefix for real option";
546 string method = "RealCmdLineOptionParser::parseValue()";
547 throw IllegalCommandLine(__FILE__, __LINE__, method, msg);
548 }
549
550 // string must not contain anything else than numbers and a dot.
551 if (arguments == "") {
552 string msg = "Missing value for real option.";
553 string method = "RealCmdLineOptionParser::parseValue()";
554 throw IllegalCommandLine(__FILE__, __LINE__, method, msg);
555 }
556
557 istringstream istream(arguments);
558 if((!(istream >> value_)) || istream.peek() != EOF) {
559 string msg = "Format of " + longName() + " option value was wrong: "
560 + arguments;
561 string method = "RealCmdLineOptionParser::parseValue()";
562 throw IllegalCommandLine(__FILE__, __LINE__, method, msg);
563 }
564
565 setDefined();
566 return true;
567}
std::string longName() const

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

Here is the call graph for this function:

◆ real()

double RealCmdLineOptionParser::real ( ) const
virtual

Returns the real value.

Returns
The real value.
Exceptions
WrongSubclassIs never thrown by this function.

Reimplemented from CmdLineOptionParser.

Definition at line 576 of file CmdLineOptionParser.cc.

576 {
577 return value_;
578}

References value_.

Member Data Documentation

◆ value_

double RealCmdLineOptionParser::value_
private

The value of the option.

Definition at line 266 of file CmdLineOptionParser.hh.

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


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