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

#include <CmdLineOptionParser.hh>

Inheritance diagram for StringCmdLineOptionParser:
Inheritance graph
Collaboration diagram for StringCmdLineOptionParser:
Collaboration graph

Public Member Functions

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

Private Member Functions

 StringCmdLineOptionParser (const StringCmdLineOptionParser &)
 Copying not allowed. More...
 
StringCmdLineOptionParseroperator= (const StringCmdLineOptionParser &)
 Assignment not allowed. More...
 

Private Attributes

std::string value_
 The value of the option. More...
 

Additional Inherited Members

- Protected Member Functions inherited from CmdLineOptionParser
void setDefined ()
 

Detailed Description

CmdLineOptionParser that has a string as a value.

Definition at line 180 of file CmdLineOptionParser.hh.

Constructor & Destructor Documentation

◆ StringCmdLineOptionParser() [1/2]

StringCmdLineOptionParser::StringCmdLineOptionParser ( 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 347 of file CmdLineOptionParser.cc.

350  : CmdLineOptionParser(name, desc, alias), value_("") {
351 }

◆ ~StringCmdLineOptionParser()

StringCmdLineOptionParser::~StringCmdLineOptionParser ( )
virtual

Destructor.

Definition at line 356 of file CmdLineOptionParser.cc.

356  {
357 }

◆ StringCmdLineOptionParser() [2/2]

StringCmdLineOptionParser::StringCmdLineOptionParser ( const StringCmdLineOptionParser )
private

Copying not allowed.

Member Function Documentation

◆ copy()

OptionValue * StringCmdLineOptionParser::copy ( ) const
virtual

Copies the option value into a OptionValue object.

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

Returns
A copy of the option value.

Implements CmdLineOptionParser.

Definition at line 368 of file CmdLineOptionParser.cc.

368  {
370  return copy;
371 }

References value_.

◆ operator=()

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

Assignment not allowed.

◆ parseValue()

bool StringCmdLineOptionParser::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 382 of file CmdLineOptionParser.cc.

383  {
384  if (prefix != "") {
385  string msg = "Illegal prefix for string option";
386  string method = "StringCmdLineOptionParser::parseValue()";
387  throw IllegalCommandLine(__FILE__, __LINE__, method, msg);
388  }
389 
390  if (arguments == "") {
391  string msg = "Missing value for string option.";
392  string method = "StringCmdLineOptionParser::parseValue()";
393  throw IllegalCommandLine(__FILE__, __LINE__, method, msg);
394  }
395 
396  value_ = arguments;
397 
398  setDefined();
399  return true;
400 }

References CmdLineOptionParser::setDefined(), and value_.

Here is the call graph for this function:

◆ String()

string StringCmdLineOptionParser::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 403 of file CmdLineOptionParser.cc.

403  {
404  assert(index == 0);
405  return value_;
406 }

References assert, and value_.

Member Data Documentation

◆ value_

std::string StringCmdLineOptionParser::value_
private

The value of the option.

Definition at line 200 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
StringOptionValue
Definition: OptionValue.hh:133
StringCmdLineOptionParser::copy
virtual OptionValue * copy() const
Definition: CmdLineOptionParser.cc:368
StringCmdLineOptionParser::value_
std::string value_
The value of the option.
Definition: CmdLineOptionParser.hh:200