clingo
|
Manages the value of an option and defines how it is parsed from a string. More...
#include <value.h>
Public Types | |
enum | State { value_unassigned = 0, value_defaulted = 1, value_fixed = 2 } |
Possible (tentative) states of an option value. More... | |
enum | DescType { desc_name = 1, desc_default = 2, desc_implicit = 4 } |
Possible value descriptions. More... | |
Public Member Functions | |
virtual | ~Value () |
State | state () const |
Returns the current state of this value. More... | |
Value * | state (Value::State s) |
const char * | arg () const |
Returns the name of this value. More... | |
Value * | arg (const char *n) |
Value * | alias (char c) |
Sets an alias name for the corresponding option. More... | |
char | alias () const |
Value * | level (DescriptionLevel lev) |
Sets a description level for the corresponding option. More... | |
DescriptionLevel | level () const |
Returns the description level of the corresponding option. More... | |
bool | isNegatable () const |
Returns true if this is the value of an negatable option. More... | |
Value * | negatable () |
bool | isImplicit () const |
Returns true if value can be implicitly created from an empty string. More... | |
bool | isFlag () const |
Returns true if this is the value of an option flag. More... | |
Value * | flag () |
bool | isComposing () const |
Returns true if the value of this option can be composed from multiple source. More... | |
Value * | composing () |
Value * | defaultsTo (const char *v) |
const char * | defaultsTo () const |
Returns the default value of this or 0 none exists. More... | |
Value * | implicit (const char *str) |
const char * | implicit () const |
Returns the implicit value of this or 0 if isImplicit() == false. More... | |
bool | parse (const std::string &name, const std::string &value, State st=value_fixed) |
Parses the given string and updates the value's state. More... | |
Protected Types | |
enum | Property { property_implicit = 1, property_flag = 3, property_composing = 4, property_negatable = 8, property_location =16, not_a_property =32 } |
typedef unsigned char | byte_t |
Protected Member Functions | |
Value (byte_t flagSet, State initial=value_unassigned) | |
void | setProperty (Property f) |
void | clearProperty (Property f) |
bool | hasProperty (Property f) const |
bool | state (bool b, State s) |
virtual bool | doParse (const std::string &name, const std::string &value)=0 |
const char * | desc (DescType t) const |
Value * | desc (DescType t, const char *d) |
Manages the value of an option and defines how it is parsed from a string.
The library maintains a 1:1-relationship between options and their values. That is, an option has exactly one value and a value has exactly one state w.r.t its option.
|
protected |
|
protected |
|
virtual |
|
protected |
|
inline |
Sets an alias name for the corresponding option.
|
inline |
const char * ProgramOptions::Value::arg | ( | ) | const |
Returns the name of this value.
|
inline |
|
inlineprotected |
|
inline |
Marks the value as composing.
|
inline |
Sets a default value for this value.
|
inline |
Returns the default value of this or 0 none exists.
|
protected |
|
protectedpure virtual |
|
inline |
Marks the value as flag.
|
inlineprotected |
|
inline |
Sets an implicit value, which will be used if option is given without an adjacent value, e.g. '–option' instead of '–option value'
const char * ProgramOptions::Value::implicit | ( | ) | const |
Returns the implicit value of this or 0 if isImplicit() == false.
|
inline |
Returns true if the value of this option can be composed from multiple source.
|
inline |
Returns true if this is the value of an option flag.
Similar to isImplicit but with the difference that no value is accepted on the command-line.
Used for options like '–help' or '–version'.
|
inline |
Returns true if value can be implicitly created from an empty string.
|
inline |
Returns true if this is the value of an negatable option.
If an option '–option' is negatable, passing '–no-option' on the command-line will set the value of '–option' to 'no'.
|
inline |
Sets a description level for the corresponding option.
Description levels can be used to suppress certain options when generating option descriptions.
|
inline |
Returns the description level of the corresponding option.
|
inline |
bool ProgramOptions::Value::parse | ( | const std::string & | name, |
const std::string & | value, | ||
State | st = value_fixed |
||
) |
Parses the given string and updates the value's state.
name | The name of the option associated with this value. |
value | The value to parse. |
st | The state to which the value should transition if parsing is succesful. |
|
inlineprotected |
|
inline |
Returns the current state of this value.
|
inline |
Sets the (initial) state of this value to s.
|
inlineprotected |