R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BProgramOptions.cxx
Go to the documentation of this file.
1#include "R3BProgramOptions.h"
2#include <boost/program_options/parsers.hpp>
3#include <boost/program_options/variables_map.hpp>
4#include <exception>
5#include <iostream>
6#include <ostream>
7#include <stdexcept>
8
9namespace R3B
10{
11 auto ProgramOptions::verify(int argc, char** argv) -> bool
12 {
13 try
14 {
15 po::store(po::command_line_parser(argc, argv).positional(pos_desc_).options(desc_).run(), varMap_);
16 po::notify(varMap_);
17
18 if (varMap_.count("help") == 1)
19 {
20 std::cout << get_desc_ref() << "\n";
21 return false;
22 }
23
24 for (auto& registrie : registries_)
25 {
26 registrie.second->retrieve(varMap_);
27 }
28 }
29 catch (const std::runtime_error& err)
30 {
31 std::cerr << "An exception occurs: " << err.what() << "\n";
32 return false;
33 }
34 catch (const std::exception& err)
35 {
36 // std::cerr << "exception occurs: " << boost::diagnostic_information(err) << std::endl;
37 std::cerr << "An exception occurs: " << err.what() << "\n";
38 return false;
39 }
40 catch (...)
41 {
42 std::cerr << "An unrecognizable exception occurs!" << "\n";
43 return false;
44 }
45 return true;
46 }
47} // namespace R3B
auto get_desc_ref() -> auto &
po::options_description desc_
auto verify(int argc, char **argv) -> bool
po::positional_options_description pos_desc_
std::unordered_map< std::string, OptionConcept * > registries_
po::variables_map varMap_