#ifndef TABLE_PARAMETERS_GRAMMAR_HPP #define TABLE_PARAMETERS_GRAMMAR_HPP #include "engine/api/table_parameters.hpp" #include "server/api/base_parameters_grammar.hpp" //#define BOOST_SPIRIT_DEBUG #include namespace osrm { namespace server { namespace api { namespace qi = boost::spirit::qi; struct TableParametersGrammar final : public BaseParametersGrammar { using Iterator = std::string::iterator; using SourcesT = std::vector; using DestinationsT = std::vector; TableParametersGrammar() : BaseParametersGrammar(root_rule, parameters) { const auto set_destiantions = [this](DestinationsT dests) { parameters.destinations = std::move(dests); }; const auto set_sources = [this](SourcesT sources) { parameters.sources = std::move(sources); }; // TODO: ulonglong -> size_t not only on Windows but on all 32 bit platforms; unsupported anyway as of now #ifdef WIN32 destinations_rule = (qi::lit("destinations=") > (qi::ulong_long % ";")[set_destiantions]) | qi::lit("destinations=all"); sources_rule = (qi::lit("sources=") > (qi::ulong_long % ";")[set_sources]) | qi::lit("sources=all"); #else destinations_rule = (qi::lit("destinations=") > (qi::ulong_ % ";")[set_destiantions]) | qi::lit("destinations=all"); sources_rule = (qi::lit("sources=") > (qi::ulong_ % ";")[set_sources]) | qi::lit("sources=all"); #endif table_rule = destinations_rule | sources_rule; root_rule = query_rule > -qi::lit(".json") > -(qi::lit("?") > (table_rule | base_rule) % '&'); } engine::api::TableParameters parameters; private: qi::rule root_rule; qi::rule table_rule; qi::rule sources_rule; qi::rule destinations_rule; }; } } } #endif