| 30 | /////////////////////////////////////////////////////////////////////////// |
| 31 | template <typename Iterator> |
| 32 | bool parse_complex(Iterator first, Iterator last, std::complex<double>& c) |
| 33 | { |
| 34 | using boost::spirit::qi::double_; |
| 35 | using boost::spirit::qi::_1; |
| 36 | using boost::spirit::qi::phrase_parse; |
| 37 | using boost::spirit::ascii::space; |
| 38 | using boost::phoenix::ref; |
| 39 | |
| 40 | double rN = 0.0; |
| 41 | double iN = 0.0; |
| 42 | bool r = phrase_parse(first, last, |
| 43 | ( |
| 44 | '(' >> double_[ref(rN) = _1] |
| 45 | >> -(',' >> double_[ref(iN) = _1]) >> ')' |
| 46 | | double_[ref(rN) = _1] |
| 47 | ), |
| 48 | space); |
| 49 | |
| 50 | if (!r || first != last) // fail if we did not get a full match |
| 51 | return false; |
| 52 | c = std::complex<double>(rN, iN); |
| 53 | return r; |
| 54 | } |
| 55 | |
| 56 | /////////////////////////////////////////////////////////////////////////// |
| 57 | // Our complex number generator |