You use the variables_map
to check whether options were specified. If you added an option called "file"
and your variables_map
was called vm
:
if(vm.count("myoption")) { ... } // Returns 0 if myoption not specified. 1 or more if it was.
Once you've used add_options
to add some options, you can access them like so, assuming that you've setup a variables_map
named vm
:
vm["myoption"].as<int>() // Will return an int, assuming your option is an int
vm["myoption"].as<std::string>() // Will return an std::string, assuming your option is an int
In your case, you want to convert one of the specified options to a sequence of integers. You can do that like so:
vm["myoption"].as< std::vector<int> >()
Which will return a vector containing the 3 integers, which you can index and use just like any normal vector. To see if there are specifically 3, just use the size()
vector member function.
The boost tutorial on this is located here.