|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r50513 - in trunk/tools/quickbook: . detail
From: daniel_james_at_[hidden]
Date: 2009-01-08 07:01:50
Author: danieljames
Date: 2009-01-08 07:01:50 EST (Thu, 08 Jan 2009)
New Revision: 50513
URL: http://svn.boost.org/trac/boost/changeset/50513
Log:
Support both windows and cygwin paths in cygwin quickbook.
Added:
trunk/tools/quickbook/detail/input_path.cpp (contents, props changed)
trunk/tools/quickbook/detail/input_path.hpp (contents, props changed)
Text files modified:
trunk/tools/quickbook/Jamfile.v2 | 1 +
trunk/tools/quickbook/detail/quickbook.cpp | 18 ++++++++++++------
2 files changed, 13 insertions(+), 6 deletions(-)
Modified: trunk/tools/quickbook/Jamfile.v2
==============================================================================
--- trunk/tools/quickbook/Jamfile.v2 (original)
+++ trunk/tools/quickbook/Jamfile.v2 2009-01-08 07:01:50 EST (Thu, 08 Jan 2009)
@@ -14,6 +14,7 @@
detail/actions.cpp
detail/actions_class.cpp
detail/utils.cpp
+ detail/input_path.cpp
detail/post_process.cpp
detail/collector.cpp
detail/template_stack.cpp
Added: trunk/tools/quickbook/detail/input_path.cpp
==============================================================================
--- (empty file)
+++ trunk/tools/quickbook/detail/input_path.cpp 2009-01-08 07:01:50 EST (Thu, 08 Jan 2009)
@@ -0,0 +1,42 @@
+/*=============================================================================
+ Copyright (c) 2009 Daniel James
+
+ Use, modification and distribution is subject to the Boost Software
+ License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+=============================================================================*/
+
+#include <boost/program_options.hpp>
+#include "./input_path.hpp"
+
+#if defined(__cygwin__) || defined(__CYGWIN__)
+#include <boost/filesystem/config.hpp>
+#include <windows.h>
+#include <sys/cygwin.h>
+#endif
+
+
+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);
+
+#if !(defined(__cygwin__) || defined(__CYGWIN__))
+ v = input_path(path);
+#elif defined(BOOST_WINDOWS_PATH)
+ char result[MAX_PATH + 1];
+ cygwin_conv_to_win32_path(path.c_str(), result);
+ v = input_path(result);
+#elif defined(BOOST_POSIX_PATH)
+ char result[MAX_PATH + 1];
+ cygwin_conv_to_posix_path(path.c_str(), result);
+ v = input_path(result);
+#else
+# error "Bosot filesystem path type doesn't seem to be set."
+#endif
+ }
+}}
\ No newline at end of file
Added: trunk/tools/quickbook/detail/input_path.hpp
==============================================================================
--- (empty file)
+++ trunk/tools/quickbook/detail/input_path.hpp 2009-01-08 07:01:50 EST (Thu, 08 Jan 2009)
@@ -0,0 +1,39 @@
+/*=============================================================================
+ Copyright (c) 2009 Daniel James
+
+ Use, modification and distribution is subject to the Boost Software
+ License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+=============================================================================*/
+
+#if !defined(BOOST_QUICKBOOK_DETAIL_INPUT_PATH_HPP)
+#define BOOST_QUICKBOOK_DETAIL_INPUT_PATH_HPP
+
+#include <vector>
+#include <boost/any.hpp>
+#include <string>
+
+namespace quickbook { 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 std::string() const { return path_; }
+
+ friend void validate(boost::any&, const std::vector<std::string>&,
+ input_path*, int);
+ };
+}}
+
+#endif
Modified: trunk/tools/quickbook/detail/quickbook.cpp
==============================================================================
--- trunk/tools/quickbook/detail/quickbook.cpp (original)
+++ trunk/tools/quickbook/detail/quickbook.cpp 2009-01-08 07:01:50 EST (Thu, 08 Jan 2009)
@@ -12,6 +12,7 @@
#include "../doc_info.hpp"
#include "./post_process.hpp"
#include "./utils.hpp"
+#include "./input_path.hpp"
#include <boost/spirit/include/classic_iterator.hpp>
#include <boost/program_options.hpp>
#include <boost/filesystem/path.hpp>
@@ -164,11 +165,11 @@
("no-pretty-print", "disable XML pretty printing")
("indent", value<int>(), "indent spaces")
("linewidth", value<int>(), "line width")
- ("input-file", value<std::string>(), "input file")
- ("output-file", value<std::string>(), "output file")
+ ("input-file", value<quickbook::detail::input_path>(), "input file")
+ ("output-file", value<quickbook::detail::input_path>(), "output file")
("debug", "debug mode (for developers)")
("ms-errors", "use Microsoft Visual Studio style error & warn message format")
- ("include-path,I", value< std::vector<std::string> >(), "include path")
+ ("include-path,I", value< std::vector<quickbook::detail::input_path> >(), "include path")
;
positional_options_description p;
@@ -232,17 +233,22 @@
if (vm.count("include-path"))
{
- quickbook::include_path = vm["include-path"].as< std::vector<std::string> >();
+ std::vector<quickbook::detail::input_path> paths
+ = vm["include-path"].as<
+ std::vector<quickbook::detail::input_path> >();
+ quickbook::include_path
+ = std::vector<std::string>(paths.begin(), paths.end());
}
if (vm.count("input-file"))
{
- std::string filein = vm["input-file"].as<std::string>();
+ std::string filein
+ = vm["input-file"].as<quickbook::detail::input_path>();
std::string fileout;
if (vm.count("output-file"))
{
- fileout = vm["output-file"].as<std::string>();
+ fileout = vm["output-file"].as<quickbook::detail::input_path>();
}
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