![]() |
PhoenixMock
1.8.7
Tools to split/merge/print mock used in Phoenix
|
#include <Option.h>
Public Member Functions | |
bool | checkArgument () const |
Check the argument of the parser. More... | |
std::string & | getDocString () |
const std::string & | getDocString () const |
Get the documentation string of the Option. More... | |
std::string & | getLongName () |
const std::string & | getLongName () const |
Get the long name of the Option. More... | |
void | getPossibleOption (std::string &possibleOption, const std::string &cursorOption) const |
Get the possible options for the bash completion. More... | |
void | getPossibleValue (std::string &possibleValue, const std::string &cursorOption) const |
Complete the possible values of the Option. More... | |
std::string & | getShortName () |
const std::string & | getShortName () const |
Get the short name of the Option. More... | |
OptionValue & | getValue () |
const OptionValue & | getValue () const |
Get the value of the Option. More... | |
bool & | isAllowEmpty () |
bool | isAllowEmpty () const |
Get if the option value can be empty. More... | |
bool & | isParsed () |
bool | isParsed () const |
Say if the Option has been parsed or not. More... | |
bool & | isRequired () |
bool | isRequired () const |
Get if the option is required. More... | |
Option & | operator= (const Option &other) |
Definition of equal operator of Option. More... | |
Option (const Option &other) | |
Copy constructor of Option. More... | |
Option (const std::string &longName, const std::string &shortName, bool isRequired, const std::string &docString="") | |
Constructor of Option. More... | |
Option (const std::string &longName, const std::string &shortName, const OptionValue &value, bool isRequired, const std::string &docString="") | |
Constructor of Option. More... | |
Option (const std::string &longName, const std::string &shortName, const OptionValue &value, const std::string &docString="") | |
Constructor of Option. More... | |
Option (const std::string &longName="", const std::string &shortName="", const std::string &docString="") | |
Default constructor of Option. More... | |
bool | parseOption (ArgParser &parser) |
Parse the current option with the given parser. More... | |
void | print (const std::string &indentation="") const |
Print an option. More... | |
void | setDocString (const std::string &docString) |
Set the documentation string of the Option. More... | |
void | setIsAllowEmpty (bool isAllowEmpty) |
Say if the option can be empty or not. More... | |
void | setIsParsed (bool isParsed) |
Say if the Option has been parsed or not. More... | |
void | setIsRequired (bool isRequired) |
Set if the option is required. More... | |
void | setLongName (const std::string &longName) |
Set the long name of the option. More... | |
void | setShortName (const std::string &shortName) |
Set the short name of the option. More... | |
void | setValue (const OptionValue &value) |
Set the value of the option. More... | |
virtual | ~Option () |
Destructeur of Option. More... | |
Protected Member Functions | |
void | copyOption (const Option &other) |
Copy function of Option. More... | |
Private Member Functions | |
void | checkAlreadyParsed (const std::string &longOption) |
Check if the Option has been already parsed. More... | |
void | initialisationOption () |
Initialisation function of the class Option. More... | |
bool | parsePartOption (ArgParser &parser, const std::string &prefix, const std::string &optionName) |
Parse the given option with the parser. More... | |
Private Attributes | |
std::string | p_docString |
Documentation string of the current Option. More... | |
std::string | p_firstPartParsedOption |
First paet of parsed option (needed for bash completion) More... | |
bool | p_isAllowEmpty |
The option can be empty and can have a value. More... | |
bool | p_isParsed |
Say if the option has been parsed or not. More... | |
bool | p_isRequired |
True if the option is required, false if it is optionnal. More... | |
std::string | p_longName |
Long name of the Option. More... | |
std::string | p_shortName |
Short name of the Option. More... | |
OptionValue | p_value |
Value of the Option. More... | |
Option::Option | ( | const std::string & | longName = "" , |
const std::string & | shortName = "" , |
||
const std::string & | docString = "" |
||
) |
Default constructor of Option.
longName | : long name of the option |
shortName | : long name of the option |
docString | : documentation string of the Option |
Definition at line 15 of file Option.cpp.
References initialisationOption().
Option::Option | ( | const std::string & | longName, |
const std::string & | shortName, | ||
const OptionValue & | value, | ||
const std::string & | docString = "" |
||
) |
Constructor of Option.
longName | : long name of the option |
shortName | : long name of the option |
value | : value of the Option |
docString | : documentation string of the Option |
Definition at line 27 of file Option.cpp.
References initialisationOption().
Option::Option | ( | const std::string & | longName, |
const std::string & | shortName, | ||
const OptionValue & | value, | ||
bool | isRequired, | ||
const std::string & | docString = "" |
||
) |
Constructor of Option.
longName | : long name of the option |
shortName | : long name of the option |
value | : value of the Option |
isRequired | : true if the option is required, false if it is optionnal |
docString | : documentation string of the Option |
Definition at line 40 of file Option.cpp.
References initialisationOption().
Option::Option | ( | const std::string & | longName, |
const std::string & | shortName, | ||
bool | isRequired, | ||
const std::string & | docString = "" |
||
) |
Constructor of Option.
longName | : long name of the option |
shortName | : long name of the option |
isRequired | : true if the option is required, false if it is optionnal |
docString | : documentation string of the Option |
Definition at line 52 of file Option.cpp.
References initialisationOption().
Option::Option | ( | const Option & | other | ) |
Copy constructor of Option.
other | : class to copy |
Definition at line 61 of file Option.cpp.
References copyOption().
|
virtual |
|
private |
Check if the Option has been already parsed.
longOption | : used option |
Definition at line 408 of file Option.cpp.
References p_isParsed.
Referenced by parsePartOption().
bool Option::checkArgument | ( | ) | const |
Check the argument of the parser.
Definition at line 252 of file Option.cpp.
References convertOptionTypeToString(), OptionValue::getType(), OptionType::NONE, p_isParsed, p_isRequired, p_longName, p_shortName, p_value, termDefault(), termRed(), and createReleaseCurl::type.
|
protected |
Copy function of Option.
other | : class to copy |
Definition at line 315 of file Option.cpp.
References p_docString, p_firstPartParsedOption, p_isAllowEmpty, p_isParsed, p_isRequired, p_longName, p_shortName, and p_value.
Referenced by operator=(), and Option().
std::string& Option::getDocString | ( | ) |
std::string & Option::getDocString | ( | ) | const |
Get the documentation string of the Option.
Definition at line 232 of file Option.cpp.
References p_docString.
Referenced by printValueOfOpt(), and printValueOfOptConst().
std::string& Option::getLongName | ( | ) |
std::string & Option::getLongName | ( | ) | const |
Get the long name of the Option.
Definition at line 182 of file Option.cpp.
References p_longName.
Referenced by printValueOfOpt(), and printValueOfOptConst().
void Option::getPossibleOption | ( | std::string & | possibleOption, |
const std::string & | cursorOption | ||
) | const |
Get the possible options for the bash completion.
[out] | possibleOption | : possible options for the bash completion |
cursorOption | : option of the cursor which is currently completed |
Definition at line 280 of file Option.cpp.
References isSameBegining(), p_isParsed, p_longName, and p_shortName.
void Option::getPossibleValue | ( | std::string & | possibleValue, |
const std::string & | cursorOption | ||
) | const |
Complete the possible values of the Option.
[out] | possibleValue | : possible value of the option |
cursorOption | : option of the cursor which is currently completed |
Definition at line 308 of file Option.cpp.
References OptionValue::bashCompletionValue(), and p_value.
Referenced by OptionParser::completeOptionValue().
std::string& Option::getShortName | ( | ) |
std::string & Option::getShortName | ( | ) | const |
Get the short name of the Option.
Definition at line 192 of file Option.cpp.
References p_shortName.
Referenced by printValueOfOpt(), and printValueOfOptConst().
OptionValue& Option::getValue | ( | ) |
OptionValue & Option::getValue | ( | ) | const |
Get the value of the Option.
Definition at line 202 of file Option.cpp.
References p_value.
Referenced by OptionMode::getValue(), printValueOfOpt(), and printValueOfOptConst().
|
private |
Initialisation function of the class Option.
Definition at line 327 of file Option.cpp.
References p_firstPartParsedOption, p_isAllowEmpty, p_isParsed, and p_isRequired.
Referenced by Option().
bool& Option::isAllowEmpty | ( | ) |
bool & Option::isAllowEmpty | ( | ) | const |
Get if the option value can be empty.
Definition at line 222 of file Option.cpp.
References p_isAllowEmpty.
Referenced by printValueOfOpt(), printValueOfOptConst(), and setIsAllowEmpty().
bool& Option::isParsed | ( | ) |
bool & Option::isParsed | ( | ) | const |
Say if the Option has been parsed or not.
Definition at line 242 of file Option.cpp.
References p_isParsed.
Referenced by OptionMode::getValue(), and setIsParsed().
bool& Option::isRequired | ( | ) |
bool & Option::isRequired | ( | ) | const |
Get if the option is required.
Definition at line 212 of file Option.cpp.
References p_isRequired.
Referenced by OptionMode::getValue(), printValueOfOpt(), printValueOfOptConst(), and setIsRequired().
Definition of equal operator of Option.
other | : class to copy |
Definition at line 74 of file Option.cpp.
References copyOption().
bool Option::parseOption | ( | ArgParser & | parser | ) |
Parse the current option with the given parser.
[out] | parser | : parser of the given arguments to the program |
Definition at line 83 of file Option.cpp.
References p_longName, p_shortName, parsePartOption(), and createReleaseCurl::parser.
|
private |
Parse the given option with the parser.
[out] | parser | : parser to be used |
prefix | : option prefix (- or – or nothing) | |
optionName | : name of hte option to be parsed |
Definition at line 340 of file Option.cpp.
References OptionValue::addValue(), checkAlreadyParsed(), OptionValue::getType(), isSameBegining(), OptionType::NONE, p_firstPartParsedOption, p_isAllowEmpty, p_isParsed, p_value, createReleaseCurl::parser, and OptionType::STRING.
Referenced by parseOption().
void Option::print | ( | const std::string & | indentation = "" | ) | const |
Print an option.
indentation | : indentation to print the option |
Definition at line 106 of file Option.cpp.
References convertOptionTypeToString(), OptionValue::getDefaultValue(), OptionValue::getPossibleValue(), OptionValue::getType(), OptionType::NONE, p_docString, p_isAllowEmpty, p_isRequired, p_longName, p_shortName, p_value, printVecString(), and createReleaseCurl::type.
void Option::setDocString | ( | const std::string & | docString | ) |
Set the documentation string of the Option.
docString | : documentation string of the Option |
Definition at line 167 of file Option.cpp.
References p_docString.
Referenced by testOption().
void Option::setIsAllowEmpty | ( | bool | isAllowEmpty | ) |
Say if the option can be empty or not.
isAllowEmpty | : true if the option can be empty, false otherwise |
Definition at line 177 of file Option.cpp.
References isAllowEmpty(), and p_isAllowEmpty.
Referenced by OptionParser::addOption(), and testOption().
void Option::setIsParsed | ( | bool | isParsed | ) |
Say if the Option has been parsed or not.
isParsed | : true if the Option has been parsed, false if not |
Definition at line 172 of file Option.cpp.
References isParsed(), and p_isParsed.
Referenced by testOption().
void Option::setIsRequired | ( | bool | isRequired | ) |
Set if the option is required.
isRequired | : true if the Option is required, false if it is optionnal |
Definition at line 162 of file Option.cpp.
References isRequired(), and p_isRequired.
Referenced by testOption().
void Option::setLongName | ( | const std::string & | longName | ) |
Set the long name of the option.
longName | : long name of the option |
Definition at line 147 of file Option.cpp.
References p_longName.
Referenced by testOption().
void Option::setShortName | ( | const std::string & | shortName | ) |
Set the short name of the option.
shortName | : short name of the option |
Definition at line 152 of file Option.cpp.
References p_shortName.
Referenced by testOption().
void Option::setValue | ( | const OptionValue & | value | ) |
Set the value of the option.
value | : value name of the option |
Definition at line 157 of file Option.cpp.
References p_value.
Referenced by testOption().
|
private |
Documentation string of the current Option.
Definition at line 82 of file Option.h.
Referenced by copyOption(), getDocString(), print(), and setDocString().
|
private |
First paet of parsed option (needed for bash completion)
Definition at line 86 of file Option.h.
Referenced by copyOption(), initialisationOption(), and parsePartOption().
|
private |
The option can be empty and can have a value.
Definition at line 88 of file Option.h.
Referenced by copyOption(), initialisationOption(), isAllowEmpty(), parsePartOption(), print(), and setIsAllowEmpty().
|
private |
Say if the option has been parsed or not.
Definition at line 84 of file Option.h.
Referenced by checkAlreadyParsed(), checkArgument(), copyOption(), getPossibleOption(), initialisationOption(), isParsed(), parsePartOption(), and setIsParsed().
|
private |
True if the option is required, false if it is optionnal.
Definition at line 80 of file Option.h.
Referenced by checkArgument(), copyOption(), initialisationOption(), isRequired(), print(), and setIsRequired().
|
private |
Long name of the Option.
Definition at line 74 of file Option.h.
Referenced by checkArgument(), copyOption(), getLongName(), getPossibleOption(), parseOption(), print(), and setLongName().
|
private |
Short name of the Option.
Definition at line 76 of file Option.h.
Referenced by checkArgument(), copyOption(), getPossibleOption(), getShortName(), parseOption(), print(), and setShortName().
|
private |
Value of the Option.
Definition at line 78 of file Option.h.
Referenced by checkArgument(), copyOption(), getPossibleValue(), getValue(), parsePartOption(), print(), and setValue().