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 |
|
|
|
12 |
|
|
///Create the OptionParser of this program |
13 |
|
|
/** @return OptionParser of this program |
14 |
|
|
*/ |
15 |
|
2 |
OptionParser createOptionParser(){ |
16 |
✓✓ |
4 |
OptionParser parser(true, "1.0.0"); |
17 |
✓✓ |
2 |
parser.addMode("class"); |
18 |
✓✓✓✓
|
2 |
parser.addOption("name", "n", OptionType::FILENAME, true, "base name of the file to be created"); |
19 |
✓ |
4 |
std::string templateDef(""); |
20 |
✓✓✓✓ ✓ |
2 |
parser.addOption("template", "t", templateDef, "template definition of the class (ex: 'typename T' or 'typename T, typename U', etc"); |
21 |
✓ |
2 |
parser.closeMode(); |
22 |
|
|
|
23 |
✓✓ |
2 |
parser.addMode("source"); |
24 |
✓✓✓✓
|
2 |
parser.addOption("name", "n", OptionType::STRING, true, "base name of the file to be created"); |
25 |
✓ |
2 |
parser.closeMode(); |
26 |
|
4 |
return parser; |
27 |
|
|
} |
28 |
|
|
|
29 |
|
|
///Do the same thing but with a const parser |
30 |
|
|
/** @param parser : OptionParser to be used |
31 |
|
|
*/ |
32 |
|
2 |
void printConstParser(const OptionParser & parser){ |
33 |
✓✓ |
2 |
const OptionMode & noneMode = parser.getMode("class"); |
34 |
|
2 |
noneMode.print(); |
35 |
|
2 |
const OptionMode & defaultMode = parser.getDefaultMode(); |
36 |
|
2 |
defaultMode.print(); |
37 |
|
2 |
} |
38 |
|
|
|
39 |
|
2 |
int main(int argc, char** argv){ |
40 |
✓ |
2 |
OptionParser parser = createOptionParser(); |
41 |
✓ |
2 |
parser.print(); |
42 |
✓ |
2 |
parser.parseArgument(argc, argv); |
43 |
✓ |
2 |
printConstParser(parser); |
44 |
✓✓ |
2 |
const OptionMode & classMode = parser.getMode("class"); |
45 |
✓✓ |
2 |
const OptionMode & sourceMode = parser.getMode("source"); |
46 |
|
|
|
47 |
✓✓✓ |
2 |
if(classMode.isParsed()){ //We are using the class mode |
48 |
✓✓ |
1 |
std::cout << "Class mode activated" << std::endl; |
49 |
✓ |
1 |
std::string className(""); |
50 |
✓✓ |
1 |
classMode.getValue(className, "name"); |
51 |
✓✓✓✓
|
1 |
std::cout << "name of the class to be generated : '" << className << "'" << std::endl; |
52 |
|
|
|
53 |
✓✓✓✓ ✓✓✓ |
1 |
phoenix_assert(phoenix_check("Check class name", className, "classname")); |
54 |
|
|
} |
55 |
|
|
|
56 |
✓✓✓ |
2 |
if(sourceMode.isParsed()){ //We are using the source mode |
57 |
✓✓ |
1 |
std::cout << "Source mode activated" << std::endl; |
58 |
✓ |
1 |
std::string fileName(""); |
59 |
✓✓ |
1 |
sourceMode.getValue(fileName, "name"); |
60 |
✓✓✓✓
|
1 |
std::cout << "name of the header/source files to be generated : " << fileName << "'" << std::endl; |
61 |
|
|
|
62 |
✓✓✓✓ ✓✓✓ |
1 |
phoenix_assert(phoenix_check("Check file name", fileName, "sourcename")); |
63 |
|
|
} |
64 |
|
2 |
return 0; |
65 |
|
|
} |
66 |
|
|
|
67 |
|
|
|