#ifndef TRIP_PARAMETERS_GRAMMAR_HPP #define TRIP_PARAMETERS_GRAMMAR_HPP #include "server/api/route_parameters_grammar.hpp" #include "engine/api/trip_parameters.hpp" #include #include namespace osrm { namespace server { namespace api { namespace { namespace ph = boost::phoenix; namespace qi = boost::spirit::qi; } template struct TripParametersGrammar final : public RouteParametersGrammar { using BaseGrammar = RouteParametersGrammar; TripParametersGrammar() : BaseGrammar(root_rule) { roundtrip_rule = qi::lit("roundtrip=") > qi::bool_[ph::bind(&engine::api::TripParameters::roundtrip, qi::_r1) = qi::_1]; source_type.add("any", engine::api::TripParameters::SourceType::Any)( "first", engine::api::TripParameters::SourceType::First); destination_type.add("any", engine::api::TripParameters::DestinationType::Any)( "last", engine::api::TripParameters::DestinationType::Last); source_rule = qi::lit("source=") > source_type[ph::bind(&engine::api::TripParameters::source, qi::_r1) = qi::_1]; destination_rule = qi::lit("destination=") > destination_type[ph::bind(&engine::api::TripParameters::destination, qi::_r1) = qi::_1]; root_rule = BaseGrammar::query_rule(qi::_r1) > BaseGrammar::format_rule(qi::_r1) > -('?' > (roundtrip_rule(qi::_r1) | source_rule(qi::_r1) | destination_rule(qi::_r1) | BaseGrammar::base_rule(qi::_r1)) % '&'); } private: qi::rule source_rule; qi::rule destination_rule; qi::rule roundtrip_rule; qi::rule root_rule; qi::symbols source_type; qi::symbols destination_type; }; } } } #endif