Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r68395 - branches/quickbook-filenames/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2011-01-23 11:47:32


Author: danieljames
Date: 2011-01-23 11:47:23 EST (Sun, 23 Jan 2011)
New Revision: 68395
URL: http://svn.boost.org/trac/boost/changeset/68395

Log:
Replace input_path with manual path conversion.
Text files modified:
   branches/quickbook-filenames/tools/quickbook/src/input_path.cpp | 30 ++++++++++--------------------
   branches/quickbook-filenames/tools/quickbook/src/input_path.hpp | 32 ++++++++------------------------
   branches/quickbook-filenames/tools/quickbook/src/quickbook.cpp | 15 ++++++++-------
   3 files changed, 26 insertions(+), 51 deletions(-)

Modified: branches/quickbook-filenames/tools/quickbook/src/input_path.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/input_path.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/input_path.cpp 2011-01-23 11:47:23 EST (Sun, 23 Jan 2011)
@@ -13,16 +13,10 @@
 
 // Everything but cygwin
 
-namespace quickbook { namespace detail
-{
- void validate(boost::any& v,
- const std::vector<std::string>& 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 @@
 #include <windows.h>
 #include <sys/cygwin.h>
 
-namespace quickbook { namespace detail
-{
- void validate(boost::any& v,
- const std::vector<std::string>& 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 @@
         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 @@
                 boost::program_options::validation_error::invalid_option_value);
         }
 
- v = input_path(result.get());
+ return fs::path(result.get());
     }
 }}
 

Modified: branches/quickbook-filenames/tools/quickbook/src/input_path.hpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/input_path.hpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/input_path.hpp 2011-01-23 11:47:23 EST (Sun, 23 Jan 2011)
@@ -10,35 +10,19 @@
 #define BOOST_QUICKBOOK_DETAIL_INPUT_PATH_HPP
 
 #include <boost/filesystem/v3/path.hpp>
-#include <vector>
-#include <boost/any.hpp>
 #include <string>
 
 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<std::string>&,
- 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

Modified: branches/quickbook-filenames/tools/quickbook/src/quickbook.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/quickbook.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/quickbook.cpp 2011-01-23 11:47:23 EST (Sun, 23 Jan 2011)
@@ -186,11 +186,11 @@
             ("no-pretty-print", "disable XML pretty printing")
             ("indent", value<int>(), "indent spaces")
             ("linewidth", value<int>(), "line width")
- ("input-file", value<quickbook::detail::input_path>(), "input file")
- ("output-file", value<quickbook::detail::input_path>(), "output file")
+ ("input-file", value<fs::path::string_type>(), "input file")
+ ("output-file", value<fs::path::string_type>(), "output file")
             ("debug", "debug mode (for developers)")
             ("ms-errors", "use Microsoft Visual Studio style error & warn message format")
- ("include-path,I", value< std::vector<quickbook::detail::input_path> >(), "include path")
+ ("include-path,I", value< std::vector<fs::path::string_type> >(), "include path")
             ("define,D", value< std::vector<std::string> >(), "define macro")
         ;
 
@@ -255,9 +255,9 @@
         
         if (vm.count("include-path"))
         {
- std::vector<quickbook::detail::input_path> paths
+ std::vector<fs::path::string_type> paths
                 = vm["include-path"].as<
- std::vector<quickbook::detail::input_path> >();
+ std::vector<fs::path::string_type> >();
             quickbook::include_path
                 = std::vector<fs::path>(paths.begin(), paths.end());
         }
@@ -270,13 +270,14 @@
 
         if (vm.count("input-file"))
         {
+ // TODO: Convert cygwin paths
             fs::path filein(
- vm["input-file"].as<quickbook::detail::input_path>());
+ vm["input-file"].as<fs::path::string_type>());
             fs::path fileout;
 
             if (vm.count("output-file"))
             {
- fileout = vm["output-file"].as<quickbook::detail::input_path>();
+ fileout = vm["output-file"].as<fs::path::string_type>();
             }
             else
             {


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk