diff --git a/include/mapnik/box2d.hpp b/include/mapnik/box2d.hpp index 267120111..c6c794c83 100644 --- a/include/mapnik/box2d.hpp +++ b/include/mapnik/box2d.hpp @@ -51,11 +51,11 @@ template class MAPNIK_DECL box2d public: using value_type = T; using box2d_type = box2d; -private: T minx_; T miny_; T maxx_; T maxy_; +private: friend inline void swap(box2d_type & lhs, box2d_type & rhs) { using std::swap; diff --git a/include/mapnik/box2d_impl.hpp b/include/mapnik/box2d_impl.hpp index 7f3e9d1e7..3d98cd03e 100644 --- a/include/mapnik/box2d_impl.hpp +++ b/include/mapnik/box2d_impl.hpp @@ -33,24 +33,30 @@ #pragma GCC diagnostic push #include -#include -#include -#include +#include +#include #pragma GCC diagnostic pop // agg #include "agg_trans_affine.h" -BOOST_FUSION_ADAPT_TPL_ADT( +BOOST_FUSION_ADAPT_TPL_STRUCT( (T), (mapnik::box2d)(T), - (T, T, obj.minx(), obj.set_minx(mapnik::safe_cast(val))) - (T, T, obj.miny(), obj.set_miny(mapnik::safe_cast(val))) - (T, T, obj.maxx(), obj.set_maxx(mapnik::safe_cast(val))) - (T, T, obj.maxy(), obj.set_maxy(mapnik::safe_cast(val)))) + (T, minx_), + (T, miny_), + (T, maxx_), + (T, maxy_)) + +namespace mapnik { + +namespace detail { +auto minx = [](auto& ctx) { _val(ctx) = _attr(ctx); }; +auto miny = [](auto& ctx) { _val(ctx) = _attr(ctx); }; +auto maxx = [](auto& ctx) { _val(ctx) = _attr(ctx); }; +auto maxy = [](auto& ctx) { _val(ctx) = _attr(ctx); }; +} -namespace mapnik -{ template box2d::box2d() :minx_( std::numeric_limits::max()), @@ -61,13 +67,13 @@ box2d::box2d() template box2d::box2d(T minx,T miny,T maxx,T maxy) { - init(minx,miny,maxx,maxy); + init(minx, miny, maxx, maxy); } template box2d::box2d(coord const& c0, coord const& c1) { - init(c0.x,c0.y,c1.x,c1.y); + init(c0.x, c0.y, c1.x, c1.y); } template @@ -350,12 +356,15 @@ void box2d::pad(T padding) template bool box2d::from_string(std::string const& str) { - boost::spirit::qi::lit_type lit; - boost::spirit::qi::double_type double_; - boost::spirit::ascii::space_type space; - bool r = boost::spirit::qi::phrase_parse(str.begin(), + using boost::spirit::x3::lit; + boost::spirit::x3::double_type double_; + boost::spirit::x3::ascii::space_type space; + bool r = boost::spirit::x3::phrase_parse(str.begin(), str.end(), - double_ >> -lit(',') >> double_ >> -lit(',') >> double_ >> -lit(',') >> double_, + double_[detail::minx] >> -lit(',') >> + double_[detail::miny] >> -lit(',') >> + double_[detail::maxx] >> -lit(',') >> + double_[detail::maxy], space, *this); return r;