PhoenixMock  1.8.7
Tools to split/merge/print mock used in Phoenix
OptionMode.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 __POPTIONMODE_H__
8 #define __POPTIONMODE_H__
9 
10 #include "Option.h"
11 
13 class OptionMode{
14  public:
15  OptionMode(const std::string & name = "");
16  OptionMode(const OptionMode & other);
17 
18  virtual ~OptionMode();
19  OptionMode & operator = (const OptionMode & other);
20 
22  bool parseOption(ArgParser & parser, Option *& partialOption);
23 
24  void print() const;
25 
26  void setName(const std::string & name);
27  void setVecOption(const VecOption & vecOption);
28  void addOption(const Option & option);
29  void clearOption();
30  void setEnableHelpOption(bool b);
31  void setProgramVersion(const std::string & programVersion);
32 
33  const std::string & getName() const;
34  std::string & getName();
35 
36  const VecOption & getVecOption() const;
38 
39  bool checkArgument() const;
40  bool isCurrentlyParsed() const;
41  bool isParsed() const;
42 
43  template<typename T>
44  bool getValue(T & value, const std::string & optionName) const;
45 
46  bool isOptionExist(const std::string & optionName) const;
47 
48  void getPossibleOption(std::string & possibleOption, const std::string & cursorOption) const;
49  void getPossibleMode(std::string & possibleOption, const std::string & cursorOption) const;
50 
51  protected:
52  void copyOptionMode(const OptionMode & other);
53  private:
55  bool getOption(Option & option, const std::string & optionName) const;
56  void iterGetPossibleOption(std::string & possibleOption, const std::string & cursorOption) const;
57 
59  std::string p_name;
65  bool p_isParsed;
69  std::string p_programVersion;
70 };
71 
73 typedef std::vector<OptionMode> VecMode;
74 
75 #include "OptionMode_impl.h"
76 
77 #endif
78 
Option.h
OptionMode::p_isCurrentlyParsed
bool p_isCurrentlyParsed
True if the OptionMode is currently parsed but not totally.
Definition: OptionMode.h:67
OptionMode::getVecOption
const VecOption & getVecOption() const
Get the vector of options of the OptionMode.
Definition: OptionMode.cpp:156
OptionMode::checkArgument
bool checkArgument() const
Check the argument of the parser.
Definition: OptionMode.cpp:166
OptionMode::iterGetPossibleOption
void iterGetPossibleOption(std::string &possibleOption, const std::string &cursorOption) const
Iterates over the possible options of the current mode.
Definition: OptionMode.cpp:273
OptionMode::p_name
std::string p_name
name of the OptionMode
Definition: OptionMode.h:63
OptionMode::~OptionMode
virtual ~OptionMode()
Destructeur of OptionMode.
Definition: OptionMode.cpp:29
OptionMode::p_isParsed
bool p_isParsed
Say if the mode contains options which are parsed.
Definition: OptionMode.h:69
OptionMode::getValue
bool getValue(T &value, const std::string &optionName) const
Get the value of the option.
Definition: OptionMode_impl.h:18
VecOption
std::vector< Option > VecOption
Vector of option.
Definition: Option.h:88
OptionMode::p_vecOption
VecOption p_vecOption
Vector of all the options of the OptionMode.
Definition: OptionMode.h:65
OptionMode::getName
const std::string & getName() const
Get the name of the OptionMode.
Definition: OptionMode.cpp:146
OptionMode::setProgramVersion
void setProgramVersion(const std::string &programVersion)
Set the program version.
Definition: OptionMode.cpp:141
OptionMode::setVecOption
void setVecOption(const VecOption &vecOption)
Set the vector of options of the OptionMode.
Definition: OptionMode.cpp:123
OptionMode::addOption
void addOption(const Option &option)
Add an option into the OptionMode.
Definition: OptionMode.cpp:128
OptionMode::OptionMode
OptionMode(const std::string &name="")
Default constructeur of OptionMode.
Definition: OptionMode.cpp:15
OptionMode::parseOption
bool parseOption(ArgParser &parser)
Parse the options in the current OptionMode.
Definition: OptionMode.cpp:47
OptionMode::getOption
bool getOption(Option &option, const std::string &optionName) const
Get the option with its name.
Definition: OptionMode.cpp:257
OptionMode::print
void print() const
Print the option of the mode.
Definition: OptionMode.cpp:104
OptionMode::setName
void setName(const std::string &name)
Set the name of the OptionMode.
Definition: OptionMode.cpp:118
OptionMode::getPossibleOption
void getPossibleOption(std::string &possibleOption, const std::string &cursorOption) const
Get the possible options for the bash completion.
Definition: OptionMode.cpp:210
OptionMode_impl.h
createReleaseCurl.parser
parser
Definition: createReleaseCurl.py:123
OptionMode::isCurrentlyParsed
bool isCurrentlyParsed() const
Say if the OptionMode is currently parsed (but maybe not totally)
Definition: OptionMode.cpp:180
VecMode
std::vector< OptionMode > VecMode
Vector of mode.
Definition: OptionMode.h:73
OptionMode::isParsed
bool isParsed() const
Say if the OptionMode contains option which are parsed.
Definition: OptionMode.cpp:187
OptionMode::initialisationOptionMode
void initialisationOptionMode()
Initialisation function of the class OptionMode.
Definition: OptionMode.cpp:246
Option
Definition: Option.h:13
OptionMode::p_programVersion
std::string p_programVersion
Program version to be printed on –version or -v option.
Definition: OptionMode.h:73
OptionMode::p_enableHelpOption
bool p_enableHelpOption
True to enable automatically the printing of the help option when the program is called with –help or...
Definition: OptionMode.h:71
OptionMode::setEnableHelpOption
void setEnableHelpOption(bool b)
Set the attribtue which enables help option.
Definition: OptionMode.cpp:136
OptionMode::clearOption
void clearOption()
Remove all the options of the OptionMode.
Definition: OptionMode.cpp:131
OptionMode::isOptionExist
bool isOptionExist(const std::string &optionName) const
Say if the given option has been passed to the program.
Definition: OptionMode.cpp:195
ArgParser
Parse the list of arguments passed to a program.
Definition: ArgParser.h:16
OptionMode::operator=
OptionMode & operator=(const OptionMode &other)
Definition of equal operator of OptionMode.
Definition: OptionMode.cpp:37
OptionMode::copyOptionMode
void copyOptionMode(const OptionMode &other)
Copy function of OptionMode.
Definition: OptionMode.cpp:236
OptionMode
Describe a mode in the program arguments.
Definition: OptionMode.h:13
OptionMode::getPossibleMode
void getPossibleMode(std::string &possibleOption, const std::string &cursorOption) const
Get the possible mode.
Definition: OptionMode.cpp:225