[program-options] Problem with paths that have spaces
Hi all,
I'm trying to use program-options to specify a filesystem path object
under Boost 1.35.0. The following code works fine when the path
specified on the command line has no spaces in it. But when it does
have spaces, I get an error.
--snip--
#include <iostream>
#include <sstream>
#include
Allen Cronce wrote:
fs::path inPath;
po::options_description desc("Allowed options"); desc.add_options() ("in,i", po::valuefs::path(&inPath), "Input file or directory <pathname>")
If I call the above with the following parameters, it works:
--in "my_file"
Input path = "my_file"
But if I call it with a path that has a space in it, I get an error:
--in "my file"
Exception error: in option 'in': invalid option value 'my file'
I know that I can work around the problem by loading the path into an interim string first, then use the string to initialize a path object. But unless I'm missing something, I would have thought that iteroperability between boost.program-options and boost.filesystem should be more seamless. It seems very common to want to load options into path objects.
I am not aware of boost.program_options has any special support for
boost::filesystem::path, which suggests that processing of this option
goes via generic path:
template
participants (2)
-
Allen Cronce
-
Vladimir Prus