FACT++  1.0
void SetupConfiguration ( Configuration conf,
int &  opt 
)

Main Doxygen/Autotools integration example program.

Parameters
confNumber of command line options.
optThe command line options.
Returns
The exit status.
Examples:
argv.cc.

Definition at line 15 of file argv.cc.

References Configuration::AddEnv(), Configuration::AddOptionsCommandline(), Configuration::AddOptionsConfigfile(), Configuration::AddOptionsDatabase(), Configuration::AddOptionsEnvironment(), po_switch(), and Configuration::SetArgumentPositions().

Referenced by main().

16 {
17  /*
18  // Default in case the option was not specified
19  typed_value* default_value(const T& v)
20  typed_value* default_value(const T& v, const std::string& textual)
21 
22  // Default value in case the option was given
23  // forces -o to become -o5
24  // forces --opt to become --opt=3
25  typed_value* implicit_value(const T &v)
26  typed_value* implicit_value(const T &v, const std::string& textual)
27 
28  // notifier function when the final value is determined
29  typed_value* notifier(function1<void, const T&> f)
30 
32  typed_value* composing()
33 
34  // Specifies that the value can span multiple tokens.
35  typed_value* multitoken()
36  typed_value* zero_tokens()
37 
38  // Specifies that the value must occur.
39  typed_value* required()
40  */
41 
42  // To merge the options from several parsers (e.g. comand_line and
43  // config file) use po_strings()->composing()
44  /*
45  po::options_description generic("Generic options");
46  generic.add_options()
47  ("help-config", "Print available configuration file options.")
48  ("help-env", "Print available environment variables.")
49  ("help", "Print available commandline options.")
50  ("print-unknown", "Print unrecognized options.")
51  ("config", po_string("config.txt"), "Set configuration file name.")
52  ;
53 
54 
55  // Declare the supported options.
56  po::options_description generic("Generaic options");
57  generic.add_options()
58 // ("testreq", po_int()->required(), "set compression level (madatory)")
59  ("default", po_string("my_default"), "set compression level")
60  ("unknown", po_int(1), "set compression level")
61  ("U", po_int(2)->implicit_value(1), "set compression level")
62  ;
63  */
64  // Declare a group of options that will be
65  // allowed both on command line and in
66  // config file
67  po::options_description config("Configuration");
68  config.add_options()
69  ("compression", var<int>(), "set compression level")
70  ("optimization", var<int>(10, &opt), "optimization level")
71  ("test-def", var<int>(42), "optimization level")
72  ("include-path,I", vars<string>()/*->composing()*/, "include path")
73  ("test,T", vars<string>()/*->composing()*/, "include path")
74  ("file1", vars<string>(), "include path")
75  ("int1", var<int>(), "include path")
76  ("Int2", var<int>(), "include path")
77  ("Int1", var<int>(), "include path")
78  ("test-db", var<string>("database"), "include path")
79  ("float1", var<double>(), "include path")
80 // (",A", po_float(), "include path")
81  ("radec", po::value<vector<double>>(), "include path")
82  ("switch", po_switch(), "include path")
83  ("bool", var<bool>()->implicit_value(true), "include path")
84  ;
85 
86  // !!! Option which are "shorted" must be placed last.
87  // Can this be switched off?
88 
89  po::options_description sections("Sections");
90  config.add_options()
91  ("unregistered", var<string>(), "include path")
92  ("Section1.unregistered", var<string>(), "include path")
93 // ("Section2*", po_string(), "include path")
94  // The latter accepts all options starting with Section2.
95  ;
96 
97  // Hidden options, will be allowed both on command line and
98  // in config file, but will not be shown to the user.
99  po::options_description hidden("Hidden options");
100  hidden.add_options()
101  ("input-file", vars<string>(), "input file")
102  ("output-file", vars<string>(), "output file")
103  ("test-file", vars<string>(), "test file")
104  ;
105 
106  po::options_description env("Environment options");
107  env.add_options()
108  ("linux", var<string>(), "LINUX env")
109  ("path", var<string>(), "PATH env")
110  ("dns", var<string>(), "DIM_DNS_SERVER env")
111  ;
112 
113  conf.AddEnv("linux", "LINUX");
114  conf.AddEnv("path", "PATH");
115  conf.AddEnv("dns", "DIM_DNS_SERVER");
116 
117  // define translation from position to name
118  po::positional_options_description p;
119  p.add("output-file", 2); // The first 2 positional options is output-file
120  p.add("test-file", 3); // The next three positional options is output-file
121  p.add("input-file", -1); // All others go to...
122 
123  conf.AddOptionsCommandline(config);
124  conf.AddOptionsCommandline(sections);
125  conf.AddOptionsCommandline(hidden, false);
126 
127  conf.AddOptionsConfigfile(config);
128  conf.AddOptionsConfigfile(sections);
129  conf.AddOptionsConfigfile(hidden, false);
130 
131  conf.AddOptionsEnvironment(env);
132 
133  conf.AddOptionsDatabase(config);
134 
135  conf.SetArgumentPositions(p);
136 }
void AddOptionsEnvironment(const po::options_description &env, bool visible=true)
void AddOptionsConfigfile(const po::options_description &cf, bool visible=true)
po::typed_value< bool > * po_switch()
void AddEnv(const std::string &conf, const std::string &env)
void SetArgumentPositions(const po::positional_options_description &desc)
void AddOptionsDatabase(const po::options_description &db, bool visible=true)
void AddOptionsCommandline(const po::options_description &cl, bool visible=true)
double p
Definition: palObs.c:169

+ Here is the call graph for this function:

+ Here is the caller graph for this function: