2016-02-17 18:20:53 -05:00
|
|
|
#ifndef NEAREST_PARAMETERS_GRAMMAR_HPP
|
|
|
|
#define NEAREST_PARAMETERS_GRAMMAR_HPP
|
|
|
|
|
|
|
|
#include "server/api/base_parameters_grammar.hpp"
|
2016-05-27 15:05:04 -04:00
|
|
|
#include "engine/api/nearest_parameters.hpp"
|
2016-02-17 18:20:53 -05:00
|
|
|
|
2023-01-21 02:47:05 -05:00
|
|
|
#include <boost/phoenix.hpp>
|
2016-04-07 07:25:35 -04:00
|
|
|
#include <boost/spirit/include/qi.hpp>
|
2016-02-17 18:20:53 -05:00
|
|
|
|
2022-12-11 04:10:26 -05:00
|
|
|
namespace osrm::server::api
|
2016-02-17 18:20:53 -05:00
|
|
|
{
|
|
|
|
|
2016-04-20 14:40:17 -04:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
namespace ph = boost::phoenix;
|
2016-02-17 18:20:53 -05:00
|
|
|
namespace qi = boost::spirit::qi;
|
2020-11-26 10:21:39 -05:00
|
|
|
} // namespace
|
2016-02-17 18:20:53 -05:00
|
|
|
|
2016-04-20 14:40:17 -04:00
|
|
|
template <typename Iterator = std::string::iterator,
|
|
|
|
typename Signature = void(engine::api::NearestParameters &)>
|
|
|
|
struct NearestParametersGrammar final : public BaseParametersGrammar<Iterator, Signature>
|
2016-02-17 18:20:53 -05:00
|
|
|
{
|
2016-04-20 14:40:17 -04:00
|
|
|
using BaseGrammar = BaseParametersGrammar<Iterator, Signature>;
|
2016-02-17 18:20:53 -05:00
|
|
|
|
2016-04-20 14:40:17 -04:00
|
|
|
NearestParametersGrammar() : BaseGrammar(root_rule)
|
2016-02-17 18:20:53 -05:00
|
|
|
{
|
2016-05-27 15:05:04 -04:00
|
|
|
nearest_rule = (qi::lit("number=") >
|
|
|
|
qi::uint_)[ph::bind(&engine::api::NearestParameters::number_of_results,
|
|
|
|
qi::_r1) = qi::_1];
|
|
|
|
|
2019-07-31 10:52:38 -04:00
|
|
|
root_rule = BaseGrammar::query_rule(qi::_r1) > BaseGrammar::format_rule(qi::_r1) >
|
2016-05-27 15:05:04 -04:00
|
|
|
-('?' > (nearest_rule(qi::_r1) | BaseGrammar::base_rule(qi::_r1)) % '&');
|
2016-02-17 18:20:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2016-04-20 14:40:17 -04:00
|
|
|
qi::rule<Iterator, Signature> root_rule;
|
|
|
|
qi::rule<Iterator, Signature> nearest_rule;
|
2016-02-17 18:20:53 -05:00
|
|
|
};
|
2022-12-20 12:00:11 -05:00
|
|
|
} // namespace osrm::server::api
|
2016-02-17 18:20:53 -05:00
|
|
|
|
|
|
|
#endif
|