1 #ifndef GGL_GRAPH_GML_GRAMMAR_HH_
2 #define GGL_GRAPH_GML_GRAMMAR_HH_
9 #if HAVE_UNORDERED_MAP > 0
10 #include <unordered_map>
11 #elif HAVE_TR1_UNORDERED_MAP > 0
12 #include <tr1/unordered_map>
13 #elif HAVE_GNU_HASH_MAP > 0
14 #include <ext/hash_map>
20 #if !defined(BOOST_SPIRIT_CLOSURE_LIMIT)
21 #define BOOST_SPIRIT_CLOSURE_LIMIT 5
22 #elif BOOST_SPIRIT_CLOSURE_LIMIT < 5
23 #error "GGL_GRAPH_GML_GRAMMAR : BOOST_SPIRIT_CLOSURE_LIMIT too low, has to be at least 5"
27 #if !defined(PHOENIX_LIMIT)
28 #define PHOENIX_LIMIT 5
29 #elif PHOENIX_LIMIT < 5
30 #error "GGL_GRAPH_GML_GRAMMAR : PHOENIX_LIMIT too low, has to be at least 5"
33 #include <boost/version.hpp>
34 #if BOOST_VERSION >= 103800
35 #include <boost/spirit/include/classic.hpp>
36 #include <boost/spirit/include/phoenix1.hpp>
37 #define NS_BOOSTSPIRIT boost::spirit::classic
39 #include <boost/spirit.hpp>
40 #include <boost/spirit/phoenix.hpp>
41 #define NS_BOOSTSPIRIT boost::spirit
103 :
public NS_BOOSTSPIRIT::grammar< Graph_GML_grammar >
122 #if HAVE_UNORDERED_MAP > 0
123 std::unordered_map<std::string, kv_values_t>
124 #elif HAVE_TR1_UNORDERED_MAP > 0
125 std::tr1::unordered_map<std::string, kv_values_t>
126 #elif HAVE_GNU_HASH_MAP > 0
127 __gnu_cxx::hash_map<std::string, kv_values_t, sgm::hash_string>
129 std::map<std::string, kv_values_t>
133 typedef boost::tuple<int,int,std::string,std::string>
edge_t;
134 typedef boost::tuple<int,std::string,std::string>
node_t;
136 struct lt_edge :
public std::binary_function<edge_t, edge_t, bool> {
138 if (a.get<0>() != b.get<0>())
return ( a.get<0>() < b.get<0>() );
139 if (a.get<1>() != b.get<1>())
return ( a.get<1>() < b.get<1>() );
140 if (a.get<2>() != b.get<2>())
return ( a.get<2>() < b.get<2>() );
141 if (a.get<3>() != b.get<3>())
return ( a.get<3>() < b.get<3>() );
147 struct lt_node :
public std::binary_function<node_t, node_t, bool> {
149 if (a.get<0>() != b.get<0>())
return ( a.get<0>() < b.get<0>() );
150 if (a.get<1>() != b.get<1>())
return ( a.get<1>() < b.get<1>() );
151 if (a.get<2>() != b.get<2>())
return ( a.get<2>() < b.get<2>() );
158 std::string, std::string, int, double>
190 keys_map_t::iterator pos =
_keys.find(k);
192 if (pos !=
_keys.end())
return (pos->second);
197 keys_map_t::iterator pos =
_keys.find(
"_"+k);
217 boost::property_map< Graph, PropNodeLabel>::type
222 boost::property_map< Graph, PropEdgeLabel>::type
241 std::pair< Graph, int >
246 template <
typename ScannerT>
255 NS_BOOSTSPIRIT::rule<ScannerT>
const&
263 typedef NS_BOOSTSPIRIT::rule<ScannerT
315 void dumpKeyValues(std::string k, std::string s,
int i,
double d);
324 void set_node_data(std::string k, std::string s,
int i,
double d);
327 void set_edge_data(std::string k, std::string s,
int i,
double d);
330 void keyValueAction(std::string k, std::string s,
int i,
double d);
354 #include "ggl/Graph_GML_grammar.icc"