1 | #include <iostream> |
---|
2 | |
---|
3 | #include <boost/program_options.hpp> |
---|
4 | namespace po = boost::program_options; |
---|
5 | int main(int ac, char** av) |
---|
6 | { |
---|
7 | using namespace std; |
---|
8 | //locale::global(locale("")); |
---|
9 | // Declare the supported options. |
---|
10 | po::options_description desc("Allowed options"); |
---|
11 | desc.add_options() |
---|
12 | ("help", "produce help message") |
---|
13 | ("compression", po::value<int>(), "set compression level") |
---|
14 | ; |
---|
15 | |
---|
16 | po::variables_map vm; |
---|
17 | po::store(po::parse_command_line(ac, av, desc), vm); |
---|
18 | po::notify(vm); |
---|
19 | |
---|
20 | if (vm.count("help")) { |
---|
21 | cout << desc << "\n"; |
---|
22 | return 1; |
---|
23 | } |
---|
24 | |
---|
25 | if (vm.count("compression")) { |
---|
26 | cout << "Compression level was set to " |
---|
27 | << vm["compression"].as<int>() << ".\n"; |
---|
28 | } else { |
---|
29 | cout << "Compression level was not set.\n"; |
---|
30 | } |
---|
31 | } |
---|