Skip to content

Commit

Permalink
Patch downstream sources (break graphml->graphviz dependency)
Browse files Browse the repository at this point in the history
  • Loading branch information
francoisk committed Mar 7, 2023
1 parent 5a90e4b commit e6ff2e3
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 48 deletions.
49 changes: 49 additions & 0 deletions downstream/libs/graph/include/boost/graph/exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,55 @@ struct BOOST_SYMBOL_VISIBLE not_complete : public bad_graph
not_complete() : bad_graph("The graph must be complete.") {}
};

// @@ The remaining exceptions have been moved here from graphviz.hpp.
//
struct BOOST_SYMBOL_VISIBLE graph_exception : public std::exception
{
~graph_exception() throw() BOOST_OVERRIDE {}
const char* what() const throw() BOOST_OVERRIDE = 0;
};

struct BOOST_SYMBOL_VISIBLE bad_parallel_edge : public graph_exception
{
std::string from;
std::string to;
mutable std::string statement;
bad_parallel_edge(const std::string& i, const std::string& j)
: from(i), to(j)
{
}

~bad_parallel_edge() throw() BOOST_OVERRIDE {}
const char* what() const throw() BOOST_OVERRIDE
{
if (statement.empty())
statement = std::string("Failed to add parallel edge: (") + from
+ "," + to + ")\n";

return statement.c_str();
}
};

struct BOOST_SYMBOL_VISIBLE directed_graph_error : public graph_exception
{
~directed_graph_error() throw() BOOST_OVERRIDE {}
const char* what() const throw() BOOST_OVERRIDE
{
return "read_graphviz: "
"Tried to read a directed graph into an undirected graph.";
}
};

struct BOOST_SYMBOL_VISIBLE undirected_graph_error : public graph_exception
{
~undirected_graph_error() throw() BOOST_OVERRIDE {}
const char* what() const throw() BOOST_OVERRIDE
{
return "read_graphviz: "
"Tried to read an undirected graph into a directed graph.";
}
};

} // namespace boost

#endif // BOOST_GRAPH_EXCEPTION_HPP
16 changes: 15 additions & 1 deletion downstream/libs/graph/include/boost/graph/graphml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,21 @@
#include <boost/any.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/graph/dll_import_export.hpp>
#include <boost/graph/graphviz.hpp> // for exceptions

// @@ Replace the inclusion of graphviz.hpp (an entire submodule) with the
// inclusion of a few lower-level headers (the required exceptions have
// been moved from graphviz.hpp to (the pre-existing) exception.hpp).
//
// According to
// https://www.boost.org/doc/libs/1_81_0/libs/graph/doc/read_graphml.html
// these exceptions are defined in graphml.hpp so they were probably moved
// to graphviz.hpp at some point without updating the docs.
//
#include <boost/graph/exception.hpp>
#include <boost/property_map/dynamic_property_map.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/adjacency_list.hpp>

#include <boost/mpl/bool.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/find.hpp>
Expand Down
48 changes: 1 addition & 47 deletions downstream/libs/graph/include/boost/graph/graphviz.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <string>
#include <boost/property_map/property_map.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/graph/exception.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/properties.hpp>
#include <boost/graph/subgraph.hpp>
Expand Down Expand Up @@ -649,53 +650,6 @@ void write_graphviz_dp(std::ostream& out, const Graph& g,
/////////////////////////////////////////////////////////////////////////////
// Graph reader exceptions
/////////////////////////////////////////////////////////////////////////////
struct BOOST_SYMBOL_VISIBLE graph_exception : public std::exception
{
~graph_exception() throw() BOOST_OVERRIDE {}
const char* what() const throw() BOOST_OVERRIDE = 0;
};

struct BOOST_SYMBOL_VISIBLE bad_parallel_edge : public graph_exception
{
std::string from;
std::string to;
mutable std::string statement;
bad_parallel_edge(const std::string& i, const std::string& j)
: from(i), to(j)
{
}

~bad_parallel_edge() throw() BOOST_OVERRIDE {}
const char* what() const throw() BOOST_OVERRIDE
{
if (statement.empty())
statement = std::string("Failed to add parallel edge: (") + from
+ "," + to + ")\n";

return statement.c_str();
}
};

struct BOOST_SYMBOL_VISIBLE directed_graph_error : public graph_exception
{
~directed_graph_error() throw() BOOST_OVERRIDE {}
const char* what() const throw() BOOST_OVERRIDE
{
return "read_graphviz: "
"Tried to read a directed graph into an undirected graph.";
}
};

struct BOOST_SYMBOL_VISIBLE undirected_graph_error : public graph_exception
{
~undirected_graph_error() throw() BOOST_OVERRIDE {}
const char* what() const throw() BOOST_OVERRIDE
{
return "read_graphviz: "
"Tried to read an undirected graph into a directed graph.";
}
};

struct BOOST_SYMBOL_VISIBLE bad_graphviz_syntax : public graph_exception
{
std::string errmsg;
Expand Down

0 comments on commit e6ff2e3

Please sign in to comment.