|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r60770 - in trunk: boost/graph boost/graph/detail libs/graph/src
From: jewillco_at_[hidden]
Date: 2010-03-22 15:16:39
Author: jewillco
Date: 2010-03-22 15:16:38 EDT (Mon, 22 Mar 2010)
New Revision: 60770
URL: http://svn.boost.org/trac/boost/changeset/60770
Log:
Re-enabled Spirit-based parser (but not by default) and cleaned up Graphviz reader implementation
Removed:
trunk/libs/graph/src/read_graphviz_spirit.cpp
Text files modified:
trunk/boost/graph/detail/read_graphviz_new.hpp | 18 +++--------
trunk/boost/graph/detail/read_graphviz_spirit.hpp | 6 +-
trunk/boost/graph/graphviz.hpp | 64 +++++++++++++++++++++++++++++----------
trunk/libs/graph/src/read_graphviz_new.cpp | 2
4 files changed, 56 insertions(+), 34 deletions(-)
Modified: trunk/boost/graph/detail/read_graphviz_new.hpp
==============================================================================
--- trunk/boost/graph/detail/read_graphviz_new.hpp (original)
+++ trunk/boost/graph/detail/read_graphviz_new.hpp 2010-03-22 15:16:38 EDT (Mon, 22 Mar 2010)
@@ -89,26 +89,18 @@
} // namespace read_graphviz_detail
-// This is also in boost/graph/graphviz.hpp
namespace detail {
namespace graph {
- BOOST_GRAPH_DECL bool read_graphviz(const std::string& str, boost::detail::graph::mutate_graph* mg);
+ BOOST_GRAPH_DECL bool read_graphviz_new(const std::string& str, boost::detail::graph::mutate_graph* mg);
} // end namespace graph
} // end namespace detail
template <typename MutableGraph>
-bool read_graphviz(const std::string& str,
- MutableGraph& graph, boost::dynamic_properties& dp,
- std::string const& node_id = "node_id") {
+bool read_graphviz_new(const std::string& str,
+ MutableGraph& graph, boost::dynamic_properties& dp,
+ std::string const& node_id = "node_id") {
boost::detail::graph::mutate_graph_impl<MutableGraph> mg(graph, dp, node_id);
- return detail::graph::read_graphviz(str, &mg);
-}
-
-template <typename InputIter, typename MutableGraph>
-bool read_graphviz(InputIter begin, InputIter end,
- MutableGraph& graph, boost::dynamic_properties& dp,
- std::string const& node_id = "node_id") {
- return read_graphviz(std::string(begin, end), graph, dp, node_id);
+ return detail::graph::read_graphviz_new(str, &mg);
}
} // namespace boost
Modified: trunk/boost/graph/detail/read_graphviz_spirit.hpp
==============================================================================
--- trunk/boost/graph/detail/read_graphviz_spirit.hpp (original)
+++ trunk/boost/graph/detail/read_graphviz_spirit.hpp 2010-03-22 15:16:38 EDT (Mon, 22 Mar 2010)
@@ -581,9 +581,9 @@
} // namespace detail
template <typename MultiPassIterator, typename MutableGraph>
-bool read_graphviz(MultiPassIterator begin, MultiPassIterator end,
- MutableGraph& graph, dynamic_properties& dp,
- std::string const& node_id = "node_id") {
+bool read_graphviz_spirit(MultiPassIterator begin, MultiPassIterator end,
+ MutableGraph& graph, dynamic_properties& dp,
+ std::string const& node_id = "node_id") {
using namespace boost;
using namespace boost::spirit::classic;
Modified: trunk/boost/graph/graphviz.hpp
==============================================================================
--- trunk/boost/graph/graphviz.hpp (original)
+++ trunk/boost/graph/graphviz.hpp 2010-03-22 15:16:38 EDT (Mon, 22 Mar 2010)
@@ -25,6 +25,7 @@
#include <boost/property_map/dynamic_property_map.hpp>
#include <boost/graph/overloading.hpp>
#include <boost/graph/dll_import_export.hpp>
+#include <boost/spirit/include/classic_multi_pass.hpp>
namespace boost {
@@ -771,10 +772,51 @@
std::map<edge_t, bgl_edge_t> bgl_edges;
};
-BOOST_GRAPH_DECL
-bool read_graphviz(std::istream& in, mutate_graph& graph);
+} } } // end namespace boost::detail::graph
-} } // end namespace detail::graph
+#ifdef BOOST_GRAPH_USE_SPIRIT_PARSER
+# ifndef BOOST_GRAPH_READ_GRAPHVIZ_ITERATORS
+# define BOOST_GRAPH_READ_GRAPHVIZ_ITERATORS
+# endif
+# include <boost/graph/detail/read_graphviz_spirit.hpp>
+#else // New default parser
+# include <boost/graph/detail/read_graphviz_new.hpp>
+#endif // BOOST_GRAPH_USE_SPIRIT_PARSER
+
+namespace boost {
+
+// Parse the passed string as a GraphViz dot file.
+template <typename MutableGraph>
+bool read_graphviz(const std::string& data,
+ MutableGraph& graph,
+ dynamic_properties& dp,
+ std::string const& node_id = "node_id") {
+#ifdef BOOST_GRAPH_USE_SPIRIT_PARSER
+ return read_graphviz_spirit(data.begin(), data.end(), graph, dp, node_id);
+#else // Non-Spirit parser
+ return read_graphviz_new(data,graph,dp,node_id);
+#endif
+}
+
+// Parse the passed iterator range as a GraphViz dot file.
+template <typename InputIterator, typename MutableGraph>
+bool read_graphviz(InputIterator user_first,
+ InputIterator user_last,
+ MutableGraph& graph,
+ dynamic_properties& dp,
+ std::string const& node_id = "node_id") {
+#ifdef BOOST_GRAPH_USE_SPIRIT_PARSER
+ typedef InputIterator is_t;
+ typedef boost::spirit::classic::multi_pass<is_t> iterator_t;
+
+ iterator_t first(boost::spirit::classic::make_multi_pass(user_first));
+ iterator_t last(boost::spirit::classic::make_multi_pass(user_last));
+
+ return read_graphviz_spirit(first, last, graph, dp, node_id);
+#else // Non-Spirit parser
+ return read_graphviz_new(std::string(user_first, user_last), graph, dp, node_id);
+#endif
+}
// Parse the passed stream as a GraphViz dot file.
template <typename MutableGraph>
@@ -782,25 +824,13 @@
dynamic_properties& dp,
std::string const& node_id = "node_id")
{
- std::string data;
+ typedef std::istream_iterator<char> is_t;
in >> std::noskipws;
- std::copy(std::istream_iterator<char>(in),
- std::istream_iterator<char>(),
- std::back_inserter(data));
- return read_graphviz(data,graph,dp,node_id);
+ return read_graphviz(is_t(in), is_t(), graph, dp, node_id);
}
} // namespace boost
-#ifdef BOOST_GRAPH_USE_SPIRIT_PARSER
-# ifndef BOOST_GRAPH_READ_GRAPHVIZ_ITERATORS
-# define BOOST_GRAPH_READ_GRAPHVIZ_ITERATORS
-# endif
-# include <boost/graph/detail/read_graphviz_spirit.hpp>
-#else // New default parser
-# include <boost/graph/detail/read_graphviz_new.hpp>
-#endif // BOOST_GRAPH_USE_SPIRIT_PARSER
-
#ifdef BOOST_GRAPH_USE_MPI
# include <boost/graph/distributed/graphviz.hpp>
#endif
Modified: trunk/libs/graph/src/read_graphviz_new.cpp
==============================================================================
--- trunk/libs/graph/src/read_graphviz_new.cpp (original)
+++ trunk/libs/graph/src/read_graphviz_new.cpp 2010-03-22 15:16:38 EDT (Mon, 22 Mar 2010)
@@ -793,7 +793,7 @@
namespace detail {
namespace graph {
- BOOST_GRAPH_DECL bool read_graphviz(const std::string& str, boost::detail::graph::mutate_graph* mg) {
+ BOOST_GRAPH_DECL bool read_graphviz_new(const std::string& str, boost::detail::graph::mutate_graph* mg) {
read_graphviz_detail::parser_result parsed_file;
read_graphviz_detail::parse_graphviz_from_string(str, parsed_file, mg->is_directed());
read_graphviz_detail::translate_results_to_graph(parsed_file, mg);
Deleted: trunk/libs/graph/src/read_graphviz_spirit.cpp
==============================================================================
--- trunk/libs/graph/src/read_graphviz_spirit.cpp 2010-03-22 15:16:38 EDT (Mon, 22 Mar 2010)
+++ (empty file)
@@ -1,47 +0,0 @@
-// Copyright 2004-5 Trustees of Indiana University
-
-// 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)
-
-//
-// read_graphviz_spirit.hpp -
-// Initialize a model of the BGL's MutableGraph concept and an associated
-// collection of property maps using a graph expressed in the GraphViz
-// DOT Language.
-//
-// Based on the grammar found at:
-// http://www.graphviz.org/cvs/doc/info/lang.html
-//
-// See documentation for this code at:
-// http://www.boost.org/libs/graph/doc/read-graphviz.html
-//
-
-// Authors: Ronald Garcia and Douglas Gregor
-//
-
-#define BOOST_GRAPH_SOURCE
-
-#ifndef BOOST_GRAPH_READ_GRAPHVIZ_ITERATORS
-# define BOOST_GRAPH_READ_GRAPHVIZ_ITERATORS
-#endif
-#include <boost/graph/graphviz.hpp>
-#include <iostream>
-
-namespace boost { namespace detail { namespace graph {
-
-#if 0
-BOOST_GRAPH_DECL
-bool read_graphviz(std::istream& in, mutate_graph& graph)
-{
- using namespace boost;
-
- typedef std::istream_iterator<char> is_t;
-
- std::string str((is_t(in)), is_t());
-
- return read_graphviz(str.begin(), str.end());
-}
-#endif
-
-} } } // end namespace boost::detail::graph
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