osrm-backend/include/server/api/match_parameter_grammar.hpp

51 lines
1.3 KiB
C++
Raw Normal View History

2016-02-17 18:20:53 -05:00
#ifndef MATCH_PARAMETERS_GRAMMAR_HPP
#define MATCH_PARAMETERS_GRAMMAR_HPP
#include "server/api/route_parameters_grammar.hpp"
2016-05-27 15:05:04 -04:00
#include "engine/api/match_parameters.hpp"
2016-02-17 18:20:53 -05:00
#include <boost/spirit/include/phoenix.hpp>
#include <boost/spirit/include/qi.hpp>
2016-02-17 18:20:53 -05:00
namespace osrm
{
namespace server
{
namespace api
{
namespace
{
namespace ph = boost::phoenix;
2016-02-17 18:20:53 -05:00
namespace qi = boost::spirit::qi;
}
2016-02-17 18:20:53 -05:00
template <typename Iterator = std::string::iterator,
typename Signature = void(engine::api::MatchParameters &)>
struct MatchParametersGrammar final : public RouteParametersGrammar<Iterator, Signature>
2016-02-17 18:20:53 -05:00
{
using BaseGrammar = RouteParametersGrammar<Iterator, Signature>;
2016-02-17 18:20:53 -05:00
MatchParametersGrammar() : BaseGrammar(root_rule)
2016-02-17 18:20:53 -05:00
{
2016-05-27 15:05:04 -04:00
timestamps_rule =
qi::lit("timestamps=") >
(qi::uint_ %
';')[ph::bind(&engine::api::MatchParameters::timestamps, qi::_r1) = qi::_1];
root_rule = BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json") >
-('?' > (timestamps_rule(qi::_r1) | BaseGrammar::base_rule(qi::_r1) | (
qi::lit("tidying=") > qi::bool_[ph::bind(&engine::api::MatchParameters::use_tidying,
qi::_r1) = qi::_1])) % '&');
2016-02-17 18:20:53 -05:00
}
private:
qi::rule<Iterator, Signature> root_rule;
qi::rule<Iterator, Signature> timestamps_rule;
2016-02-17 18:20:53 -05:00
};
}
}
}
#endif