* signature changed from void() to void(engine::api::Parameters&) * performance increase due to use "static const GrammarT" and avoid construction and destruction of grammars during parsing * removed code duplication in inherited grammars * rule unlimited changed to qi::lit * added rule size_t_ * parser accepts "&geometries=" and "&overview=" and fails at "foo" instead of "&geometries=foo" and &overview=foo * added expectations checks for derived grammars * changed rules qi::list(".") to character rules '.'
50 lines
1.1 KiB
C++
50 lines
1.1 KiB
C++
#ifndef SERVER_API_TILE_PARAMETERS_GRAMMAR_HPP
|
|
#define SERVER_API_TILE_PARAMETERS_GRAMMAR_HPP
|
|
|
|
#include "engine/api/tile_parameters.hpp"
|
|
|
|
#include "engine/hint.hpp"
|
|
#include "engine/polyline_compressor.hpp"
|
|
|
|
#include <boost/spirit/include/phoenix.hpp>
|
|
#include <boost/spirit/include/qi.hpp>
|
|
|
|
#include <string>
|
|
|
|
namespace osrm
|
|
{
|
|
namespace server
|
|
{
|
|
namespace api
|
|
{
|
|
|
|
namespace
|
|
{
|
|
namespace ph = boost::phoenix;
|
|
namespace qi = boost::spirit::qi;
|
|
}
|
|
|
|
template <typename Iterator = std::string::iterator,
|
|
typename Signature = void(engine::api::TileParameters &)>
|
|
struct TileParametersGrammar final : boost::spirit::qi::grammar<Iterator, Signature>
|
|
{
|
|
TileParametersGrammar() : TileParametersGrammar::base_type(root_rule)
|
|
{
|
|
root_rule
|
|
= qi::lit("tile(")
|
|
> qi::uint_[ph::bind(&engine::api::TileParameters::x, qi::_r1) = qi::_1] > ','
|
|
> qi::uint_[ph::bind(&engine::api::TileParameters::y, qi::_r1) = qi::_1] > ','
|
|
> qi::uint_[ph::bind(&engine::api::TileParameters::z, qi::_r1) = qi::_1]
|
|
> qi::lit(").mvt")
|
|
;
|
|
}
|
|
|
|
private:
|
|
qi::rule<Iterator, Signature> root_rule;
|
|
};
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif
|