source: nscp/include/program_options_ex.hpp @ 858ecc1

0.4.00.4.10.4.2
Last change on this file since 858ecc1 was 1e0bbec, checked in by Michael Medin <michael@…>, 3 years ago

Semi-working NRPEClient (debian boost is broken so need to recompile it myself before I can finish it off) But "should almost work" (from CLI)

  • Property mode set to 100644
File size: 1.5 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        static boost::program_options::basic_parsed_options<charT> parse_command_line(int argc, charT* argv[], const boost::program_options::options_description& desc,
10                int style = 0, boost::function1<std::pair<std::string, std::string>, const std::string&> ext = boost::program_options::ext_parser())
11        {
12                return basic_command_line_parser_ex<charT>(argc, argv).options(desc).style(style).extra_parser(ext).run();
13        }
14
15        template<class charTx, class Iterator>
16                std::vector<std::basic_string<charTx> >
17                        make_vector(Iterator i, Iterator e)
18                {
19                        std::vector<std::basic_string<charTx> > result;
20                        // Some compilers don't have templated constructor for
21                        // vector, so we can't create vector from (argv+1, argv+argc) range
22                        //if (a0 != NULL)
23                        //      result.push_back(a0);
24                        for(; i != e; ++i)
25                                result.push_back(*i);
26                        return result;           
27                }
28                basic_command_line_parser_ex(int argc, charT* argv[])
29                        : boost::program_options::basic_command_line_parser<charT>(
30                        make_vector<charT, charT**>(argv, argv+argc)
31                        )
32                {}
33                /*
34#ifdef _WIN32
35                basic_command_line_parser_ex(const std::wstring args)
36                        : boost::program_options::basic_command_line_parser<charT>(boost::program_options::split_winmain(args))
37                {}
38#endif
39                */
40
41};
Note: See TracBrowser for help on using the repository browser.