FACT++  1.0
int main ( int  argc,
const char **  argv 
)
Examples:
argv.cc.

Definition at line 139 of file argv.cc.

References Configuration::Get(), Configuration::Has(), Configuration::HasHelp(), Configuration::HasPrint(), Configuration::Parse(), and SetupConfiguration().

140 {
141  int opt;
142 
143  Configuration conf(argv[0]);
144  SetupConfiguration(conf, opt);
145 
146  po::variables_map vm;
147  try
148  {
149  vm = conf.Parse(argc, argv);
150  }
151  catch (std::exception &e)
152  {
153 #if BOOST_VERSION > 104000
154  po::multiple_occurrences *MO = dynamic_cast<po::multiple_occurrences*>(&e);
155  if (MO)
156  cout << "Error: " << e.what() << " of '" << MO->get_option_name() << "' option." << endl;
157  else
158 #endif
159  cout << "Error: " << e.what() << endl;
160  cout << endl;
161 
162  return -1;
163  }
164 
165  if (conf.HasHelp() || conf.HasPrint())
166  return -1;
167 
168  cout << "------------------------------" << endl;
169 
170  cout << "Program " << argv[0] << " started successfully." << endl;
171 
172  cout << conf.Has("switch") << " " << conf.Get<bool>("switch") << endl;
173  cout << conf.Has("bool") << " " << conf.Get<bool>("bool") << endl;
174 
175  return 0;
176 /*
177  if (vm.count("compression"))
178  cout << "Compression level was set to " << vm["compression"].as<int>() << ".\n";
179  else
180  cout << "Compression level was not set.\n";
181 
182 
183  cout << "Test default is always: " << vm["test-def"].as<int>() << "\n";
184  cout << "Optimization level is " << vm["optimization"].as<int>() << "\n";
185  //cout << "Int2: " << vm["Int2"].as<int>() << "\n";
186 
187  cout << conf.GetString("unregistered") << endl;
188  cout << conf.GetString("Section1.unregistered") << endl;
189  cout << conf.Has("Section2.unregistered") << endl;
190  cout << conf.GetString("Section2.Section3.unregistered") << endl;
191  cout << "test-db: " << conf.GetString("test-db") << endl;
192 
193 
194  if (vm.count("include-path"))
195  {
196  vector<string> v = vm["include-path"].as< vector<string> >();
197  for (vector<string>::iterator s=v.begin(); s<v.end(); s++)
198  cout << "Incl P: " << *s << endl;
199  }
200 
201  if (vm.count("input-file"))
202  {
203  vector<string> v = vm["input-file"].as< vector<string> >();
204  for (vector<string>::iterator s=v.begin(); s<v.end(); s++)
205  cout << "Incl F: " << *s << endl;
206  }
207 
208  if (vm.count("output-file"))
209  {
210  vector<string> v = vm["output-file"].as< vector<string> >();
211  for (vector<string>::iterator s=v.begin(); s<v.end(); s++)
212  cout << "Out: " << *s << endl;
213  }
214 
215  if (vm.count("test-file"))
216  {
217  vector<string> v = vm["test-file"].as< vector<string> >();
218  for (vector<string>::iterator s=v.begin(); s<v.end(); s++)
219  cout << "Testf: " << *s << endl;
220  }
221 
222  cout << "Linux: " << conf.Get<string>("linux") << endl;
223 
224  if (vm.count("path"))
225  cout << "Path: " << vm["path"].as<string>() << endl;
226  if (vm.count("file1"))
227  cout << "File1: " << vm["file1"].as<string>() << endl;
228  if (vm.count("int1"))
229  cout << "Int1: " << vm["int1"].as<int>() << endl;
230  if (vm.count("float1"))
231  cout << "Float1: " << vm["float1"].as<float>() << endl;
232 
233  if (vm.count("test"))
234  {
235  vector<string> v = vm["test"].as< vector<string> >();
236  for (vector<string>::iterator s=v.begin(); s<v.end(); s++)
237  cout << "Test: " << *s << endl;
238  }*/
239 }
void SetupConfiguration(Configuration &conf, int &opt)
Definition: argv.cc:15
Commandline parsing, resource file parsing and database access.
Definition: Configuration.h:9

+ Here is the call graph for this function: