source: nscp/include/program_options_ex.hpp @ f029bc2

0.4.00.4.10.4.2
Last change on this file since f029bc2 was dcd90b2, checked in by Michael Medin <michael@…>, 3 years ago

Added back openssl now builds (and presumably the NRPEClient works with it haven't tested but will do after I get the NRPEListener up and running...)

  • Property mode set to 100644
File size: 1.4 KB
Line 
1#pragma once
2
3#include <boost/program_options.hpp>
4#include <boost/function/function1.hpp>
5
6template<class charT>
7class basic_command_line_parser_ex : public boost::program_options::basic_command_line_parser<charT> {
8public:
9        /*
10        static boost::program_options::basic_parsed_options<charT> parse_command_line(int argc, charT* argv[], const boost::program_options::options_description& desc,
11                int style = 0, boost::function1<std::pair<std::string, std::string>, const std::string&> ext = boost::program_options::ext_parser())
12        {
13                return basic_command_line_parser_ex<charT>(argc, argv).options(desc).style(style).extra_parser(ext).run();
14        }
15        */
16
17        template<class charTx, class Iterator>
18                std::vector<std::basic_string<charTx> >
19                        make_vector(Iterator i, Iterator e)
20                {
21                        std::vector<std::basic_string<charTx> > result;
22                        // Some compilers don't have templated constructor for
23                        // vector, so we can't create vector from (argv+1, argv+argc) range
24                        //if (a0 != NULL)
25                        //      result.push_back(a0);
26                        for(; i != e; ++i)
27                                result.push_back(*i);
28                        return result;           
29                }
30                basic_command_line_parser_ex(int argc, charT* argv[])
31                        : boost::program_options::basic_command_line_parser<charT>(
32                        make_vector<charT, charT**>(argv, argv+argc)
33                        )
34                {}
35                basic_command_line_parser_ex(std::vector<charT> v)
36                        : boost::program_options::basic_command_line_parser<charT>(v)
37                {}
38
39};
Note: See TracBrowser for help on using the repository browser.