PhoenixPresentation  2.0.0
Set of cmake function to automate presentation generation
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 
14 class Option{
15  public:
16  Option();
17  Option(const PString & longName, const PString & shortName, const PString & docString);
18  Option(const PString & longName, const PString & shortName, const OptionValue & value, const PString & docString);
19  Option(const PString & longName, const PString & shortName, const OptionValue & value, bool isRequired, const PString & docString);
20  Option(const PString & longName, const PString & shortName, bool isRequired, const PString & docString);
21 
22  Option(const Option & other);
23  virtual ~Option();
24  Option & operator = (const Option & other);
25 
26  bool parseOption(ArgParser & parser);
27 
28  void print(const PString & indentation = "") const;
29 
30  void setLongName(const PString & longName);
31  void setShortName(const PString & shortName);
32  void setValue(const OptionValue & value);
33  void setIsRequired(bool isRequired);
34  void setDocString(const PString & docString);
35  void setIsParsed(bool isParsed);
36  void setIsAllowEmpty(bool isAllowEmpty);
37 
38  const PString & getLongName() const;
39  PString & getLongName();
40 
41  const PString & getShortName() const;
43 
44  const OptionValue & getValue() const;
46 
47  bool isRequired() const;
48  bool & isRequired();
49 
50  bool isAllowEmpty() const;
51  bool & isAllowEmpty();
52 
53  const PString & getDocString() const;
55 
56  bool isParsed() const;
57  bool & isParsed();
58  bool checkArgument() const;
59 
60  void getPossibleOption(PString & possibleOption, const PString & cursorOption) const;
61  void getPossibleValue(PString & possibleValue, const PString & cursorOption) const;
62 
63  protected:
64  void copyOption(const Option & other);
65 
66  private:
67  void initialisationOption();
68  bool parsePartOption(ArgParser & parser, const PString & prefix, const PString & optionName);
69  void checkAlreadyParsed(const PString & longOption);
70 
82  bool p_isParsed;
87 };
88 
90 typedef std::vector<Option> VecOption;
91 
92 #endif
93 
std::vector< Option > VecOption
Vector of option.
Definition: Option.h:90
Parse the list of arguments passed to a program.
Definition: ArgParser.h:13
Describe the value of an option passed to a program.
Definition: OptionValue.h:16
Describes an option passed to a program.
Definition: Option.h:14
virtual ~Option()
Destructeur of Option.
Definition: Option.cpp:73
void setIsParsed(bool isParsed)
Say if the Option has been parsed or not.
Definition: Option.cpp:179
void setIsAllowEmpty(bool isAllowEmpty)
Say if the option can be empty or not.
Definition: Option.cpp:184
bool p_isAllowEmpty
The option can be empty and can have a value.
Definition: Option.h:86
const PString & getLongName() const
Get the long name of the Option.
Definition: Option.cpp:189
void checkAlreadyParsed(const PString &longOption)
Check if the Option has been already parsed.
Definition: Option.cpp:414
bool parsePartOption(ArgParser &parser, const PString &prefix, const PString &optionName)
Parse the given option with the parser.
Definition: Option.cpp:346
void getPossibleOption(PString &possibleOption, const PString &cursorOption) const
Get the possible options for the bash completion.
Definition: Option.cpp:287
void initialisationOption()
Initialisation function of the class Option.
Definition: Option.cpp:334
void setLongName(const PString &longName)
Set the long name of the option.
Definition: Option.cpp:154
bool parseOption(ArgParser &parser)
Parse the current option with the given parser.
Definition: Option.cpp:90
PString p_shortName
Short name of the Option.
Definition: Option.h:74
const OptionValue & getValue() const
Get the value of the Option.
Definition: Option.cpp:209
bool isParsed() const
Say if the Option has been parsed or not.
Definition: Option.cpp:249
void copyOption(const Option &other)
Copy function of Option.
Definition: Option.cpp:322
bool p_isRequired
True if the option is required, false if it is optionnal.
Definition: Option.h:78
OptionValue p_value
Value of the Option.
Definition: Option.h:76
const PString & getDocString() const
Get the documentation string of the Option.
Definition: Option.cpp:239
void setShortName(const PString &shortName)
Set the short name of the option.
Definition: Option.cpp:159
bool checkArgument() const
Check the argument of the parser.
Definition: Option.cpp:259
bool p_isParsed
Say if the option has been parsed or not.
Definition: Option.h:82
PString p_firstPartParsedOption
First paet of parsed option (needed for bash completion)
Definition: Option.h:84
void setIsRequired(bool isRequired)
Set if the option is required.
Definition: Option.cpp:169
PString p_longName
Long name of the Option.
Definition: Option.h:72
const PString & getShortName() const
Get the short name of the Option.
Definition: Option.cpp:199
void setValue(const OptionValue &value)
Set the value of the option.
Definition: Option.cpp:164
bool isAllowEmpty() const
Get if the option value can be empty.
Definition: Option.cpp:229
Option & operator=(const Option &other)
Definition of equal operator of Option.
Definition: Option.cpp:81
void getPossibleValue(PString &possibleValue, const PString &cursorOption) const
Complete the possible values of the Option.
Definition: Option.cpp:315
PString p_docString
Documentation string of the current Option.
Definition: Option.h:80
void print(const PString &indentation="") const
Print an option.
Definition: Option.cpp:113
void setDocString(const PString &docString)
Set the documentation string of the Option.
Definition: Option.cpp:174
Option()
Default constructor of Option.
Definition: Option.cpp:11
bool isRequired() const
Get if the option is required.
Definition: Option.cpp:219
Extends the std::string.
Definition: PString.h:16