PhoenixInkscape  2.0.0
Generate multiple png files with svg inkscape files
main.cpp
Go to the documentation of this file.
1 
2 /***************************************
3  Auteur : Pierre Aubert
4  Mail : pierre.aubert@lapp.in2p3.fr
5  Licence : CeCILL-C
6 ****************************************/
7 
8 #include "phoenix_assert.h"
9 #include "phoenix_check.h"
10 #include "OptionParser.h"
11 
13 
16  OptionParser parser(true, "1.0.0");
17  parser.setExampleLongOption("test_plib_optionparser_int --value=42");
18  parser.setExampleShortOption("test_plib_optionparser_int -n 42");
19  parser.addOption("value", "n", OptionType::INT, true, "Required option");
20  return parser;
21 }
22 
24 
26 void printConstParser(const OptionParser & parser){
27  const OptionMode & noneMode = parser.getMode("NotExistingMode");
28  noneMode.print();
29  const OptionMode & defaultMode = parser.getDefaultMode();
30  defaultMode.print();
31 }
32 
33 int main(int argc, char** argv){
35  parser.parseArgument(argc, argv);
36  parser.print();
37  printConstParser(parser);
38  const OptionMode & noneMode = parser.getMode("NotExistingMode");
39  noneMode.print();
40 
41  OptionParser parser2(parser), parser3;
42  parser2.print();
43  parser3 = parser;
44  parser3.print();
45 
46  const OptionMode & defaultMode = parser.getDefaultMode();
47  int value(0);
48  defaultMode.getValue(value, "value");
49 // std::cout << "value = '" << value << "'" << std::endl;
50 
51  phoenix_assert(phoenix_check("Value", value, 42));
52  return 0;
53 }
54 
55 
Describe a mode in the program arguments.
Definition: OptionMode.h:13
void print() const
Print the option of the mode.
Definition: OptionMode.cpp:112
bool getValue(T &value, const PString &optionName) const
Get the value of the option.
Parse the options passed to a program.
Definition: OptionParser.h:15
void parseArgument(int argc, char **argv)
Parse the arguments passed to the program.
void addOption(const PString &longOption, const PString &shortOption, OptionType::OptionType optionType, bool isRequired, const PString &docString)
Add an option in the OptionParser.
const OptionMode & getMode(const PString &name) const
Get mode by name.
void setExampleShortOption(const PString &example)
Set the example usage of the program.
void print() const
Print all the options.
void setExampleLongOption(const PString &example)
Set the example usage of the program.
const OptionMode & getDefaultMode() const
Get default mode.
#define phoenix_assert(isOk)
bool phoenix_check(const std::string &testName, const std::string &val, const std::string &reference)
Check two string.
int main(int argc, char **argv)
Definition: main.cpp:290
OptionParser createOptionParser()
Create the OptionParser of this program.
Definition: main.cpp:17
void printConstParser(const OptionParser &parser)
Do the same thing but with a const parser.
Definition: main.cpp:32