Unpack paths and return total distance in matrix plugin for CH (#4990)
This commit is contained in:
@@ -22,11 +22,11 @@ namespace qi = boost::spirit::qi;
|
||||
|
||||
template <typename Iterator = std::string::iterator,
|
||||
typename Signature = void(engine::api::TableParameters &)>
|
||||
struct TableParametersGrammar final : public BaseParametersGrammar<Iterator, Signature>
|
||||
struct TableParametersGrammar : public BaseParametersGrammar<Iterator, Signature>
|
||||
{
|
||||
using BaseGrammar = BaseParametersGrammar<Iterator, Signature>;
|
||||
|
||||
TableParametersGrammar() : BaseGrammar(root_rule)
|
||||
TableParametersGrammar() : TableParametersGrammar(root_rule)
|
||||
{
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
if (std::is_same<std::size_t, unsigned long long>::value)
|
||||
@@ -51,15 +51,36 @@ struct TableParametersGrammar final : public BaseParametersGrammar<Iterator, Sig
|
||||
table_rule = destinations_rule(qi::_r1) | sources_rule(qi::_r1);
|
||||
|
||||
root_rule = BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json") >
|
||||
-('?' > (table_rule(qi::_r1) | BaseGrammar::base_rule(qi::_r1)) % '&');
|
||||
-('?' > (table_rule(qi::_r1) | base_rule(qi::_r1)) % '&');
|
||||
}
|
||||
|
||||
TableParametersGrammar(qi::rule<Iterator, Signature> &root_rule_) : BaseGrammar(root_rule_)
|
||||
{
|
||||
using AnnotationsType = engine::api::TableParameters::AnnotationsType;
|
||||
|
||||
const auto add_annotation = [](engine::api::TableParameters &table_parameters,
|
||||
AnnotationsType table_param) {
|
||||
table_parameters.annotations = table_parameters.annotations | table_param;
|
||||
};
|
||||
|
||||
annotations.add("duration", AnnotationsType::Duration)("distance",
|
||||
AnnotationsType::Distance);
|
||||
|
||||
base_rule = BaseGrammar::base_rule(qi::_r1) |
|
||||
(qi::lit("annotations=") >
|
||||
(annotations[ph::bind(add_annotation, qi::_r1, qi::_1)] % ','));
|
||||
}
|
||||
|
||||
protected:
|
||||
qi::rule<Iterator, Signature> base_rule;
|
||||
|
||||
private:
|
||||
qi::rule<Iterator, Signature> root_rule;
|
||||
qi::rule<Iterator, Signature> table_rule;
|
||||
qi::rule<Iterator, Signature> sources_rule;
|
||||
qi::rule<Iterator, Signature> destinations_rule;
|
||||
qi::rule<Iterator, std::size_t()> size_t_;
|
||||
qi::symbols<char, engine::api::TableParameters::AnnotationsType> annotations;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user