diff --git a/src/input_path.cpp b/src/input_path.cpp index 287eaae..4e0f4e1 100644 --- a/src/input_path.cpp +++ b/src/input_path.cpp @@ -13,16 +13,10 @@ // Everything but cygwin -namespace quickbook { namespace detail -{ - void validate(boost::any& v, - const std::vector& values, - input_path*, int) - { - std::string path - = boost::program_options::validators::get_single_string(values); - - v = input_path(path); +namespace quickbook { +namespace detail { + fs::path native_to_path(fs::path::string_type const& path) { + return fs::path(path); } }} @@ -36,15 +30,10 @@ namespace quickbook { namespace detail #include #include -namespace quickbook { namespace detail -{ - void validate(boost::any& v, - const std::vector& values, - input_path*, int) - { - std::string path - = boost::program_options::validators::get_single_string(values); - +namespace quickbook { +namespace detail { + fs::path native_to_path(fs::path::string_type const& path) { + // TODO: Use unicode version #if defined(BOOST_WINDOWS_PATH) cygwin_conv_path_t flags = CCP_POSIX_TO_WIN_A | CCP_RELATIVE; #elif defined(BOOST_POSIX_PATH) @@ -56,6 +45,7 @@ namespace quickbook { namespace detail ssize_t size = cygwin_conv_path(flags, path.c_str(), NULL, 0); if (size < 0) { + // TODO: Better error. throw boost::program_options::validation_error( boost::program_options::validation_error::invalid_option_value); } @@ -67,7 +57,7 @@ namespace quickbook { namespace detail boost::program_options::validation_error::invalid_option_value); } - v = input_path(result.get()); + return fs::path(result.get()); } }} diff --git a/src/input_path.hpp b/src/input_path.hpp index 3eeb2f4..51f29c5 100644 --- a/src/input_path.hpp +++ b/src/input_path.hpp @@ -10,35 +10,19 @@ #define BOOST_QUICKBOOK_DETAIL_INPUT_PATH_HPP #include -#include -#include #include namespace quickbook { namespace fs = boost::filesystem; -namespace detail -{ - // Use this class with Boost.Program Options to convert paths to the format - // the Boost.Filesystem expects. This is needed on cygwin to convert cygwin - // paths to windows paths (or vice versa, depending on how filesystem is set - // up). - // - // Note that we don't want to convert paths in quickbook files, as they - // should be platform independent, and aren't necessarily relative to the - // current directory. - - class input_path { - std::string path_; - public: - explicit input_path(char const* c) : path_(c) {} - explicit input_path(std::string const& c) : path_(c) {} - operator boost::filesystem::path() const { return boost::filesystem::path(path_); } - - friend void validate(boost::any&, const std::vector&, - input_path*, int); - }; -}} + namespace detail + { + // Convert paths from the command line, or other native sources to + // our internal path type. Mainly used to convert cygwin paths, but + // might be useful elsewhere. + fs::path native_to_path(fs::path::string_type const&); + } +} #endif diff --git a/src/quickbook.cpp b/src/quickbook.cpp index e7346e2..1f300b1 100644 --- a/src/quickbook.cpp +++ b/src/quickbook.cpp @@ -186,11 +186,11 @@ main(int argc, char* argv[]) ("no-pretty-print", "disable XML pretty printing") ("indent", value(), "indent spaces") ("linewidth", value(), "line width") - ("input-file", value(), "input file") - ("output-file", value(), "output file") + ("input-file", value(), "input file") + ("output-file", value(), "output file") ("debug", "debug mode (for developers)") ("ms-errors", "use Microsoft Visual Studio style error & warn message format") - ("include-path,I", value< std::vector >(), "include path") + ("include-path,I", value< std::vector >(), "include path") ("define,D", value< std::vector >(), "define macro") ; @@ -255,9 +255,9 @@ main(int argc, char* argv[]) if (vm.count("include-path")) { - std::vector paths + std::vector paths = vm["include-path"].as< - std::vector >(); + std::vector >(); quickbook::include_path = std::vector(paths.begin(), paths.end()); } @@ -270,13 +270,14 @@ main(int argc, char* argv[]) if (vm.count("input-file")) { + // TODO: Convert cygwin paths fs::path filein( - vm["input-file"].as()); + vm["input-file"].as()); fs::path fileout; if (vm.count("output-file")) { - fileout = vm["output-file"].as(); + fileout = vm["output-file"].as(); } else {