Please excuse any ignorance, I'm new to c++.
I'm trying to use boost program_options and commandline parser for my command line program. The program uses getline to get some user inputted command. I want to parse that so it can be passed to boost but I can't seem to get the types right. I'm still learning pointers and all that jazz properly but I'm having a tough time.
Here's the code so you can get a idea of what I'm trying to do:
namespace po = boost::program_options;
int _tmain(int argc, _TCHAR* argv[])
{
std::string input;
_TCHAR* parsedInput[20];
while (std::cin) {
std::getline(std::cin, input);
boost::split(parsedInput, input, boost::is_any_of(" "), boost::token_compress_on);
po::options_description desc("allowed options");
desc.add_options()
("help", "produce help message")
("compression", po::value<int>(), "set compression level")
;
po::variables_map vm;
po::store(po::parse_command_line(5, parsedInput, desc), vm);
po::notify(vm);
if (vm.count("help"))
std::cout << desc << "\n";
}
return 0;
}
po::store(po::parse_command_line(5, parsedInput, desc), vm);
the 5 is arbitrary just while I'm trying to make this work.
With the code I'm not entirely sure what my issue is but I think it actually has something to do with splitting the input, this is the current error message error C2078: too many initializers
.
I originally split the input into a vector of strings, which got me past that error but then I had problems with po::parse_command_line(5, parsedInput, desc)
taking the wrong type, I assume it can't take a vector of strings. After looking at the documentation that does seem to be the case.
If anyone could give me a hand or point me in the right direction I would be grateful. Thank you.