Ticket #6695: auto_link_test.cpp

File auto_link_test.cpp, 1.2 KB (added by Ben Craig <ben.craig@…>, 11 years ago)
Line 
1/*
2 Copyright 2010-2010
3 National Instruments Corporation.
4 All rights reserved.
5*/
6
7#include <boost/program_options/options_description.hpp>
8#include <boost/program_options/parsers.hpp>
9#include <boost/program_options/variables_map.hpp>
10#include <boost/system/system_error.hpp>
11#include <iostream>
12#include <vector>
13
14int main()
15{
16 boost::system::error_code temp;
17 boost::system::system_error err(temp);
18 std::cout<<err.what()<<"\n";
19
20 namespace po = boost::program_options;
21 // Declare the supported options.
22 po::options_description desc("Allowed options");
23 desc.add_options()
24 ("help", "produce help message")
25 ("compression", po::value<int>(), "set compression level")
26 ;
27
28 po::variables_map vm;
29 char *argv[]={"ThisProg","compression=1"};
30 po::store(po::parse_command_line(1, argv, desc), vm);
31 po::notify(vm);
32
33 if (vm.count("help")) {
34 std::cout << desc << "\n";
35 return 1;
36 }
37
38 if (vm.count("compression")) {
39 std::cout << "Compression level was set to "
40 << vm["compression"].as<int>()
41 << ".\n";
42 } else {
43 std::cout << "Compression level was not set.\n";
44 }
45
46 return 0;
47}