From 6f0bab62463cc0e38707c0ae677d5e50c556052b Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Tue, 15 Dec 2020 16:23:59 +0000 Subject: [PATCH] Backport support for boost 1.74 via patch from @redneb --- .../mapnik/json/feature_generator_grammar.hpp | 99 ++++---- .../json/feature_generator_grammar_impl.hpp | 10 +- .../json/properties_generator_grammar.hpp | 11 +- .../properties_generator_grammar_impl.hpp | 2 +- .../util/spirit_transform_attribute.hpp | 216 ------------------ include/mapnik/wkt/wkt_factory.hpp | 2 + src/json/mapnik_json_generator_grammar.cpp | 2 +- src/tiff_reader.cpp | 1 + 8 files changed, 63 insertions(+), 280 deletions(-) delete mode 100644 include/mapnik/util/spirit_transform_attribute.hpp diff --git a/include/mapnik/json/feature_generator_grammar.hpp b/include/mapnik/json/feature_generator_grammar.hpp index 7bfbbc5e2..6fd5c11e3 100644 --- a/include/mapnik/json/feature_generator_grammar.hpp +++ b/include/mapnik/json/feature_generator_grammar.hpp @@ -30,88 +30,87 @@ #include // boost +#include #include +#include +#include + + +namespace mapnik { + +struct kv_store +{ + using value_type = mapnik::feature_impl::value_type; + using iterator_type = mapnik::feature_kv_iterator2; + kv_store(mapnik::feature_impl const& f) + : start_(mapnik::value_not_null(),f.begin(),f.end()), + end_(mapnik::value_not_null(),f.end(),f.end()) + {} + iterator_type start_; + iterator_type end_; +}; + +} namespace boost { namespace spirit { namespace traits { template <> -struct is_container : mpl::false_ {} ; +struct is_container : mpl::false_ {} ; template <> -struct container_iterator +struct container_iterator { - using type = mapnik::feature_kv_iterator2; + using type = mapnik::kv_store::iterator_type; }; template <> -struct begin_container +struct begin_container { - static mapnik::feature_kv_iterator2 - call (mapnik::feature_impl const& f) + static mapnik::kv_store::iterator_type + call (mapnik::kv_store const& kv) { - return mapnik::feature_kv_iterator2(mapnik::value_not_null(),f.begin(),f.end()); + return kv.start_; } }; template <> -struct end_container +struct end_container { - static mapnik::feature_kv_iterator2 - call (mapnik::feature_impl const& f) + static mapnik::kv_store::iterator_type + call (mapnik::kv_store const& kv) { - return mapnik::feature_kv_iterator2(mapnik::value_not_null(),f.end(),f.end()); + return kv.end_; } }; -#if BOOST_VERSION >= 106900 -template <> -struct transform_attribute - : detail::transform_attribute_base -{}; - -template <> -struct transform_attribute, const mapnik::feature_impl &, - boost::spirit::karma::domain, void> - : detail::transform_attribute_base, mapnik::feature_impl const&, boost::spirit::karma::domain> -{}; -#endif }}} +BOOST_FUSION_ADAPT_ADT( + mapnik::feature_impl, + (int, int, obj.id(), /**/) + (mapnik::geometry::geometryconst&, mapnik::geometry::geometry const&, obj.get_geometry(),/**/) + (mapnik::kv_store const, mapnik::kv_store const, mapnik::kv_store(obj), /**/)) + namespace mapnik { namespace json { +namespace detail { +template +#if BOOST_VERSION >= 107000 +struct attribute_type { using type = T();}; +#else +struct attribute_type { using type = T const&();}; +#endif +} namespace karma = boost::spirit::karma; -template -struct get_id -{ - using feature_type = T; - using result_type = mapnik::value_integer; - result_type operator() (feature_type const& f) const - { - return f.id(); - } -}; - -struct extract_geometry -{ - using result_type = mapnik::geometry::geometry const&; - template - result_type operator() (T const& f) const - { - return f.get_geometry(); - } -}; - template struct feature_generator_grammar : - karma::grammar + karma::grammar::type> { feature_generator_grammar(); - karma::rule feature; - geometry_generator_grammar > geometry; - properties_generator_grammar properties; - boost::phoenix::function > id_; - boost::phoenix::function geom_; + karma::rule::type> feature; + geometry_generator_grammar> geometry; + properties_generator_grammar properties; }; }} diff --git a/include/mapnik/json/feature_generator_grammar_impl.hpp b/include/mapnik/json/feature_generator_grammar_impl.hpp index baf4be853..fd65e7320 100644 --- a/include/mapnik/json/feature_generator_grammar_impl.hpp +++ b/include/mapnik/json/feature_generator_grammar_impl.hpp @@ -29,13 +29,11 @@ feature_generator_grammar::feature_generator_gramma : feature_generator_grammar::base_type(feature) { boost::spirit::karma::lit_type lit; - boost::spirit::karma::uint_type uint_; - boost::spirit::karma::_val_type _val; - boost::spirit::karma::_1_type _1; + boost::spirit::karma::int_type int_; - feature = lit("{\"type\":\"Feature\",\"id\":") - << uint_[_1 = id_(_val)] - << lit(",\"geometry\":") << geometry[_1 = geom_(_val)] + feature = lit("{\"type\":\"Feature\"") + << lit(",\"id\":") << int_ + << lit(",\"geometry\":") << geometry << lit(",\"properties\":") << properties << lit('}') ; diff --git a/include/mapnik/json/properties_generator_grammar.hpp b/include/mapnik/json/properties_generator_grammar.hpp index 69145b8ab..3aaeb0d23 100644 --- a/include/mapnik/json/properties_generator_grammar.hpp +++ b/include/mapnik/json/properties_generator_grammar.hpp @@ -30,6 +30,7 @@ #include #include #include +#include #pragma GCC diagnostic pop #include @@ -50,7 +51,7 @@ struct escaped_string struct extract_string { - using result_type = std::tuple; + using result_type = std::tuple; result_type operator() (mapnik::value const& val) const { @@ -60,19 +61,17 @@ struct extract_string }; template -struct properties_generator_grammar : karma::grammar +struct properties_generator_grammar : karma::grammar { using pair_type = std::tuple; properties_generator_grammar(); // rules - karma::rule properties; + karma::rule properties; karma::rule pair; karma::rule()> value; - karma::rule value_null_; - karma::rule ustring; + // escaped_string escaped_string_; - typename karma::int_generator int__; boost::phoenix::function extract_string_; std::string quote_; }; diff --git a/include/mapnik/json/properties_generator_grammar_impl.hpp b/include/mapnik/json/properties_generator_grammar_impl.hpp index 8f694f6ca..a81c75fa4 100644 --- a/include/mapnik/json/properties_generator_grammar_impl.hpp +++ b/include/mapnik/json/properties_generator_grammar_impl.hpp @@ -69,6 +69,7 @@ properties_generator_grammar::properties_generator boost::spirit::karma::string_type kstring; boost::spirit::karma::eps_type eps; using boost::phoenix::at_c; + properties = lit('{') << -(pair % lit(',')) << lit('}') @@ -84,7 +85,6 @@ properties_generator_grammar::properties_generator | kstring[_1 = at_c<0>(_val)] ; - } }} diff --git a/include/mapnik/util/spirit_transform_attribute.hpp b/include/mapnik/util/spirit_transform_attribute.hpp deleted file mode 100644 index c4176f1fa..000000000 --- a/include/mapnik/util/spirit_transform_attribute.hpp +++ /dev/null @@ -1,216 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2015 Artem Pavlenko - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - *****************************************************************************/ - -#ifndef MAPNIK_UTIL_SPIRIT_TRANSFORM_ATTRIBUTE_HPP -#define MAPNIK_UTIL_SPIRIT_TRANSFORM_ATTRIBUTE_HPP - -#include -#include - -#include - -#pragma GCC diagnostic push -#include -#include -#pragma GCC diagnostic pop - -namespace boost { namespace spirit { namespace traits { - - template <> - struct transform_attribute const, - mapnik::geometry::point const&, karma::domain> - { - using type = mapnik::geometry::point const&; - static type pre(mapnik::geometry::geometry const& geom) - { - return mapnik::util::get >(geom); - } - }; - - template <> - struct transform_attribute const, - mapnik::geometry::line_string const&, karma::domain> - { - using type = mapnik::geometry::line_string const&; - static type pre(mapnik::geometry::geometry const& geom) - { - return mapnik::util::get >(geom); - } - }; - - template <> - struct transform_attribute const, - mapnik::geometry::polygon const&, karma::domain> - { - using type = mapnik::geometry::polygon const&; - static type pre(mapnik::geometry::geometry const& geom) - { - return mapnik::util::get >(geom); - } - }; - - template <> - struct transform_attribute const, - mapnik::geometry::polygon::rings_container const&, karma::domain> - { - using type = mapnik::geometry::polygon::rings_container const&; - static type pre(mapnik::geometry::polygon const& poly) - { - return poly.interior_rings; - } - }; - - template <> - struct transform_attribute const, - mapnik::geometry::multi_point const&, karma::domain> - { - using type = mapnik::geometry::multi_point const&; - static type pre(mapnik::geometry::geometry const& geom) - { - return mapnik::util::get >(geom); - } - }; - - template <> - struct transform_attribute const, - mapnik::geometry::multi_line_string const&, karma::domain> - { - using type = mapnik::geometry::multi_line_string const&; - static type pre(mapnik::geometry::geometry const& geom) - { - return mapnik::util::get >(geom); - } - }; - - template <> - struct transform_attribute const, - mapnik::geometry::multi_polygon const&, karma::domain> - { - using type = mapnik::geometry::multi_polygon const&; - static type pre(mapnik::geometry::geometry const& geom) - { - return mapnik::util::get >(geom); - } - }; - - template <> - struct transform_attribute const, - mapnik::geometry::geometry_collection const&, karma::domain> - { - using type = mapnik::geometry::geometry_collection const&; - static type pre(mapnik::geometry::geometry const& geom) - { - return mapnik::util::get >(geom); - } - }; - - template <> - struct transform_attribute const, - mapnik::geometry::point const&, karma::domain> - { - using type = mapnik::geometry::point const&; - static type pre(mapnik::geometry::geometry const& geom) - { - return mapnik::util::get >(geom); - } - }; - - template <> - struct transform_attribute const, - mapnik::geometry::line_string const&, karma::domain> - { - using type = mapnik::geometry::line_string const&; - static type pre(mapnik::geometry::geometry const& geom) - { - return mapnik::util::get >(geom); - } - }; - - template <> - struct transform_attribute const, - mapnik::geometry::polygon const&, karma::domain> - { - using type = mapnik::geometry::polygon const&; - static type pre(mapnik::geometry::geometry const& geom) - { - return mapnik::util::get >(geom); - } - }; - - template <> - struct transform_attribute const, - mapnik::geometry::polygon::rings_container const&, karma::domain> - { - using type = mapnik::geometry::polygon::rings_container const&; - static type pre(mapnik::geometry::polygon const& poly) - { - return poly.interior_rings; - } - }; - - template <> - struct transform_attribute const, - mapnik::geometry::multi_point const&, karma::domain> - { - using type = mapnik::geometry::multi_point const&; - static type pre(mapnik::geometry::geometry const& geom) - { - return mapnik::util::get >(geom); - } - }; - - template <> - struct transform_attribute const, - mapnik::geometry::multi_line_string const&, karma::domain> - { - using type = mapnik::geometry::multi_line_string const&; - static type pre(mapnik::geometry::geometry const& geom) - { - return mapnik::util::get >(geom); - } - }; - - template <> - struct transform_attribute const, - mapnik::geometry::multi_polygon const&, karma::domain> - { - using type = mapnik::geometry::multi_polygon const&; - static type pre(mapnik::geometry::geometry const& geom) - { - return mapnik::util::get >(geom); - } - }; - - template <> - struct transform_attribute const, - mapnik::geometry::geometry_collection const&, karma::domain> - { - using type = mapnik::geometry::geometry_collection const&; - static type pre(mapnik::geometry::geometry const& geom) - { - return mapnik::util::get >(geom); - } - }; - -}}} - -#endif // MAPNIK_UTIL_SPIRIT_TRANSFORM_ATTRIBUTE_HPP diff --git a/include/mapnik/wkt/wkt_factory.hpp b/include/mapnik/wkt/wkt_factory.hpp index 14f509dda..01569d6da 100644 --- a/include/mapnik/wkt/wkt_factory.hpp +++ b/include/mapnik/wkt/wkt_factory.hpp @@ -23,6 +23,8 @@ #ifndef MAPNIK_WKT_FACTORY_HPP #define MAPNIK_WKT_FACTORY_HPP +#include + // mapnik #include diff --git a/src/json/mapnik_json_generator_grammar.cpp b/src/json/mapnik_json_generator_grammar.cpp index 72a1a74c9..b5aeecc94 100644 --- a/src/json/mapnik_json_generator_grammar.cpp +++ b/src/json/mapnik_json_generator_grammar.cpp @@ -29,6 +29,6 @@ using sink_type = std::back_insert_iterator; -template struct mapnik::json::properties_generator_grammar; +template struct mapnik::json::properties_generator_grammar; template struct mapnik::json::feature_generator_grammar; template struct mapnik::json::geometry_generator_grammar >; diff --git a/src/tiff_reader.cpp b/src/tiff_reader.cpp index 65850e4c7..dd1d5de76 100644 --- a/src/tiff_reader.cpp +++ b/src/tiff_reader.cpp @@ -41,6 +41,7 @@ extern "C" // stl #include #include +#include namespace mapnik { namespace detail {