0

Can Someone Please explain this Last line? I need to eventually determine if two vertexes are connected.

include <boost/fusion/adapted/std_pair.hpp>
include <boost/spirit/include/qi.hpp>
include <boost/graph/edge_list.hpp>
include <fstream>

typedef std::pair<int,int> Edge;
typedef std::vector<Edge> EdgeList;
typedef boost::edge_list<EdgeList::iterator> Graph;

namespace qi = boost::spirit::qi;

int main()
{
    std::ifstream ifs("Graph.txt");
    ifs >> std::noskipws;
    //std::cout << ifs;
    boost::spirit::istream_iterator f(ifs), l;

    std::vector<Edge> edges;
    bool parse_ok = qi::phrase_parse(f, l, (qi::int_ >> qi::int_) % qi::eol, qi::blank, edges);

Can some please explain this last line?:

bool parse_ok = qi::phrase_parse(f, l, (qi::int_ >> qi::int_) % qi::eol, qi::blank, edges);
manlio
  • 18,345
  • 14
  • 76
  • 126
  • I closed this as a duplicate of the one you took the code from. If you want to ask how to find whether two edges are connected, that has nothing to do with the parsing. If you want to replace the parsing without using Boost Spirit, fine: that's another question and I'll be happy to answer that question (if you post it with the input and what you tried). – sehe Oct 18 '17 at 11:48

1 Answers1

0

Looking at the documentation, looks like " The library provides a couple of free functions to make parsing a snap. These parser functions have two forms. The first form parse works on the character level. The second phrase_parse works on the phrase level and requires skip parser. Both versions can take in attributes by reference that will hold the parsed values on a successful parse." phrase_parse() is defined as

template <typename Iterator, typename Expr, typename Skipper>
inline bool
phrase_parse(
    Iterator& first
  , Iterator last
  , Expr const& expr
  , Skipper const& skipper
  , BOOST_SCOPED_ENUM(skip_flag) post_skip = skip_flag::postskip);

Maybe this is a good place to start.

schaiba
  • 362
  • 3
  • 11
  • That's not a good place to start. Start with the tutorials: http://www.boost.org/doc/libs/1_65_1/libs/spirit/doc/html/spirit/qi.html – sehe Oct 18 '17 at 11:45