support stacked (multiple) image filters with < boost 1.47 #1210

Closed
springmeyer opened this Issue May 11, 2012 · 4 comments

Projects

None yet

2 participants

Owner

I tried a variety of alternative syntaxes to try to get the compile going (c9bedf8 | #1209) with boost 1.42-1.46 including -(filter % *char_("; ")), -(filter >> *char_("; ")), -(filter >> *(lit';')) etc (and using lexeme) but nothing seems to work. You'll get various errors about 2 args supplied, zero expected.

@springmeyer springmeyer pushed a commit that referenced this issue May 15, 2012
Dane Springmeyer only use skipping if >= boost 1.47 - corrects #1209 (refs #1210) 8f79641
Owner

likely going to punt on this and just package more recent boost versions as per mapnik/mapnik-packaging#48

Contributor

the spirit propagation rule is a: A, b: unused -> (a % b): vector<A>
therefore to make (filter % separator) construct vector<filter_type> values, filter must construct filter_type values

I think you were already half-way to solution in 3d89e40 -- when writing another grammar I faced a problem with boost::spirit::traits::clear, which requires that each value_type in a variant be default-constructible -- nevermind, back on topic:

diff --git a/include/mapnik/image_filter_parser.hpp b/include/mapnik/image_filter_parser.hpp
index 2192c96..ccb7c34 100644
--- a/include/mapnik/image_filter_parser.hpp
+++ b/include/mapnik/image_filter_parser.hpp
@@ -47,47 +47,43 @@ struct image_filter_grammar :
         using qi::_b;
         using qi::eps;
         using qi::char_;
+        using qi::no_skip;
         using phoenix::push_back;
         using phoenix::construct;

-#if BOOST_VERSION >= 104700
-        using qi::no_skip;
         start = -(filter % no_skip[*char_("; ")])
             ;
-#else
-        start = -(filter)
-            ;
-#endif

         filter = 
-            lit("emboss")[push_back(_val,construct<mapnik::filter::emboss>())]
+            lit("emboss")[_val = construct<mapnik::filter::emboss>()]
             |
-            lit("blur")[push_back(_val,construct<mapnik::filter::blur>())]
+            lit("blur")[_val = construct<mapnik::filter::blur>()]
             |
-            lit("gray")[push_back(_val,construct<mapnik::filter::gray>())]
+            lit("gray")[_val = construct<mapnik::filter::gray>()]
             |
-            lit("edge-detect")[push_back(_val,construct<mapnik::filter::edge_detect>())]
+            lit("edge-detect")[_val = construct<mapnik::filter::edge_detect>()]
             |
-            lit("sobel")[push_back(_val,construct<mapnik::filter::sobel>())]
+            lit("sobel")[_val = construct<mapnik::filter::sobel>()]
             |
-            lit("sharpen")[push_back(_val,construct<mapnik::filter::sharpen>())]
+            lit("sharpen")[_val = construct<mapnik::filter::sharpen>()]
             |
-            lit("x-gradient")[push_back(_val,construct<mapnik::filter::x_gradient>())]
+            lit("x-gradient")[_val = construct<mapnik::filter::x_gradient>()]
             |
-            lit("y-gradient")[push_back(_val,construct<mapnik::filter::y_gradient>())]
+            lit("y-gradient")[_val = construct<mapnik::filter::y_gradient>()]
             |
             (lit("agg-stack-blur")[_a = 1, _b = 1] 
              >> -( lit(':') >> lit("rx") >> lit('=') >> radius_[_a = _1] 
                    >> lit(',') 
                    >> lit("ry") >> lit('=') >> radius_[_b = _1])             
-             [push_back(_val,construct<mapnik::filter::agg_stack_blur>(_a,_b))])
+             [_val = (construct<mapnik::filter::agg_stack_blur>(_a,_b))])
             |
-            lit("invert")[push_back(_val,construct<mapnik::filter::invert>())]
+            lit("invert")[_val = construct<mapnik::filter::invert>()]
             ;
     }
     //  
+    typedef mapnik::filter::filter_type filter_type;
     qi::rule<Iterator, ContType(), qi::ascii::space_type> start;
-    qi::rule<Iterator, ContType(), qi::locals<int,int>, qi::ascii::space_type> filter;
+    qi::rule<Iterator, filter_type, qi::locals<int,int>, qi::ascii::space_type> filter;
     qi::uint_parser< unsigned, 10, 1, 3 > radius_;
 };

compiles with boost 1.46.1
didn't check any other boost version, nor whether it actually works

Owner

thanks! we'll take a look

Owner

no longer needed to support older boost, closing.

@springmeyer springmeyer added this to the Mapnik 3.x milestone Jun 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment