PhoenixPresentation  2.0.0
Set of cmake function to automate presentation generation
main.cpp File Reference
#include "phoenix_assert.h"
#include "phoenix_check.h"
#include "OptionParser.h"
+ Include dependency graph for main.cpp:

Go to the source code of this file.

Functions

OptionParser createOptionParser ()
 Create the OptionParser of this program. More...
 
int main (int argc, char **argv)
 
void printConstParser (const OptionParser &parser)
 Do the same thing but with a const parser. More...
 

Function Documentation

◆ createOptionParser()

OptionParser createOptionParser ( )

Create the OptionParser of this program.

Returns
OptionParser of this program

Definition at line 15 of file main.cpp.

15  {
16  OptionParser parser(true, "1.0.0");
17  parser.setExampleLongOption("test_option_parser_vecpossiblevalue --project=test");
18  parser.setExampleShortOption("test_option_parser_vecpossiblevalue -p test");
19 
20  PVecString vecPossibleValue;
21  vecPossibleValue.push_back("test");
22  vecPossibleValue.push_back("othervalue");
23  vecPossibleValue.push_back("lastpossibility");
24 
25  parser.addOption("project", "p", OptionType::STRING, true, false, vecPossibleValue, "Required option");
26  return parser;
27 }
std::vector< PString > PVecString
Definition: PString.h:96
Parse the options passed to a program.
Definition: OptionParser.h:15

References OptionParser::addOption(), OptionParser::setExampleLongOption(), OptionParser::setExampleShortOption(), and OptionType::STRING.

+ Here is the call graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 39 of file main.cpp.

39  {
41  parser.parseArgument(argc, argv);
42  parser.print();
43 
44  const OptionMode & defaultMode = parser.getDefaultMode();
45  PString selectedProject("");
46  defaultMode.getValue(selectedProject, "project");
47 // std::cout << "selectedProject = '" << selectedProject << "'" << std::endl;
48 
49  phoenix_assert(phoenix_check("project", selectedProject, "test"));
50  return 0;
51 }
OptionParser createOptionParser()
Create the OptionParser of this program.
Definition: main.cpp:17
Describe a mode in the program arguments.
Definition: OptionMode.h:13
bool getValue(T &value, const PString &optionName) const
Get the value of the option.
void parseArgument(int argc, char **argv)
Parse the arguments passed to the program.
void print() const
Print all the options.
const OptionMode & getDefaultMode() const
Get default mode.
Extends the std::string.
Definition: PString.h:16
#define phoenix_assert(isOk)
bool phoenix_check(const std::string &testName, const std::string &val, const std::string &reference)
Check two string.

References createOptionParser(), OptionParser::getDefaultMode(), OptionMode::getValue(), OptionParser::parseArgument(), phoenix_assert, phoenix_check(), and OptionParser::print().

+ Here is the call graph for this function:

◆ printConstParser()

void printConstParser ( const OptionParser parser)

Do the same thing but with a const parser.

Parameters
parser: OptionParser to be used

Definition at line 32 of file main.cpp.

32  {
33  const OptionMode & noneMode = parser.getMode("NotExistingMode");
34  noneMode.print();
35  const OptionMode & defaultMode = parser.getDefaultMode();
36  defaultMode.print();
37 }
void print() const
Print the option of the mode.
Definition: OptionMode.cpp:112
const OptionMode & getMode(const PString &name) const
Get mode by name.

References OptionParser::getDefaultMode(), OptionParser::getMode(), and OptionMode::print().

+ Here is the call graph for this function: