summaryrefslogtreecommitdiffhomepage
path: root/programopts.h
blob: 442d3b0d905187c8676a89f68b36939791dc6e7a (plain)
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
// Parse command line options of program

#pragma once

#include <functional>
#include <map>
#include <memory>
#include <string>
#include <vector>

#define EXPORT __attribute__((visibility("default")))

namespace Reichwein {

class EXPORT ProgramOpts
{
public:
 // Processing of options in lambdas: each do return true iff parameter was consumed
 ProgramOpts(int argc, char* argv[], std::map<std::string, std::function<bool(const std::string&)>>& option_prefixes);
 ~ProgramOpts();
 void process(); // must be called to run functions per option, given to ctor
 std::string programName();
 std::vector<std::string> nonOptionArguments();
private:
 struct impl;
 std::unique_ptr<impl> m_pimpl;
};

} // namespace