From ad29b237e36c21b40e8fa1d9b31ee08a27aa8823 Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Fri, 10 Feb 2017 14:53:17 +0100 Subject: [PATCH] make annotations={true|false|(values)+} grammar --- .../server/api/route_parameters_grammar.hpp | 22 +++++++++---------- unit_tests/server/parameters_parser.cpp | 1 + 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/include/server/api/route_parameters_grammar.hpp b/include/server/api/route_parameters_grammar.hpp index 28e7e9605..b38080267 100644 --- a/include/server/api/route_parameters_grammar.hpp +++ b/include/server/api/route_parameters_grammar.hpp @@ -42,11 +42,13 @@ struct RouteParametersGrammar : public BaseParametersGrammar &root_rule_) : BaseGrammar(root_rule_) { + using AnnotationsType = engine::api::RouteParameters::AnnotationsType; + const auto add_annotation = [](engine::api::RouteParameters &route_parameters, - engine::api::RouteParameters::AnnotationsType &route_param) { + AnnotationsType route_param) { route_parameters.annotations_type = route_parameters.annotations_type | route_param; - route_parameters.annotations = route_parameters.annotations_type != - engine::api::RouteParameters::AnnotationsType::None; + route_parameters.annotations = + route_parameters.annotations_type != AnnotationsType::None; }; geometries_type.add("geojson", engine::api::RouteParameters::GeometriesType::GeoJSON)( @@ -57,13 +59,9 @@ struct RouteParametersGrammar : public BaseParametersGrammar(std::string{"1,2;3,"} + '\0'), 6); BOOST_CHECK_EQUAL(testInvalidOptions("1,2;3,4?annotations=distances"), 28UL); BOOST_CHECK_EQUAL(testInvalidOptions("1,2;3,4?annotations="), 20UL); + BOOST_CHECK_EQUAL(testInvalidOptions("1,2;3,4?annotations=true,false"), 24UL); BOOST_CHECK_EQUAL( testInvalidOptions("1,2;3,4?annotations=&overview=simplified"), 20UL);