From 80c54521303b7802c41c9beab9998c680b05dc7d Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 23 Apr 2013 14:00:08 +0100 Subject: [PATCH] + fix phoenix functions to compile on ubuntu 12.04/c++11 + cleanups --- include/mapnik/css_color_grammar.hpp | 28 +- include/mapnik/css_color_grammar_def.hpp | 2 - include/mapnik/expression_grammar.hpp | 23 +- include/mapnik/json/feature_grammar.hpp | 22 +- .../json/geometry_generator_grammar.hpp | 20 +- include/mapnik/json/geometry_grammar.hpp | 25 +- .../mapnik/util/geometry_svg_generator.hpp | 13 +- include/mapnik/wkt/wkt_grammar.hpp | 275 +++++++++--------- 8 files changed, 169 insertions(+), 239 deletions(-) diff --git a/include/mapnik/css_color_grammar.hpp b/include/mapnik/css_color_grammar.hpp index 51d498428..8778d8e10 100644 --- a/include/mapnik/css_color_grammar.hpp +++ b/include/mapnik/css_color_grammar.hpp @@ -23,11 +23,11 @@ #ifndef MAPNIK_CSS_COLOR_GRAMMAR_HPP #define MAPNIK_CSS_COLOR_GRAMMAR_HPP -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 - // mapnik #include +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + // spirit2 #include #include @@ -99,13 +99,9 @@ inline int clip_int(int val) struct percent_conv_impl { - template - struct result - { - typedef unsigned type; - }; + typedef unsigned result_type; - unsigned operator() (double val) const + result_type operator() (double val) const { return clip_int<0,255>(int((255.0 * val)/100.0 + 0.5)); } @@ -113,13 +109,9 @@ struct percent_conv_impl struct alpha_conv_impl { - template - struct result - { - typedef unsigned type; - }; + typedef unsigned result_type; - unsigned operator() (double val) const + result_type operator() (double val) const { return clip_int<0,255>(int((255.0 * val) + 0.5)); } @@ -127,14 +119,10 @@ struct alpha_conv_impl struct hsl_conv_impl { - template - struct result - { - typedef void type; - }; + typedef void result_type; template - void operator() (T0 & c, T1 h, T2 s, T3 l) const + result_type operator() (T0 & c, T1 h, T2 s, T3 l) const { double m1,m2; // normalize values diff --git a/include/mapnik/css_color_grammar_def.hpp b/include/mapnik/css_color_grammar_def.hpp index 57768e895..028411ba1 100644 --- a/include/mapnik/css_color_grammar_def.hpp +++ b/include/mapnik/css_color_grammar_def.hpp @@ -23,8 +23,6 @@ #ifndef MAPNIK_CSS_COLOR_GRAMMAR_DEF_HPP #define MAPNIK_CSS_COLOR_GRAMMAR_DEF_HPP -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 - // boost #include diff --git a/include/mapnik/expression_grammar.hpp b/include/mapnik/expression_grammar.hpp index 50ac37ded..8b82e53fb 100644 --- a/include/mapnik/expression_grammar.hpp +++ b/include/mapnik/expression_grammar.hpp @@ -47,11 +47,7 @@ using standard_wide::space_type; struct unicode_impl { - template - struct result - { - typedef UnicodeString type; - }; + typedef UnicodeString result_type; explicit unicode_impl(mapnik::transcoder const& tr) : tr_(tr) {} @@ -66,34 +62,27 @@ struct unicode_impl struct regex_match_impl { - template - struct result - { - typedef expr_node type; - }; + + typedef expr_node result_type; explicit regex_match_impl(mapnik::transcoder const& tr) : tr_(tr) {} template - expr_node operator() (T0 & node, T1 const& pattern) const; + result_type operator() (T0 & node, T1 const& pattern) const; mapnik::transcoder const& tr_; }; struct regex_replace_impl { - template - struct result - { - typedef expr_node type; - }; + typedef expr_node result_type; explicit regex_replace_impl(mapnik::transcoder const& tr) : tr_(tr) {} template - expr_node operator() (T0 & node, T1 const& pattern, T2 const& format) const; + result_type operator() (T0 & node, T1 const& pattern, T2 const& format) const; mapnik::transcoder const& tr_; }; diff --git a/include/mapnik/json/feature_grammar.hpp b/include/mapnik/json/feature_grammar.hpp index 84b6926ae..780dc34ba 100644 --- a/include/mapnik/json/feature_grammar.hpp +++ b/include/mapnik/json/feature_grammar.hpp @@ -69,16 +69,14 @@ public: struct put_property { - template - struct result - { - typedef void type; - }; + + typedef void result_type; + explicit put_property(mapnik::transcoder const& tr) : tr_(tr) {} template - void operator() (T0 & feature, T1 const& key, T2 const& val) const + result_type operator() (T0 & feature, T1 const& key, T2 const& val) const { mapnik::value v = boost::apply_visitor(attribute_value_visitor(tr_),val); // TODO: optimize feature.put_new(key, v); @@ -89,14 +87,10 @@ struct put_property struct extract_geometry { - template - struct result - { - typedef boost::ptr_vector& type; - }; + typedef boost::ptr_vector& result_type; template - boost::ptr_vector& operator() (T & feature) const + result_type operator() (T & feature) const { return feature.paths(); } @@ -104,8 +98,8 @@ struct extract_geometry template struct feature_grammar : - qi::grammar + qi::grammar { feature_grammar(mapnik::transcoder const& tr); diff --git a/include/mapnik/json/geometry_generator_grammar.hpp b/include/mapnik/json/geometry_generator_grammar.hpp index c653e37b2..dbd8e6a17 100644 --- a/include/mapnik/json/geometry_generator_grammar.hpp +++ b/include/mapnik/json/geometry_generator_grammar.hpp @@ -60,10 +60,8 @@ namespace { struct get_type { - template - struct result { typedef int type; }; - - int operator() (geometry_type const& geom) const + typedef int result_type; + result_type operator() (geometry_type const& geom) const { return static_cast(geom.type()); } @@ -71,10 +69,8 @@ struct get_type struct get_first { - template - struct result { typedef geometry_type::value_type const type; }; - - geometry_type::value_type const operator() (geometry_type const& geom) const + typedef geometry_type::value_type const result_type; + result_type operator() (geometry_type const& geom) const { geometry_type::value_type coord; boost::get<0>(coord) = geom.vertex(0,&boost::get<1>(coord),&boost::get<2>(coord)); @@ -84,10 +80,8 @@ struct get_first struct multi_geometry_type { - template - struct result { typedef boost::tuple type; }; - - boost::tuple operator() (geometry_container const& geom) const + typedef boost::tuple result_type; + result_type operator() (geometry_container const& geom) const { unsigned type = 0u; bool collection = false; @@ -132,7 +126,7 @@ struct json_coordinate_policy : karma::real_policies template static bool fraction_part(OutputIterator& sink, T n - , unsigned adjprec, unsigned precision) + , unsigned adjprec, unsigned precision) { if (n == 0) return true; return base_type::fraction_part(sink, n, adjprec, precision); diff --git a/include/mapnik/json/geometry_grammar.hpp b/include/mapnik/json/geometry_grammar.hpp index 308f0048a..42e3fe92f 100644 --- a/include/mapnik/json/geometry_grammar.hpp +++ b/include/mapnik/json/geometry_grammar.hpp @@ -41,14 +41,10 @@ using standard_wide::space_type; struct push_vertex { - template - struct result - { - typedef void type; - }; + typedef void result_type; template - void operator() (T0 c, T1 path, T2 x, T3 y) const + result_type operator() (T0 c, T1 path, T2 x, T3 y) const { BOOST_ASSERT( path!=0 ); path->push_vertex(x,y,c); @@ -57,14 +53,10 @@ struct push_vertex struct close_path { - template - struct result - { - typedef void type; - }; + typedef void result_type; template - void operator() (T path) const + result_type operator() (T path) const { BOOST_ASSERT( path!=0 ); path->close_path(); @@ -73,12 +65,7 @@ struct close_path struct cleanup { - template - struct result - { - typedef void type; - }; - + typedef void result_type; template void operator() (T0 & path) const { @@ -89,7 +76,7 @@ struct cleanup template struct geometry_grammar : qi::grammar, void(boost::ptr_vector& ) - , space_type> + , space_type> { geometry_grammar(); qi::rule, void(boost::ptr_vector& ),space_type> geometry; diff --git a/include/mapnik/util/geometry_svg_generator.hpp b/include/mapnik/util/geometry_svg_generator.hpp index e8b31954b..a818a423b 100644 --- a/include/mapnik/util/geometry_svg_generator.hpp +++ b/include/mapnik/util/geometry_svg_generator.hpp @@ -96,10 +96,8 @@ namespace mapnik { namespace util { template struct get_type { - template - struct result { typedef int type; }; - - int operator() (Geometry const& geom) const + typedef int result_type; + result_type operator() (Geometry const& geom) const { return static_cast(geom.type()); } @@ -109,11 +107,8 @@ namespace mapnik { namespace util { struct get_first { typedef T geometry_type; - - template - struct result { typedef typename geometry_type::value_type const type; }; - - typename geometry_type::value_type const operator() (geometry_type const& geom) const + typedef typename geometry_type::value_type const result_type; + result_type const operator() (geometry_type const& geom) const { typename geometry_type::value_type coord; geom.rewind(0); diff --git a/include/mapnik/wkt/wkt_grammar.hpp b/include/mapnik/wkt/wkt_grammar.hpp index 1d09cda62..b657cb90e 100644 --- a/include/mapnik/wkt/wkt_grammar.hpp +++ b/include/mapnik/wkt/wkt_grammar.hpp @@ -41,179 +41,164 @@ namespace mapnik { namespace wkt { - using namespace boost::spirit; - using namespace boost::fusion; - using namespace boost::phoenix; +using namespace boost::spirit; +using namespace boost::fusion; +using namespace boost::phoenix; - struct push_vertex +struct push_vertex +{ + typedef void result_type; + template + result_type operator() (T0 c, T1 path, T2 x, T3 y) const { - template - struct result - { - typedef void type; - }; + BOOST_ASSERT( path!=0 ); + path->push_vertex(x,y,c); + } +}; - template - void operator() (T0 c, T1 path, T2 x, T3 y) const - { - BOOST_ASSERT( path!=0 ); - path->push_vertex(x,y,c); - } - }; - - struct close_path +struct close_path +{ + typedef void result_type; + template + result_type operator() (T path) const { - template - struct result - { - typedef void type; - }; + BOOST_ASSERT( path!=0 ); + path->close_path(); + } +}; - template - void operator() (T path) const - { - BOOST_ASSERT( path!=0 ); - path->close_path(); - } - }; - - struct cleanup +struct cleanup +{ + typedef void result_type; + template + void operator() (T0 & path) const { - template - struct result - { - typedef void type; - }; + if (path) delete path,path=0; + } +}; - template - void operator() (T0 & path) const - { - if (path) delete path,path=0; - } - }; - - template - struct wkt_grammar : qi::grammar() , ascii::space_type> +template +struct wkt_grammar : qi::grammar() , ascii::space_type> +{ + wkt_grammar() + : wkt_grammar::base_type(geometry_tagged_text) { - wkt_grammar() - : wkt_grammar::base_type(geometry_tagged_text) - { - using qi::no_case; - using qi::_1; - using qi::_2; - using boost::phoenix::push_back; + using qi::no_case; + using qi::_1; + using qi::_2; + using boost::phoenix::push_back; - geometry_tagged_text = point_tagged_text - | linestring_tagged_text - | polygon_tagged_text - | multipoint_tagged_text - | multilinestring_tagged_text - | multipolygon_tagged_text - ; + geometry_tagged_text = point_tagged_text + | linestring_tagged_text + | polygon_tagged_text + | multipoint_tagged_text + | multilinestring_tagged_text + | multipolygon_tagged_text + ; - // ::= point - point_tagged_text = no_case[lit("POINT")] [ _a = new_(Point) ] - >> ( point_text(_a) [push_back(_val,_a)] - | eps[cleanup_(_a)][_pass = false]) - ; + // ::= point + point_tagged_text = no_case[lit("POINT")] [ _a = new_(Point) ] + >> ( point_text(_a) [push_back(_val,_a)] + | eps[cleanup_(_a)][_pass = false]) + ; - // ::= | - point_text = (lit("(") >> point(SEG_MOVETO,_r1) >> lit(')')) - | empty_set - ; + // ::= | + point_text = (lit("(") >> point(SEG_MOVETO,_r1) >> lit(')')) + | empty_set + ; - // ::= linestring - linestring_tagged_text = no_case[lit("LINESTRING")] [ _a = new_(LineString) ] - >> (linestring_text(_a)[push_back(_val,_a)] - | eps[cleanup_(_a)][_pass = false]) - ; + // ::= linestring + linestring_tagged_text = no_case[lit("LINESTRING")] [ _a = new_(LineString) ] + >> (linestring_text(_a)[push_back(_val,_a)] + | eps[cleanup_(_a)][_pass = false]) + ; - // ::= | { }* - linestring_text = points(_r1) | empty_set - ; + // ::= | { }* + linestring_text = points(_r1) | empty_set + ; - // ::= polygon - polygon_tagged_text = no_case[lit("POLYGON")] [ _a = new_(Polygon) ] - >> ( polygon_text(_a)[push_back(_val,_a)] - | eps[cleanup_(_a)][_pass = false]) - ; + // ::= polygon + polygon_tagged_text = no_case[lit("POLYGON")] [ _a = new_(Polygon) ] + >> ( polygon_text(_a)[push_back(_val,_a)] + | eps[cleanup_(_a)][_pass = false]) + ; - // ::= | { }* - polygon_text = (lit('(') >> linestring_text(_r1)[close_path_(_r1)] % lit(',') >> lit(')')) | empty_set; + // ::= | { }* + polygon_text = (lit('(') >> linestring_text(_r1)[close_path_(_r1)] % lit(',') >> lit(')')) | empty_set; - // ::= multipoint - multipoint_tagged_text = no_case[lit("MULTIPOINT")] - >> multipoint_text - ; + // ::= multipoint + multipoint_tagged_text = no_case[lit("MULTIPOINT")] + >> multipoint_text + ; - // ::= | { }* - multipoint_text = (lit('(') - >> ((eps[_a = new_(Point)] - >> (point_text(_a) | empty_set) [push_back(_val,_a)] - | eps[cleanup_(_a)][_pass = false]) % lit(',')) - >> lit(')')) | empty_set - ; + // ::= | { }* + multipoint_text = (lit('(') + >> ((eps[_a = new_(Point)] + >> (point_text(_a) | empty_set) [push_back(_val,_a)] + | eps[cleanup_(_a)][_pass = false]) % lit(',')) + >> lit(')')) | empty_set + ; - // ::= multilinestring - multilinestring_tagged_text = no_case[lit("MULTILINESTRING")] - >> multilinestring_text ; + // ::= multilinestring + multilinestring_tagged_text = no_case[lit("MULTILINESTRING")] + >> multilinestring_text ; - // ::= | { }* - multilinestring_text = (lit('(') - >> ((eps[_a = new_(LineString)] - >> ( points(_a)[push_back(_val,_a)] - | eps[cleanup_(_a)][_pass = false])) - % lit(',')) - >> lit(')')) | empty_set; + // ::= | { }* + multilinestring_text = (lit('(') + >> ((eps[_a = new_(LineString)] + >> ( points(_a)[push_back(_val,_a)] + | eps[cleanup_(_a)][_pass = false])) + % lit(',')) + >> lit(')')) | empty_set; - // ::= multipolygon - multipolygon_tagged_text = no_case[lit("MULTIPOLYGON")] - >> multipolygon_text ; + // ::= multipolygon + multipolygon_tagged_text = no_case[lit("MULTIPOLYGON")] + >> multipolygon_text ; - // ::= | { }* + // ::= | { }* - multipolygon_text = (lit('(') - >> ((eps[_a = new_(Polygon)] - >> ( polygon_text(_a)[push_back(_val,_a)] - | eps[cleanup_(_a)][_pass = false])) - % lit(',')) - >> lit(')')) | empty_set; + multipolygon_text = (lit('(') + >> ((eps[_a = new_(Polygon)] + >> ( polygon_text(_a)[push_back(_val,_a)] + | eps[cleanup_(_a)][_pass = false])) + % lit(',')) + >> lit(')')) | empty_set; - // points - points = lit('(')[_a = SEG_MOVETO] >> point (_a,_r1) % lit(',') [_a = SEG_LINETO] >> lit(')'); - // point - point = (double_ >> double_) [push_vertex_(_r1,_r2,_1,_2)]; + // points + points = lit('(')[_a = SEG_MOVETO] >> point (_a,_r1) % lit(',') [_a = SEG_LINETO] >> lit(')'); + // point + point = (double_ >> double_) [push_vertex_(_r1,_r2,_1,_2)]; - // - empty_set = no_case[lit("EMPTY")]; + // + empty_set = no_case[lit("EMPTY")]; - } + } - // start - qi::rule(),ascii::space_type> geometry_tagged_text; + // start + qi::rule(),ascii::space_type> geometry_tagged_text; - qi::rule,boost::ptr_vector(),ascii::space_type> point_tagged_text; - qi::rule,boost::ptr_vector(),ascii::space_type> linestring_tagged_text; - qi::rule,boost::ptr_vector(),ascii::space_type> polygon_tagged_text; - qi::rule(),ascii::space_type> multipoint_tagged_text; - qi::rule(),ascii::space_type> multilinestring_tagged_text; - qi::rule(),ascii::space_type> multipolygon_tagged_text; - // - qi::rule point_text; - qi::rule linestring_text; - qi::rule polygon_text; - qi::rule, boost::ptr_vector(),ascii::space_type> multipoint_text; - qi::rule, boost::ptr_vector(),ascii::space_type> multilinestring_text; - qi::rule, boost::ptr_vector(),ascii::space_type> multipolygon_text; - // - qi::rule point; - qi::rule,void(geometry_type*),ascii::space_type> points; - qi::rule empty_set; - boost::phoenix::function push_vertex_; - boost::phoenix::function close_path_; - boost::phoenix::function cleanup_; - }; + qi::rule,boost::ptr_vector(),ascii::space_type> point_tagged_text; + qi::rule,boost::ptr_vector(),ascii::space_type> linestring_tagged_text; + qi::rule,boost::ptr_vector(),ascii::space_type> polygon_tagged_text; + qi::rule(),ascii::space_type> multipoint_tagged_text; + qi::rule(),ascii::space_type> multilinestring_tagged_text; + qi::rule(),ascii::space_type> multipolygon_tagged_text; + // + qi::rule point_text; + qi::rule linestring_text; + qi::rule polygon_text; + qi::rule, boost::ptr_vector(),ascii::space_type> multipoint_text; + qi::rule, boost::ptr_vector(),ascii::space_type> multilinestring_text; + qi::rule, boost::ptr_vector(),ascii::space_type> multipolygon_text; + // + qi::rule point; + qi::rule,void(geometry_type*),ascii::space_type> points; + qi::rule empty_set; + boost::phoenix::function push_vertex_; + boost::phoenix::function close_path_; + boost::phoenix::function cleanup_; +}; template