Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/graph/src/read_graphviz_spirit.cpp @ 45

Last change on this file since 45 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 1.8 KB
Line 
1// Copyright 2004-5 Trustees of Indiana University
2
3// Use, modification and distribution is subject to the Boost Software
4// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5// http://www.boost.org/LICENSE_1_0.txt)
6
7//
8// read_graphviz_spirit.hpp -
9//   Initialize a model of the BGL's MutableGraph concept and an associated
10//  collection of property maps using a graph expressed in the GraphViz
11// DOT Language. 
12//
13//   Based on the grammar found at:
14//   http://www.graphviz.org/cvs/doc/info/lang.html
15//
16//   See documentation for this code at:
17//     http://www.boost.org/libs/graph/doc/read-graphviz.html
18//
19
20// Authors: Ronald Garcia and Douglas Gregor
21//
22
23#define BOOST_GRAPH_SOURCE
24
25#ifndef BOOST_GRAPH_READ_GRAPHVIZ_ITERATORS
26#  define BOOST_GRAPH_READ_GRAPHVIZ_ITERATORS
27#endif
28#include <boost/graph/graphviz.hpp>
29
30namespace boost { namespace detail { namespace graph { 
31
32BOOST_GRAPH_DECL
33bool read_graphviz(std::istream& in, mutate_graph& graph) 
34{
35  using namespace boost;
36  using namespace boost::spirit;
37
38  typedef std::istream_iterator<char> is_t;
39  typedef multi_pass<is_t> iterator_t;
40
41  iterator_t first(make_multi_pass(is_t(in)));
42  iterator_t last(make_multi_pass(is_t()));
43
44  // Turn off white space skipping on the stream
45  in.unsetf(std::ios::skipws);
46
47  typedef skip_parser_iteration_policy< boost::detail::graph::dot_skipper>
48    iter_policy_t;
49  typedef scanner_policies<iter_policy_t> scanner_policies_t;
50  typedef scanner<iterator_t, scanner_policies_t> scanner_t;
51
52  boost::detail::graph::dot_grammar p(graph);
53  boost::detail::graph::dot_skipper skip_p;
54
55  iter_policy_t iter_policy(skip_p);
56  scanner_policies_t policies(iter_policy);
57
58  scanner_t scan(first, last, policies);
59
60  return p.parse(scan);
61}
62
63} } } // end namespace boost::detail::graph
Note: See TracBrowser for help on using the repository browser.