OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
MetaParser.hpp
1/*
2 * MetaParser.hpp
3 *
4 * Created on: Mar 3, 2019
5 * Author: i-bird
6 */
7
8#ifndef METAPARSER_HPP_
9#define METAPARSER_HPP_
10
11#include <algorithm>
12#include <iostream>
13#include <iterator>
14#include <string>
15#include <vector>
16
17#include <boost/bind/bind.hpp>
18#include <boost/program_options.hpp>
19#include <boost/tokenizer.hpp>
20
21typedef boost::program_options::options_description MetaParser_options;
22namespace MetaParser_def = boost::program_options;
23
25{
26 boost::program_options::options_description desc;
27
28 boost::program_options::variables_map vm;
29
30public:
31
32 explicit MetaParser(boost::program_options::options_description & desc)
33 :desc(desc)
34 {
35 }
36
42 bool parse(std::string & opts)
43 {
44 std::istringstream iss(opts);
45
46 // Parse mocked up input.
47 boost::program_options::store(boost::program_options::parse_config_file(iss,desc), vm);
48 boost::program_options::notify(vm);
49
50 return true;
51 }
52
61 template<typename T>
62 bool getOption(std::string opt,T & value)
63 {
64 if (vm.count(opt))
65 {
66 value = vm[opt].as<T>();
67 return true;
68 }
69
70 return false;
71 }
72
77 void clear()
78 {
79 vm.clear();
80 }
81};
82
83
84#endif /* METAPARSER_HPP_ */
bool getOption(std::string opt, T &value)
Return the option opt in value.
void clear()
clear everything you parsed so far
bool parse(std::string &opts)
Parse the string of options.