C++ (Qt)struct Node{ Node() : number(0) {} static constexpr uint nodeDimension = 3; uint number; std::array<float, nodeDimension> coordinates = {{-1, -1, -1}};}; namespace qi = boost::spirit::qi;namespace phx = boost::phoenix;namespace sw = boost::spirit::standard_wide; template <class ForwardIterator>class NodeParser : public qi::grammar<ForwardIterator, Node(), sw::space_type>{public: NodeParser() : NodeParser::base_type(start_, "NodeParser") { start_ = qi::lit("*node(") >> qi::uint_[phx::bind(&NodeParser::set_number, qi::_val, qi::_1)] >> ',' >> qi::float_[phx::bind(&NodeParser::set_x, qi::_val, qi::_1)] >> ',' >> qi::float_[phx::bind(&NodeParser::set_y, qi::_val, qi::_1)] >> ',' >> qi::float_[phx::bind(&NodeParser::set_z, qi::_val, qi::_1)] >> ',' >> *(qi::uint_ >> ',') >> qi::uint_ >> ')'; }private: qi::rule<ForwardIterator, Node(), sw::space_type> start_; static void set_number(Node & node, uint number){ node.number = number; } static void set_x(Node & node, float x){ node.coordinates[0] = x; } static void set_y(Node & node, float y){ node.coordinates[1] = y; } static void set_z(Node & node, float z){ node.coordinates[2] = z; }};
C++ (Qt)QStringRef src(&text);src = BeforeFirst(src, "//");
C++ (Qt)start_ = qi::lit("*node(") >> qi::uint_[phx::bind(&NodeParser::set_number, qi::_val, qi::_1)] >> ',' >> qi::float_[phx::bind(&NodeParser::set_x, qi::_val, qi::_1)] >> ',' >> qi::float_[phx::bind(&NodeParser::set_y, qi::_val, qi::_1)] >> ',' >> qi::float_[phx::bind(&NodeParser::set_z, qi::_val, qi::_1)] >> ',' >> *(qi::uint_ >> ',') >> qi::uint_ >> ')' >> '//' >> *(qi::char_);
C++ (Qt)start = space // tab/space/cr/lf | "//" >> *(char_ - eol) >> eol // C++ style comments;
C++ (Qt) switch (e->type()) { case QEvent::MouseButtonDblClick: break; default: return false; }