From dfdeda17fdf3901be538d741159bacaf8ec999ef Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Wed, 13 Nov 2024 14:03:01 +0000 Subject: [PATCH] expressions - add "bool(expr)" explicit conversion operator --- include/mapnik/expression_grammar_x3_def.hpp | 1 + include/mapnik/function_call.hpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/include/mapnik/expression_grammar_x3_def.hpp b/include/mapnik/expression_grammar_x3_def.hpp index 06a318698..5b1dc9583 100644 --- a/include/mapnik/expression_grammar_x3_def.hpp +++ b/include/mapnik/expression_grammar_x3_def.hpp @@ -217,6 +217,7 @@ struct unary_function_types_ : x3::symbols ("log", log_impl()) // ("abs", abs_impl()) // ("length", length_impl()) // + ("bool", bool_impl()) // ("int", int_impl()) // ("float", float_impl()) // ("str", str_impl()) // diff --git a/include/mapnik/function_call.hpp b/include/mapnik/function_call.hpp index 30e8b956d..75c92a1e8 100644 --- a/include/mapnik/function_call.hpp +++ b/include/mapnik/function_call.hpp @@ -95,6 +95,12 @@ struct str_impl value_type operator()(value_type const& val) const { return val.to_unicode(); } }; +// bool +struct bool_impl +{ + value_type operator()(value_type const& val) const { return val.to_bool(); } +}; + // int struct int_impl {