PhoenixMock  1.8.7
Tools to split/merge/print mock used in Phoenix
Option.h
Go to the documentation of this file.
1 /***************************************
2  Auteur : Pierre Aubert
3  Mail : pierre.aubert@lapp.in2p3.fr
4  Licence : CeCILL-C
5 ****************************************/
6 
7 #ifndef __POPTION_H__
8 #define __POPTION_H__
9 
10 #include "ArgParser.h"
11 #include "OptionValue.h"
12 
13 class Option{
14  public:
15  Option(const std::string & longName = "", const std::string & shortName = "", const std::string & docString = "");
16  Option(const std::string & longName, const std::string & shortName, const OptionValue & value, const std::string & docString = "");
17  Option(const std::string & longName, const std::string & shortName, const OptionValue & value, bool isRequired, const std::string & docString = "");
18  Option(const std::string & longName, const std::string & shortName, bool isRequired, const std::string & docString = "");
19 
20  Option(const Option & other);
21  virtual ~Option();
22  Option & operator = (const Option & other);
23 
25 
26  void print(const std::string & indentation = "") const;
27 
28  void setLongName(const std::string & longName);
29  void setShortName(const std::string & shortName);
30  void setValue(const OptionValue & value);
31  void setIsRequired(bool isRequired);
32  void setDocString(const std::string & docString);
33  void setIsParsed(bool isParsed);
34  void setIsAllowEmpty(bool isAllowEmpty);
35 
36  const std::string & getLongName() const;
37  std::string & getLongName();
38 
39  const std::string & getShortName() const;
40  std::string & getShortName();
41 
42  const OptionValue & getValue() const;
44 
45  bool isRequired() const;
46  bool & isRequired();
47 
48  bool isAllowEmpty() const;
49  bool & isAllowEmpty();
50 
51  const std::string & getDocString() const;
52  std::string & getDocString();
53 
54  bool isParsed() const;
55  bool & isParsed();
56  bool checkArgument() const;
57 
58  void getPossibleOption(std::string & possibleOption, const std::string & cursorOption) const;
59  void getPossibleValue(std::string & possibleValue, const std::string & cursorOption) const;
60 
61  protected:
62  void copyOption(const Option & other);
63 
64  private:
65  void initialisationOption();
66  bool parsePartOption(ArgParser & parser, const std::string & prefix, const std::string & optionName);
67  void checkAlreadyParsed(const std::string & longOption);
68 
70  std::string p_longName;
72  std::string p_shortName;
78  std::string p_docString;
80  bool p_isParsed;
85 };
86 
88 typedef std::vector<Option> VecOption;
89 
90 #include "Option_impl.h"
91 
92 #endif
93 
Option::p_value
OptionValue p_value
Value of the Option.
Definition: Option.h:78
Option::isRequired
bool isRequired() const
Get if the option is required.
Definition: Option.cpp:212
Option::setIsParsed
void setIsParsed(bool isParsed)
Say if the Option has been parsed or not.
Definition: Option.cpp:172
Option::p_shortName
std::string p_shortName
Short name of the Option.
Definition: Option.h:76
Option::setDocString
void setDocString(const std::string &docString)
Set the documentation string of the Option.
Definition: Option.cpp:167
Option::p_longName
std::string p_longName
Long name of the Option.
Definition: Option.h:74
Option::isParsed
bool isParsed() const
Say if the Option has been parsed or not.
Definition: Option.cpp:242
Option_impl.h
Option::p_isRequired
bool p_isRequired
True if the option is required, false if it is optionnal.
Definition: Option.h:80
Option::checkAlreadyParsed
void checkAlreadyParsed(const std::string &longOption)
Check if the Option has been already parsed.
Definition: Option.cpp:408
Option::checkArgument
bool checkArgument() const
Check the argument of the parser.
Definition: Option.cpp:252
VecOption
std::vector< Option > VecOption
Vector of option.
Definition: Option.h:88
Option::getValue
const OptionValue & getValue() const
Get the value of the Option.
Definition: Option.cpp:202
Option::p_isAllowEmpty
bool p_isAllowEmpty
The option can be empty and can have a value.
Definition: Option.h:88
Option::isAllowEmpty
bool isAllowEmpty() const
Get if the option value can be empty.
Definition: Option.cpp:222
Option::print
void print(const std::string &indentation="") const
Print an option.
Definition: Option.cpp:106
Option::setLongName
void setLongName(const std::string &longName)
Set the long name of the option.
Definition: Option.cpp:147
Option::p_firstPartParsedOption
std::string p_firstPartParsedOption
First paet of parsed option (needed for bash completion)
Definition: Option.h:86
OptionValue.h
Option::operator=
Option & operator=(const Option &other)
Definition of equal operator of Option.
Definition: Option.cpp:74
Option::setValue
void setValue(const OptionValue &value)
Set the value of the option.
Definition: Option.cpp:157
Option::copyOption
void copyOption(const Option &other)
Copy function of Option.
Definition: Option.cpp:315
Option::~Option
virtual ~Option()
Destructeur of Option.
Definition: Option.cpp:66
Option::getShortName
const std::string & getShortName() const
Get the short name of the Option.
Definition: Option.cpp:192
ArgParser.h
Option::getPossibleValue
void getPossibleValue(std::string &possibleValue, const std::string &cursorOption) const
Complete the possible values of the Option.
Definition: Option.cpp:308
Option::parseOption
bool parseOption(ArgParser &parser)
Parse the current option with the given parser.
Definition: Option.cpp:83
createReleaseCurl.parser
parser
Definition: createReleaseCurl.py:123
Option::p_isParsed
bool p_isParsed
Say if the option has been parsed or not.
Definition: Option.h:84
Option::p_docString
std::string p_docString
Documentation string of the current Option.
Definition: Option.h:82
Option::setShortName
void setShortName(const std::string &shortName)
Set the short name of the option.
Definition: Option.cpp:152
Option::getLongName
const std::string & getLongName() const
Get the long name of the Option.
Definition: Option.cpp:182
Option
Definition: Option.h:13
Option::Option
Option(const std::string &longName="", const std::string &shortName="", const std::string &docString="")
Default constructor of Option.
Definition: Option.cpp:15
Option::parsePartOption
bool parsePartOption(ArgParser &parser, const std::string &prefix, const std::string &optionName)
Parse the given option with the parser.
Definition: Option.cpp:340
Option::setIsAllowEmpty
void setIsAllowEmpty(bool isAllowEmpty)
Say if the option can be empty or not.
Definition: Option.cpp:177
OptionValue
Describe the value of an option passed to a program.
Definition: OptionValue.h:20
Option::initialisationOption
void initialisationOption()
Initialisation function of the class Option.
Definition: Option.cpp:327
Option::setIsRequired
void setIsRequired(bool isRequired)
Set if the option is required.
Definition: Option.cpp:162
Option::getPossibleOption
void getPossibleOption(std::string &possibleOption, const std::string &cursorOption) const
Get the possible options for the bash completion.
Definition: Option.cpp:280
Option::getDocString
const std::string & getDocString() const
Get the documentation string of the Option.
Definition: Option.cpp:232
ArgParser
Parse the list of arguments passed to a program.
Definition: ArgParser.h:16