2017-10-18 2 views
0

Can Some Description이 마지막 줄을 설명 해주시겠습니까? 결국 두 개의 꼭지점이 연결되어 있는지 확인해야합니다. 그래프와 영혼을 부스트

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); 

어떤이 마지막 줄?

bool parse_ok = qi::phrase_parse(f, l, (qi::int_ >> qi::int_) % qi::eol, qi::blank, edges); 
+0

코드를 가져온 것과 중복 된 것으로 이것을 닫았습니다. 두 모서리가 연결되어 있는지 찾는 방법을 묻고 싶다면 파싱과 관련이 없습니다. Boost Spirit을 사용하지 않고 구문 분석을 바꾸려면 괜찮습니다. 그 질문은 또 하나의 질문입니다. 입력 한 내용과 시도한 내용을 게시하면 그 질문에 답변하게되어 기쁩니다. – sehe

답변

0

the documentation 보면,이 라이브러리는 스냅을 분석하기 위해 무료 기능의 몇 가지를 제공한다 "모양을 설명해주십시오 수 있습니다.이 파서 함수는 두 가지 형태가 첫 번째 형식 구문 분석은 문자 수준에서 작동합니다. 두 번째 phrase_parse는 구문 수준에서 작동하며 건너 뛰기 구문 분석기가 필요합니다. 두 버전 모두 성공적 구문 분석에 구문 분석 된 값을 보유 할 수있는 참조로 특성을 사용할 수 있습니다. " phrase_parse()는 다음과 같이 정의됩니다.

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); 

어쩌면 시작하기에 좋은 곳입니까?

+0

시작하기에 좋지 않습니다. 자습서로 시작하십시오. http://www.boost.org/doc/libs/1_65_1/libs/spirit/doc/html/spirit/qi.html – sehe

관련 문제