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.addMode("class");
18  parser.addOption("name", "n", OptionType::FILENAME, true, "base name of the file to be created");
19  std::string templateDef("");
20  parser.addOption("template", "t", templateDef, "template definition of the class (ex: 'typename T' or 'typename T, typename U', etc");
21  parser.closeMode();
22 
23  parser.addMode("source");
24  parser.addOption("name", "n", OptionType::STRING, true, "base name of the file to be created");
25  parser.closeMode();
26  return parser;
27 }
28 
30 
32 void printConstParser(const OptionParser & parser){
33  const OptionMode & noneMode = parser.getMode("class");
34  noneMode.print();
35  const OptionMode & defaultMode = parser.getDefaultMode();
36  defaultMode.print();
37 }
38 
39 int main(int argc, char** argv){
41  parser.print();
42  parser.parseArgument(argc, argv);
43  printConstParser(parser);
44  const OptionMode & classMode = parser.getMode("class");
45  const OptionMode & sourceMode = parser.getMode("source");
46 
47  if(classMode.isParsed()){ //We are using the class mode
48  std::cout << "Class mode activated" << std::endl;
49  std::string className("");
50  classMode.getValue(className, "name");
51  std::cout << "name of the class to be generated : '" << className << "'" << std::endl;
52 
53  phoenix_assert(phoenix_check("Check class name", className, "classname"));
54  }
55 
56  if(sourceMode.isParsed()){ //We are using the source mode
57  std::cout << "Source mode activated" << std::endl;
58  std::string fileName("");
59  sourceMode.getValue(fileName, "name");
60  std::cout << "name of the header/source files to be generated : " << fileName << "'" << std::endl;
61 
62  phoenix_assert(phoenix_check("Check file name", fileName, "sourcename"));
63  }
64  return 0;
65 }
66 
67 
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 isParsed() const
Say if the OptionMode contains option which are parsed.
Definition: OptionMode.cpp:195
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 closeMode()
Close the current mode and go back to be default one.
void addMode(const PString &modeName)
Add a mode in the option.
void print() const
Print all the options.
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