CGRAOmp  0.1
Public Member Functions | Private Attributes | List of all members
CGRAOmp::OptKeyValue Class Reference

A pair of key and value for command line option. More...

#include <OptionPlugin.hpp>

Public Member Functions

 OptKeyValue ()
 Default constructor Instances made by this constructor are always invalidated. More...
 
 OptKeyValue (string key, string value)
 Construct a new Key-Value object. More...
 
 OptKeyValue (const char *s)
  converting constructor from char* More...
 
 OptKeyValue (string keyvalue)
  converting constructor from std::string More...
 
 OptKeyValue (const OptKeyValue &)=default
 copy constructor More...
 
 OptKeyValue (OptKeyValue &&)=default
 move constructor More...
 
pair< string, string > get ()
 Get both key and value. More...
 
string get_key () const
 Get the key. More...
 
string get_value () const
 Get the value. More...
 
 operator bool () const noexcept
 explicit operator for bool More...
 
bool operator!= (const OptKeyValue &rhs)
 equality comparetor More...
 
bool operator== (const OptKeyValue &rhs)
 inequality comparator More...
 
OptKeyValueoperator= (OptKeyValue &&r)=default
 move assignment operator More...
 
OptKeyValueoperator= (const OptKeyValue &r)=default
 copy assignement operator More...
 

Private Attributes

bool valid
 
string key
 
string value
 

Detailed Description

A pair of key and value for command line option.

Constructor & Destructor Documentation

◆ OptKeyValue() [1/6]

CGRAOmp::OptKeyValue::OptKeyValue ( )
inline

Default constructor Instances made by this constructor are always invalidated.

◆ OptKeyValue() [2/6]

CGRAOmp::OptKeyValue::OptKeyValue ( string  key,
string  value 
)
inline

Construct a new Key-Value object.

Parameters
keykey of string
valuevalue of string

◆ OptKeyValue() [3/6]

CGRAOmp::OptKeyValue::OptKeyValue ( const char *  s)
inline

 converting constructor from char*

Parameters
sstring
  • It must be "key=value".
  • Otherwise, the instance will be invalidated

◆ OptKeyValue() [4/6]

CGRAOmp::OptKeyValue::OptKeyValue ( string  keyvalue)

 converting constructor from std::string

Parameters
sstring
  • It must be "key=value".
  • Otherwise, the instance will be invalidated

It parses a string based on a regular expression

◆ OptKeyValue() [5/6]

CGRAOmp::OptKeyValue::OptKeyValue ( const OptKeyValue )
default

copy constructor

◆ OptKeyValue() [6/6]

CGRAOmp::OptKeyValue::OptKeyValue ( OptKeyValue &&  )
default

move constructor

Member Function Documentation

◆ get()

pair<string, string> CGRAOmp::OptKeyValue::get ( )
inline

Get both key and value.

Returns
pair<string, string>, the first is key, and the second is value.

◆ get_key()

string CGRAOmp::OptKeyValue::get_key ( ) const
inline

Get the key.

Returns
string of key

◆ get_value()

string CGRAOmp::OptKeyValue::get_value ( ) const
inline

Get the value.

Returns
string of value

◆ operator bool()

CGRAOmp::OptKeyValue::operator bool ( ) const
inlineexplicitnoexcept

explicit operator for bool

Returns
true in the case of valid key-value
Otherwise, false

The following code can check wherether the option is valid or not.

cl::opt<OptKeyValue> MyOption("optname");
...
if (MyOption) {
// have a valid key-value
} else {
// the option is not specified or invalid
}

◆ operator!=()

bool CGRAOmp::OptKeyValue::operator!= ( const OptKeyValue rhs)
inline

equality comparetor

◆ operator=() [1/2]

OptKeyValue& CGRAOmp::OptKeyValue::operator= ( const OptKeyValue r)
default

copy assignement operator

◆ operator=() [2/2]

OptKeyValue& CGRAOmp::OptKeyValue::operator= ( OptKeyValue &&  r)
default

move assignment operator

◆ operator==()

bool CGRAOmp::OptKeyValue::operator== ( const OptKeyValue rhs)
inline

inequality comparator

Member Data Documentation

◆ key

string CGRAOmp::OptKeyValue::key
private

◆ valid

bool CGRAOmp::OptKeyValue::valid
private

◆ value

string CGRAOmp::OptKeyValue::value
private

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