forked from hxmhuang/OpenArray_Dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArgumentParser.hpp
More file actions
61 lines (48 loc) · 1.24 KB
/
Copy pathArgumentParser.hpp
File metadata and controls
61 lines (48 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef SUNWAY
#ifndef __ARGUMENTPARSER_HPP__
#define __ARGUMENTPARSER_HPP__
#include <boost/program_options.hpp>
#include <boost/format.hpp>
#include <string>
#include <iostream>
#include <boost/tokenizer.hpp>
namespace po = boost::program_options;
class ArgumentParser{
private:
po::options_description m_ops_desc;
po::variables_map m_vm;
std::string cmdline;
public:
template<class T>
T get_option(const char* key){
return m_vm[key].as<T>();
}
template<class T>
void add_option(const char* key,
T val,
const char* desc){
m_ops_desc.add_options()
(key, po::value<T>()->default_value(val), desc);
}
const po::option_description* find(char* key);
void set_cmdline(char* cmd);
void parse_cmdline(int argc, char** argv);
void parse_cmdline();
void parse_file(char* file);
/// @brief Tokenize a string.
/// The tokens will be separated by each non-quoted
/// space or equal character.
/// Empty tokens are removed.
///
/// @param input The string to tokenize.
///
/// @return Vector of tokens.
std::vector<std::string> tokenize(const std::string& input);
void show();
static ArgumentParser* global(){
static ArgumentParser ap;
return ≈
}
};
#endif
#endif