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

#include <CmdLineOptionParser.hh>

Inheritance diagram for UnsignedIntegerCmdLineOptionParser:
Inheritance graph
Collaboration diagram for UnsignedIntegerCmdLineOptionParser:
Collaboration graph

Public Member Functions

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

Private Member Functions

 UnsignedIntegerCmdLineOptionParser (const UnsignedIntegerCmdLineOptionParser &)
 Copying not allowed.
 
UnsignedIntegerCmdLineOptionParseroperator= (const UnsignedIntegerCmdLineOptionParser &)
 Assignment not allowed.
 

Private Attributes

unsigned value_
 The value of option.
 

Additional Inherited Members

- Protected Member Functions inherited from CmdLineOptionParser
void setDefined ()
 

Detailed Description

Models an option that has an unsigned integer value.

Definition at line 147 of file CmdLineOptionParser.hh.

Constructor & Destructor Documentation

◆ UnsignedIntegerCmdLineOptionParser() [1/2]

UnsignedIntegerCmdLineOptionParser::UnsignedIntegerCmdLineOptionParser ( 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 269 of file CmdLineOptionParser.cc.

272 :
273 CmdLineOptionParser(name, desc, alias), value_(0) {
274}
unsigned value_
The value of option.

◆ ~UnsignedIntegerCmdLineOptionParser()

UnsignedIntegerCmdLineOptionParser::~UnsignedIntegerCmdLineOptionParser ( )
virtual

Destructor.

Definition at line 279 of file CmdLineOptionParser.cc.

279 {
280}

◆ UnsignedIntegerCmdLineOptionParser() [2/2]

UnsignedIntegerCmdLineOptionParser::UnsignedIntegerCmdLineOptionParser ( const UnsignedIntegerCmdLineOptionParser )
private

Copying not allowed.

Member Function Documentation

◆ copy()

OptionValue * UnsignedIntegerCmdLineOptionParser::copy ( ) const
virtual

Implements CmdLineOptionParser.

Definition at line 283 of file CmdLineOptionParser.cc.

References copy(), and value_.

Referenced by copy().

Here is the call graph for this function:

◆ operator=()

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

Assignment not allowed.

◆ parseValue()

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

Parses the unsigned integer option value.

Parameters
argumentsThe arguments of option.
prefixThe prefix of option.
Returns
True when parsing is ready.
Exceptions
IllegalCommandLineIf the arguments of option are erronous.

Implements CmdLineOptionParser.

Definition at line 297 of file CmdLineOptionParser.cc.

298 {
299 if (prefix != "") {
300 string msg = "Illegal prefix for unsigned integer option";
301 string method = "UnsignedIntegerCmdLineOptionParser::parseValue()";
302 throw IllegalCommandLine(__FILE__, __LINE__, method, msg);
303 }
304
305 if (arguments == "") {
306 string msg = "Missing value for unsigned integer option.";
307 string method = "UnsignedIntegerCmdLineOptionParser::parseValue()";
308 throw IllegalCommandLine(__FILE__, __LINE__, method, msg);
309 }
310
311 istringstream istream(arguments);
312 if((!(istream >> value_)) || istream.peek() != EOF) {
313 string msg = "Format of " + longName() + " option value was wrong: "
314 + arguments;
315 string method = "unsignedIntegerCmdLineOptionParser::parseValue()";
316 throw IllegalCommandLine(__FILE__, __LINE__, method, msg);
317 }
318
319 setDefined();
320 return true;
321}
std::string longName() const

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

Here is the call graph for this function:

◆ unsignedInteger()

unsigned UnsignedIntegerCmdLineOptionParser::unsignedInteger ( int  index = 0) const
virtual

Returns the value of the unsigned integer option.

Parameters
indexThis must be zero for usigned integer option.
Returns
The value of usigned integer option.
Exceptions
WrongSubclassIs never thrown by this function.

Reimplemented from CmdLineOptionParser.

Definition at line 331 of file CmdLineOptionParser.cc.

331 {
332 assert(index == 0);
333 return value_;
334}
#define assert(condition)

References assert, and value_.

Member Data Documentation

◆ value_

unsigned UnsignedIntegerCmdLineOptionParser::value_
private

The value of option.

Definition at line 169 of file CmdLineOptionParser.hh.

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


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