Commit 92402ecc authored by Tiago Peixoto's avatar Tiago Peixoto

Synchronize graphviz support with boost 1.40

parent f0524b52
...@@ -165,6 +165,10 @@ AX_BOOST_IOSTREAMS ...@@ -165,6 +165,10 @@ AX_BOOST_IOSTREAMS
if test "$BOOST_IOSTREAMS_LIB" = ""; then if test "$BOOST_IOSTREAMS_LIB" = ""; then
AC_MSG_ERROR([No usable boost::iostreams found]) AC_MSG_ERROR([No usable boost::iostreams found])
fi fi
AX_BOOST_REGEX
if test "$BOOST_REGEX_LIB" = ""; then
AC_MSG_ERROR([No usable boost::regex found])
fi
[CPPFLAGS="${CPPFLAGS} ${BOOST_CPPFLAGS}"] [CPPFLAGS="${CPPFLAGS} ${BOOST_CPPFLAGS}"]
dnl Checks for header files. dnl Checks for header files.
...@@ -272,7 +276,7 @@ AC_SUBST(MOD_DIR) ...@@ -272,7 +276,7 @@ AC_SUBST(MOD_DIR)
# default LIBADD flags for submodules # default LIBADD flags for submodules
[MOD_LIBADD="${PYTHON_LDFLAGS} ${BOOST_IOSTREAMS_LIB} -l${BOOST_PYTHON_LIB} \ [MOD_LIBADD="${PYTHON_LDFLAGS} ${BOOST_IOSTREAMS_LIB} -l${BOOST_PYTHON_LIB} \
${OPENMP_LDFLAGS} -lexpat"] ${BOOST_REGEX_LIB} ${OPENMP_LDFLAGS} -lexpat"]
AC_SUBST(MOD_LIBADD) AC_SUBST(MOD_LIBADD)
# needed for typeinfo objects to work across DSO boundaries. # needed for typeinfo objects to work across DSO boundaries.
......
# ===========================================================================
# http://www.nongnu.org/autoconf-archive/ax_boost_regex.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_BOOST_REGEX
#
# DESCRIPTION
#
# Test for Regex library from the Boost C++ libraries. The macro requires
# a preceding call to AX_BOOST_BASE. Further documentation is available at
# <http://randspringer.de/boost/index.html>.
#
# This macro calls:
#
# AC_SUBST(BOOST_REGEX_LIB)
#
# And sets:
#
# HAVE_BOOST_REGEX
#
# LICENSE
#
# Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
# Copyright (c) 2008 Michael Tindal
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved.
AC_DEFUN([AX_BOOST_REGEX],
[
AC_ARG_WITH([boost-regex],
AS_HELP_STRING([--with-boost-regex@<:@=special-lib@:>@],
[use the Regex library from boost - it is possible to specify a certain library for the linker
e.g. --with-boost-regex=boost_regex-gcc-mt-d-1_33_1 ]),
[
if test "$withval" = "no"; then
want_boost="no"
elif test "$withval" = "yes"; then
want_boost="yes"
ax_boost_user_regex_lib=""
else
want_boost="yes"
ax_boost_user_regex_lib="$withval"
fi
],
[want_boost="yes"]
)
if test "x$want_boost" = "xyes"; then
AC_REQUIRE([AC_PROG_CC])
CPPFLAGS_SAVED="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
export CPPFLAGS
LDFLAGS_SAVED="$LDFLAGS"
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
export LDFLAGS
AC_CACHE_CHECK(whether the Boost::Regex library is available,
ax_cv_boost_regex,
[AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <boost/regex.hpp>
]],
[[boost::regex r(); return 0;]]),
ax_cv_boost_regex=yes, ax_cv_boost_regex=no)
AC_LANG_POP([C++])
])
if test "x$ax_cv_boost_regex" = "xyes"; then
AC_DEFINE(HAVE_BOOST_REGEX,,[define if the Boost::Regex library is available])
BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
if test "x$ax_boost_user_regex_lib" = "x"; then
for libextension in `ls $BOOSTLIBDIR/libboost_regex*.{so,a}* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_regex.*\)\.so.*$;\1;' -e 's;^lib\(boost_regex.*\)\.a*$;\1;'` ; do
ax_lib=${libextension}
AC_CHECK_LIB($ax_lib, exit,
[BOOST_REGEX_LIB="-l$ax_lib"; AC_SUBST(BOOST_REGEX_LIB) link_regex="yes"; break],
[link_regex="no"])
done
if test "x$link_regex" != "xyes"; then
for libextension in `ls $BOOSTLIBDIR/boost_regex*.{dll,a}* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_regex.*\)\.dll.*$;\1;' -e 's;^\(boost_regex.*\)\.a*$;\1;'` ; do
ax_lib=${libextension}
AC_CHECK_LIB($ax_lib, exit,
[BOOST_REGEX_LIB="-l$ax_lib"; AC_SUBST(BOOST_REGEX_LIB) link_regex="yes"; break],
[link_regex="no"])
done
fi
else
for ax_lib in $ax_boost_user_regex_lib boost_regex-$ax_boost_user_regex_lib; do
AC_CHECK_LIB($ax_lib, main,
[BOOST_REGEX_LIB="-l$ax_lib"; AC_SUBST(BOOST_REGEX_LIB) link_regex="yes"; break],
[link_regex="no"])
done
fi
if test "x$link_regex" != "xyes"; then
AC_MSG_ERROR(Could not link against $ax_lib !)
fi
fi
CPPFLAGS="$CPPFLAGS_SAVED"
LDFLAGS="$LDFLAGS_SAVED"
fi
])
// Copyright 2004-9 Trustees of Indiana University
// Distributed under 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_new.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
//
// Jeremiah rewrite used grammar found at:
// http://www.graphviz.org/doc/info/lang.html
// and page 34 or http://www.graphviz.org/pdf/dotguide.pdf
//
// See documentation for this code at:
// http://www.boost.org/libs/graph/doc/read-graphviz.html
//
// Author: Jeremiah Willcock
// Ronald Garcia
//
#ifndef BOOST_READ_GRAPHVIZ_NEW_HPP
#define BOOST_READ_GRAPHVIZ_NEW_HPP
#include <boost/ref.hpp>
#include <boost/dynamic_property_map.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/detail/workaround.hpp>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <utility>
#include <map>
#include <iostream>
#include <cstdlib>
namespace boost {
namespace read_graphviz_detail {
typedef std::string node_name;
typedef std::string subgraph_name;
typedef std::map<std::string, std::string> properties;
struct node_and_port {
node_name name;
std::string angle; // Or empty if no angle
std::vector<std::string> location; // Up to two identifiers
friend inline bool operator==(const node_and_port& a, const node_and_port& b) {
return a.name == b.name &&
a.angle == b.angle &&
a.location == b.location;
}
friend inline bool operator<(const node_and_port& a, const node_and_port& b) {
if (a.name != b.name) return a.name < b.name;
if (a.angle != b.angle) return a.angle < b.angle;
return a.location < b.location;
}
};
struct edge_info {
node_and_port source;
node_and_port target;
properties props;
};
struct parser_result {
bool graph_is_directed;
bool graph_is_strict;
std::map<node_name, properties> nodes; // Global set
std::vector<edge_info> edges;
std::map<subgraph_name, properties> graph_props; // Root and subgraphs
};
// The actual parser, from libs/graph/src/read_graphviz_new.cpp
void parse_graphviz_from_string(const std::string& str, parser_result& result, bool want_directed);
// Translate from those results to a graph
void translate_results_to_graph(const parser_result& r, ::boost::detail::graph::mutate_graph* mg);
} // 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);
} // 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") {
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);
}
} // namespace boost
#endif // BOOST_READ_GRAPHVIZ_NEW_HPP
This diff is collapsed.
// Copyright 2004 The 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)
// Authors: Douglas Gregor
// Andrew Lumsdaine
//
// This file contains helps that enable concept-based overloading
// within the Boost Graph Library.
//
#ifndef BOOST_GRAPH_OVERLOADING_HPP
#define BOOST_GRAPH_OVERLOADING_HPP
#include <boost/type_traits/is_base_and_derived.hpp>
#include <boost/utility/enable_if.hpp>
namespace boost { namespace graph { namespace detail {
struct no_parameter {};
} } } // end namespace boost::graph::detail
#ifndef BOOST_NO_SFINAE
#define BOOST_GRAPH_ENABLE_IF_MODELS(Graph, Tag, Type) \
typename enable_if_c<(is_base_and_derived< \
Tag, \
typename graph_traits<Graph>::traversal_category>::value), \
Type>::type
#define BOOST_GRAPH_ENABLE_IF_MODELS_PARM(Graph, Tag) \
, BOOST_GRAPH_ENABLE_IF_MODELS(Graph, Tag, \
::boost::graph::detail::no_parameter) \
= ::boost::graph::detail::no_parameter()
#else
#define BOOST_GRAPH_ENABLE_IF_MODELS(Graph, Tag, Type) Type
#define BOOST_GRAPH_ENABLE_IF_MODELS_PARM(Graph, Tag)
#endif // no SFINAE support
#endif // BOOST_GRAPH_OVERLOADING_HPP
...@@ -36,6 +36,10 @@ libgraph_tool_core_la_SOURCES = \ ...@@ -36,6 +36,10 @@ libgraph_tool_core_la_SOURCES = \
../boost-workaround/boost/graph/graphml.hpp\ ../boost-workaround/boost/graph/graphml.hpp\
../boost-workaround/boost/graph/betweenness_centrality.hpp\ ../boost-workaround/boost/graph/betweenness_centrality.hpp\
../boost-workaround/boost/graph/copy.hpp\ ../boost-workaround/boost/graph/copy.hpp\
../boost-workaround/boost/graph/overloading.hpp\
../boost-workaround/boost/graph/graphviz.hpp\
../boost-workaround/boost/graph/detail/read_graphviz_new.hpp\
../boost-workaround/boost/graph/detail/read_graphviz_spirit.hpp\
../boost-workaround/boost/graph/isomorphism.hpp\ ../boost-workaround/boost/graph/isomorphism.hpp\
../boost-workaround/boost/graph/fruchterman_reingold.hpp\ ../boost-workaround/boost/graph/fruchterman_reingold.hpp\
../boost-workaround/boost/graph/kamada_kawai_spring_layout.hpp ../boost-workaround/boost/graph/kamada_kawai_spring_layout.hpp
......
...@@ -26,38 +26,21 @@ ...@@ -26,38 +26,21 @@
# define BOOST_GRAPH_READ_GRAPHVIZ_ITERATORS # define BOOST_GRAPH_READ_GRAPHVIZ_ITERATORS
#endif #endif
#include <boost/graph/graphviz.hpp> #include <boost/graph/graphviz.hpp>
#include <iostream>
namespace boost { namespace detail { namespace graph { namespace boost { namespace detail { namespace graph {
BOOST_GRAPH_DECL BOOST_GRAPH_DECL
bool read_graphviz(std::istream& in, mutate_graph& graph) bool read_graphviz(std::istream& in, mutate_graph& graph)
{ {
using namespace boost; using namespace boost;
using namespace boost::spirit::classic;
typedef std::istream_iterator<char> is_t; typedef std::istream_iterator<char> is_t;
typedef multi_pass<is_t> iterator_t;
iterator_t first(make_multi_pass(is_t(in)));
iterator_t last(make_multi_pass(is_t()));
// Turn off white space skipping on the stream
in.unsetf(std::ios::skipws);
typedef skip_parser_iteration_policy< boost::detail::graph::dot_skipper>
iter_policy_t;
typedef scanner_policies<iter_policy_t> scanner_policies_t;
typedef scanner<iterator_t, scanner_policies_t> scanner_t;
boost::detail::graph::dot_grammar p(graph);
boost::detail::graph::dot_skipper skip_p;
iter_policy_t iter_policy(skip_p);
scanner_policies_t policies(iter_policy);
scanner_t scan(first, last, policies); std::string str((is_t(in)), is_t());
return p.parse(scan); return read_graphviz(str, &graph);
} }
} } } // end namespace boost::detail::graph } } } // end namespace boost::detail::graph
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment