2 #include <boost/program_options.hpp>
4 /*----------------------------------------------------------------------*\
6 \*---------------------------------------------------------------------*/
11 namespace po
= boost::program_options
;
13 using po::options_description
;
15 using po::variables_map
;
17 using po::parse_command_line
;
20 /*--------------------------------------*\
22 \*-------------------------------------*/
24 bool useOption(int argc
, char** argv
);
26 /*--------------------------------------*\
28 \*-------------------------------------*/
30 static bool use(double a
, double b
);
31 static bool help(const options_description
& description
);
33 /*----------------------------------------------------------------------*\
35 \*---------------------------------------------------------------------*/
37 /*--------------------------------------*\
39 \*-------------------------------------*/
42 * http://www.boost.org/doc/libs/1_55_0/doc/html/program_options/tutorial.html#idp163291912
44 bool useOption(int argc
, char** argv
)
49 options_description
description("Allowed options");
50 description
.add_options()
51 ("help", "produce help message")
52 ("a", value
<double>(&a
)->default_value(3.14), "explain here what is a ... Example: --a=2.22")
53 ("b", value
<double>(&b
)->default_value(1.11), "explain here what is b ... Example: --a=3.33");
55 variables_map mapVariableValue
;
56 store(parse_command_line(argc
, argv
, description
), mapVariableValue
);
57 notify(mapVariableValue
);
59 if (mapVariableValue
.count("help"))
61 return help(description
);
69 /*--------------------------------------*\
71 \*-------------------------------------*/
73 bool use(double a
, double b
)
75 cout
<< "[Use Option] : " << endl
<< endl
;
77 cout
<< "a= " << a
<< endl
;
78 cout
<< "b= " << b
<< endl
;
84 bool help(const options_description
& description
)
86 cout
<< "[Help] " << endl
<<endl
;
88 cout
<< description
<< endl
<<endl
;
90 cout
<< "Write help here ..."<<endl
<<endl
;
95 /*----------------------------------------------------------------------*\
97 \*---------------------------------------------------------------------*/