boost.program_options - passing string or vector<string>

Hello I want to use boost.program_options to parse commands for my program (console application) What I want to do is to be able to pass std::vector<std::string> of arguments or std::string (line) to parse_command_line(ac, av, desc); instead of char *argv, int argc. How is that possible? I've been looking at basic_command_line_parser class but couldnt figure out how it would be possible to do that, since converting string/vector of strings to array of char pointers would be really stupid. Many thanks for help Aljaz

AMDG Aljaz wrote:
Hello
I want to use boost.program_options to parse commands for my program (console application)
What I want to do is to be able to pass std::vector<std::string> of arguments or std::string (line) to parse_command_line(ac, av, desc); instead of char *argv, int argc.
How is that possible?
I've been looking at basic_command_line_parser class but couldnt figure out how it would be possible to do that, since converting string/vector of strings to array of char pointers would be really stupid.
basic_command_line_parser has a constructor that takes a std::vector<std::string> http://www.boost.org/doc/libs/1_35_0/doc/html/boost/program_options/basic_co... In Christ, Steven Watanabe

I managed to figure that out. However, I get stuck here because this wont compile: using namespace boost::program_options; variables_map vm; basic_command_line_parser<char> clp(vector_list); clp.options(desc); store(clp, vm); What should I do instead? Many thanks for help! "Steven Watanabe" <watanabesj@gmail.com> wrote in message news:487D264A.2080804@providere-consulting.com...
AMDG
Aljaz wrote:
Hello
I want to use boost.program_options to parse commands for my program (console application)
What I want to do is to be able to pass std::vector<std::string> of arguments or std::string (line) to parse_command_line(ac, av, desc); instead of char *argv, int argc.
How is that possible?
I've been looking at basic_command_line_parser class but couldnt figure out how it would be possible to do that, since converting string/vector of strings to array of char pointers would be really stupid.
basic_command_line_parser has a constructor that takes a std::vector<std::string>
http://www.boost.org/doc/libs/1_35_0/doc/html/boost/program_options/basic_co...
In Christ, Steven Watanabe

AMDG Aljaz wrote:
using namespace boost::program_options; variables_map vm; basic_command_line_parser<char> clp(vector_list); clp.options(desc); store(clp, vm);
What should I do instead?
store(clp.run(), vm) In Christ, Steven Watanabe

Thanks a lot for help! That solves the problem. "Steven Watanabe" <watanabesj@gmail.com> wrote in message news:487D4ABB.6010007@providere-consulting.com...
AMDG
Aljaz wrote:
using namespace boost::program_options; variables_map vm; basic_command_line_parser<char> clp(vector_list); clp.options(desc); store(clp, vm);
What should I do instead?
store(clp.run(), vm)
In Christ, Steven Watanabe
participants (2)
-
Aljaz
-
Steven Watanabe