+ fix phoenix functions to compile on ubuntu 12.04/c++11

+ cleanups
This commit is contained in:
artemp 2013-04-23 14:00:08 +01:00
parent 2b9ce83226
commit 80c5452130
8 changed files with 169 additions and 239 deletions

View file

@ -23,11 +23,11 @@
#ifndef MAPNIK_CSS_COLOR_GRAMMAR_HPP #ifndef MAPNIK_CSS_COLOR_GRAMMAR_HPP
#define MAPNIK_CSS_COLOR_GRAMMAR_HPP #define MAPNIK_CSS_COLOR_GRAMMAR_HPP
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
// mapnik // mapnik
#include <mapnik/color.hpp> #include <mapnik/color.hpp>
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
// spirit2 // spirit2
#include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/qi_action.hpp> #include <boost/spirit/include/qi_action.hpp>
@ -99,13 +99,9 @@ inline int clip_int(int val)
struct percent_conv_impl struct percent_conv_impl
{ {
template <typename T> typedef unsigned result_type;
struct result
{
typedef unsigned 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)); 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 struct alpha_conv_impl
{ {
template <typename T> typedef unsigned result_type;
struct result
{
typedef unsigned type;
};
unsigned operator() (double val) const result_type operator() (double val) const
{ {
return clip_int<0,255>(int((255.0 * val) + 0.5)); return clip_int<0,255>(int((255.0 * val) + 0.5));
} }
@ -127,14 +119,10 @@ struct alpha_conv_impl
struct hsl_conv_impl struct hsl_conv_impl
{ {
template<typename T0,typename T1, typename T2, typename T3> typedef void result_type;
struct result
{
typedef void type;
};
template <typename T0,typename T1, typename T2, typename T3> template <typename T0,typename T1, typename T2, typename T3>
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; double m1,m2;
// normalize values // normalize values

View file

@ -23,8 +23,6 @@
#ifndef MAPNIK_CSS_COLOR_GRAMMAR_DEF_HPP #ifndef MAPNIK_CSS_COLOR_GRAMMAR_DEF_HPP
#define MAPNIK_CSS_COLOR_GRAMMAR_DEF_HPP #define MAPNIK_CSS_COLOR_GRAMMAR_DEF_HPP
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
// boost // boost
#include <boost/version.hpp> #include <boost/version.hpp>

View file

@ -47,11 +47,7 @@ using standard_wide::space_type;
struct unicode_impl struct unicode_impl
{ {
template <typename T> typedef UnicodeString result_type;
struct result
{
typedef UnicodeString type;
};
explicit unicode_impl(mapnik::transcoder const& tr) explicit unicode_impl(mapnik::transcoder const& tr)
: tr_(tr) {} : tr_(tr) {}
@ -66,34 +62,27 @@ struct unicode_impl
struct regex_match_impl struct regex_match_impl
{ {
template <typename T0, typename T1>
struct result typedef expr_node result_type;
{
typedef expr_node type;
};
explicit regex_match_impl(mapnik::transcoder const& tr) explicit regex_match_impl(mapnik::transcoder const& tr)
: tr_(tr) {} : tr_(tr) {}
template <typename T0,typename T1> template <typename T0,typename T1>
expr_node operator() (T0 & node, T1 const& pattern) const; result_type operator() (T0 & node, T1 const& pattern) const;
mapnik::transcoder const& tr_; mapnik::transcoder const& tr_;
}; };
struct regex_replace_impl struct regex_replace_impl
{ {
template <typename T0, typename T1, typename T2> typedef expr_node result_type;
struct result
{
typedef expr_node type;
};
explicit regex_replace_impl(mapnik::transcoder const& tr) explicit regex_replace_impl(mapnik::transcoder const& tr)
: tr_(tr) {} : tr_(tr) {}
template <typename T0,typename T1,typename T2> template <typename T0,typename T1,typename T2>
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_; mapnik::transcoder const& tr_;
}; };

View file

@ -69,16 +69,14 @@ public:
struct put_property struct put_property
{ {
template <typename T0,typename T1, typename T2>
struct result typedef void result_type;
{
typedef void type;
};
explicit put_property(mapnik::transcoder const& tr) explicit put_property(mapnik::transcoder const& tr)
: tr_(tr) {} : tr_(tr) {}
template <typename T0,typename T1, typename T2> template <typename T0,typename T1, typename T2>
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 mapnik::value v = boost::apply_visitor(attribute_value_visitor(tr_),val); // TODO: optimize
feature.put_new(key, v); feature.put_new(key, v);
@ -89,14 +87,10 @@ struct put_property
struct extract_geometry struct extract_geometry
{ {
template <typename T> typedef boost::ptr_vector<mapnik::geometry_type>& result_type;
struct result
{
typedef boost::ptr_vector<mapnik::geometry_type>& type;
};
template <typename T> template <typename T>
boost::ptr_vector<mapnik::geometry_type>& operator() (T & feature) const result_type operator() (T & feature) const
{ {
return feature.paths(); return feature.paths();
} }
@ -104,8 +98,8 @@ struct extract_geometry
template <typename Iterator, typename FeatureType> template <typename Iterator, typename FeatureType>
struct feature_grammar : struct feature_grammar :
qi::grammar<Iterator, void(FeatureType&), qi::grammar<Iterator, void(FeatureType&),
space_type> space_type>
{ {
feature_grammar(mapnik::transcoder const& tr); feature_grammar(mapnik::transcoder const& tr);

View file

@ -60,10 +60,8 @@ namespace {
struct get_type struct get_type
{ {
template <typename T> typedef int result_type;
struct result { typedef int type; }; result_type operator() (geometry_type const& geom) const
int operator() (geometry_type const& geom) const
{ {
return static_cast<int>(geom.type()); return static_cast<int>(geom.type());
} }
@ -71,10 +69,8 @@ struct get_type
struct get_first struct get_first
{ {
template <typename T> typedef geometry_type::value_type const result_type;
struct result { typedef geometry_type::value_type const type; }; result_type operator() (geometry_type const& geom) const
geometry_type::value_type const operator() (geometry_type const& geom) const
{ {
geometry_type::value_type coord; geometry_type::value_type coord;
boost::get<0>(coord) = geom.vertex(0,&boost::get<1>(coord),&boost::get<2>(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 struct multi_geometry_type
{ {
template <typename T> typedef boost::tuple<unsigned,bool> result_type;
struct result { typedef boost::tuple<unsigned,bool> type; }; result_type operator() (geometry_container const& geom) const
boost::tuple<unsigned,bool> operator() (geometry_container const& geom) const
{ {
unsigned type = 0u; unsigned type = 0u;
bool collection = false; bool collection = false;
@ -132,7 +126,7 @@ struct json_coordinate_policy : karma::real_policies<T>
template <typename OutputIterator> template <typename OutputIterator>
static bool fraction_part(OutputIterator& sink, T n static bool fraction_part(OutputIterator& sink, T n
, unsigned adjprec, unsigned precision) , unsigned adjprec, unsigned precision)
{ {
if (n == 0) return true; if (n == 0) return true;
return base_type::fraction_part(sink, n, adjprec, precision); return base_type::fraction_part(sink, n, adjprec, precision);

View file

@ -41,14 +41,10 @@ using standard_wide::space_type;
struct push_vertex struct push_vertex
{ {
template <typename T0,typename T1, typename T2, typename T3> typedef void result_type;
struct result
{
typedef void type;
};
template <typename T0,typename T1, typename T2, typename T3> template <typename T0,typename T1, typename T2, typename T3>
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 ); BOOST_ASSERT( path!=0 );
path->push_vertex(x,y,c); path->push_vertex(x,y,c);
@ -57,14 +53,10 @@ struct push_vertex
struct close_path struct close_path
{ {
template <typename T> typedef void result_type;
struct result
{
typedef void type;
};
template <typename T> template <typename T>
void operator() (T path) const result_type operator() (T path) const
{ {
BOOST_ASSERT( path!=0 ); BOOST_ASSERT( path!=0 );
path->close_path(); path->close_path();
@ -73,12 +65,7 @@ struct close_path
struct cleanup struct cleanup
{ {
template <typename T0> typedef void result_type;
struct result
{
typedef void type;
};
template <typename T0> template <typename T0>
void operator() (T0 & path) const void operator() (T0 & path) const
{ {
@ -89,7 +76,7 @@ struct cleanup
template <typename Iterator> template <typename Iterator>
struct geometry_grammar : struct geometry_grammar :
qi::grammar<Iterator,qi::locals<int>, void(boost::ptr_vector<mapnik::geometry_type>& ) qi::grammar<Iterator,qi::locals<int>, void(boost::ptr_vector<mapnik::geometry_type>& )
, space_type> , space_type>
{ {
geometry_grammar(); geometry_grammar();
qi::rule<Iterator, qi::locals<int>, void(boost::ptr_vector<mapnik::geometry_type>& ),space_type> geometry; qi::rule<Iterator, qi::locals<int>, void(boost::ptr_vector<mapnik::geometry_type>& ),space_type> geometry;

View file

@ -96,10 +96,8 @@ namespace mapnik { namespace util {
template <typename Geometry> template <typename Geometry>
struct get_type struct get_type
{ {
template <typename T> typedef int result_type;
struct result { typedef int type; }; result_type operator() (Geometry const& geom) const
int operator() (Geometry const& geom) const
{ {
return static_cast<int>(geom.type()); return static_cast<int>(geom.type());
} }
@ -109,11 +107,8 @@ namespace mapnik { namespace util {
struct get_first struct get_first
{ {
typedef T geometry_type; typedef T geometry_type;
typedef typename geometry_type::value_type const result_type;
template <typename U> result_type const operator() (geometry_type const& geom) const
struct result { typedef typename geometry_type::value_type const type; };
typename geometry_type::value_type const operator() (geometry_type const& geom) const
{ {
typename geometry_type::value_type coord; typename geometry_type::value_type coord;
geom.rewind(0); geom.rewind(0);

View file

@ -41,179 +41,164 @@
namespace mapnik { namespace wkt { namespace mapnik { namespace wkt {
using namespace boost::spirit; using namespace boost::spirit;
using namespace boost::fusion; using namespace boost::fusion;
using namespace boost::phoenix; using namespace boost::phoenix;
struct push_vertex struct push_vertex
{
typedef void result_type;
template <typename T0,typename T1, typename T2, typename T3>
result_type operator() (T0 c, T1 path, T2 x, T3 y) const
{ {
template <typename T0,typename T1, typename T2, typename T3> BOOST_ASSERT( path!=0 );
struct result path->push_vertex(x,y,c);
{ }
typedef void type; };
};
template <typename T0,typename T1, typename T2, typename T3> struct close_path
void operator() (T0 c, T1 path, T2 x, T3 y) const {
{ typedef void result_type;
BOOST_ASSERT( path!=0 ); template <typename T>
path->push_vertex(x,y,c); result_type operator() (T path) const
}
};
struct close_path
{ {
template <typename T> BOOST_ASSERT( path!=0 );
struct result path->close_path();
{ }
typedef void type; };
};
template <typename T> struct cleanup
void operator() (T path) const {
{ typedef void result_type;
BOOST_ASSERT( path!=0 ); template <typename T0>
path->close_path(); void operator() (T0 & path) const
}
};
struct cleanup
{ {
template <typename T0> if (path) delete path,path=0;
struct result }
{ };
typedef void type;
};
template <typename T0> template <typename Iterator>
void operator() (T0 & path) const struct wkt_grammar : qi::grammar<Iterator, boost::ptr_vector<mapnik::geometry_type>() , ascii::space_type>
{ {
if (path) delete path,path=0; wkt_grammar()
} : wkt_grammar::base_type(geometry_tagged_text)
};
template <typename Iterator>
struct wkt_grammar : qi::grammar<Iterator, boost::ptr_vector<mapnik::geometry_type>() , ascii::space_type>
{ {
wkt_grammar() using qi::no_case;
: wkt_grammar::base_type(geometry_tagged_text) using qi::_1;
{ using qi::_2;
using qi::no_case; using boost::phoenix::push_back;
using qi::_1;
using qi::_2;
using boost::phoenix::push_back;
geometry_tagged_text = point_tagged_text geometry_tagged_text = point_tagged_text
| linestring_tagged_text | linestring_tagged_text
| polygon_tagged_text | polygon_tagged_text
| multipoint_tagged_text | multipoint_tagged_text
| multilinestring_tagged_text | multilinestring_tagged_text
| multipolygon_tagged_text | multipolygon_tagged_text
; ;
// <point tagged text> ::= point <point text> // <point tagged text> ::= point <point text>
point_tagged_text = no_case[lit("POINT")] [ _a = new_<geometry_type>(Point) ] point_tagged_text = no_case[lit("POINT")] [ _a = new_<geometry_type>(Point) ]
>> ( point_text(_a) [push_back(_val,_a)] >> ( point_text(_a) [push_back(_val,_a)]
| eps[cleanup_(_a)][_pass = false]) | eps[cleanup_(_a)][_pass = false])
; ;
// <point text> ::= <empty set> | <left paren> <point> <right paren> // <point text> ::= <empty set> | <left paren> <point> <right paren>
point_text = (lit("(") >> point(SEG_MOVETO,_r1) >> lit(')')) point_text = (lit("(") >> point(SEG_MOVETO,_r1) >> lit(')'))
| empty_set | empty_set
; ;
// <linestring tagged text> ::= linestring <linestring text> // <linestring tagged text> ::= linestring <linestring text>
linestring_tagged_text = no_case[lit("LINESTRING")] [ _a = new_<geometry_type>(LineString) ] linestring_tagged_text = no_case[lit("LINESTRING")] [ _a = new_<geometry_type>(LineString) ]
>> (linestring_text(_a)[push_back(_val,_a)] >> (linestring_text(_a)[push_back(_val,_a)]
| eps[cleanup_(_a)][_pass = false]) | eps[cleanup_(_a)][_pass = false])
; ;
// <linestring text> ::= <empty set> | <left paren> <point> {<comma> <point>}* <right paren> // <linestring text> ::= <empty set> | <left paren> <point> {<comma> <point>}* <right paren>
linestring_text = points(_r1) | empty_set linestring_text = points(_r1) | empty_set
; ;
// <polygon tagged text> ::= polygon <polygon text> // <polygon tagged text> ::= polygon <polygon text>
polygon_tagged_text = no_case[lit("POLYGON")] [ _a = new_<geometry_type>(Polygon) ] polygon_tagged_text = no_case[lit("POLYGON")] [ _a = new_<geometry_type>(Polygon) ]
>> ( polygon_text(_a)[push_back(_val,_a)] >> ( polygon_text(_a)[push_back(_val,_a)]
| eps[cleanup_(_a)][_pass = false]) | eps[cleanup_(_a)][_pass = false])
; ;
// <polygon text> ::= <empty set> | <left paren> <linestring text> {<comma> <linestring text>}* <right paren> // <polygon text> ::= <empty set> | <left paren> <linestring text> {<comma> <linestring text>}* <right paren>
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 tagged text> ::= multipoint <multipoint text> //<multipoint tagged text> ::= multipoint <multipoint text>
multipoint_tagged_text = no_case[lit("MULTIPOINT")] multipoint_tagged_text = no_case[lit("MULTIPOINT")]
>> multipoint_text >> multipoint_text
; ;
// <multipoint text> ::= <empty set> | <left paren> <point text> {<comma> <point text>}* <right paren> // <multipoint text> ::= <empty set> | <left paren> <point text> {<comma> <point text>}* <right paren>
multipoint_text = (lit('(') multipoint_text = (lit('(')
>> ((eps[_a = new_<geometry_type>(Point)] >> ((eps[_a = new_<geometry_type>(Point)]
>> (point_text(_a) | empty_set) [push_back(_val,_a)] >> (point_text(_a) | empty_set) [push_back(_val,_a)]
| eps[cleanup_(_a)][_pass = false]) % lit(',')) | eps[cleanup_(_a)][_pass = false]) % lit(','))
>> lit(')')) | empty_set >> lit(')')) | empty_set
; ;
// <multilinestring tagged text> ::= multilinestring <multilinestring text> // <multilinestring tagged text> ::= multilinestring <multilinestring text>
multilinestring_tagged_text = no_case[lit("MULTILINESTRING")] multilinestring_tagged_text = no_case[lit("MULTILINESTRING")]
>> multilinestring_text ; >> multilinestring_text ;
// <multilinestring text> ::= <empty set> | <left paren> <linestring text> {<comma> <linestring text>}* <right paren> // <multilinestring text> ::= <empty set> | <left paren> <linestring text> {<comma> <linestring text>}* <right paren>
multilinestring_text = (lit('(') multilinestring_text = (lit('(')
>> ((eps[_a = new_<geometry_type>(LineString)] >> ((eps[_a = new_<geometry_type>(LineString)]
>> ( points(_a)[push_back(_val,_a)] >> ( points(_a)[push_back(_val,_a)]
| eps[cleanup_(_a)][_pass = false])) | eps[cleanup_(_a)][_pass = false]))
% lit(',')) % lit(','))
>> lit(')')) | empty_set; >> lit(')')) | empty_set;
// <multipolygon tagged text> ::= multipolygon <multipolygon text> // <multipolygon tagged text> ::= multipolygon <multipolygon text>
multipolygon_tagged_text = no_case[lit("MULTIPOLYGON")] multipolygon_tagged_text = no_case[lit("MULTIPOLYGON")]
>> multipolygon_text ; >> multipolygon_text ;
// <multipolygon text> ::= <empty set> | <left paren> <polygon text> {<comma> <polygon text>}* <right paren> // <multipolygon text> ::= <empty set> | <left paren> <polygon text> {<comma> <polygon text>}* <right paren>
multipolygon_text = (lit('(') multipolygon_text = (lit('(')
>> ((eps[_a = new_<geometry_type>(Polygon)] >> ((eps[_a = new_<geometry_type>(Polygon)]
>> ( polygon_text(_a)[push_back(_val,_a)] >> ( polygon_text(_a)[push_back(_val,_a)]
| eps[cleanup_(_a)][_pass = false])) | eps[cleanup_(_a)][_pass = false]))
% lit(',')) % lit(','))
>> lit(')')) | empty_set; >> lit(')')) | empty_set;
// points // points
points = lit('(')[_a = SEG_MOVETO] >> point (_a,_r1) % lit(',') [_a = SEG_LINETO] >> lit(')'); points = lit('(')[_a = SEG_MOVETO] >> point (_a,_r1) % lit(',') [_a = SEG_LINETO] >> lit(')');
// point // point
point = (double_ >> double_) [push_vertex_(_r1,_r2,_1,_2)]; point = (double_ >> double_) [push_vertex_(_r1,_r2,_1,_2)];
// <empty set> // <empty set>
empty_set = no_case[lit("EMPTY")]; empty_set = no_case[lit("EMPTY")];
} }
// start // start
qi::rule<Iterator,boost::ptr_vector<geometry_type>(),ascii::space_type> geometry_tagged_text; qi::rule<Iterator,boost::ptr_vector<geometry_type>(),ascii::space_type> geometry_tagged_text;
qi::rule<Iterator,qi::locals<geometry_type*>,boost::ptr_vector<geometry_type>(),ascii::space_type> point_tagged_text; qi::rule<Iterator,qi::locals<geometry_type*>,boost::ptr_vector<geometry_type>(),ascii::space_type> point_tagged_text;
qi::rule<Iterator,qi::locals<geometry_type*>,boost::ptr_vector<geometry_type>(),ascii::space_type> linestring_tagged_text; qi::rule<Iterator,qi::locals<geometry_type*>,boost::ptr_vector<geometry_type>(),ascii::space_type> linestring_tagged_text;
qi::rule<Iterator,qi::locals<geometry_type*>,boost::ptr_vector<geometry_type>(),ascii::space_type> polygon_tagged_text; qi::rule<Iterator,qi::locals<geometry_type*>,boost::ptr_vector<geometry_type>(),ascii::space_type> polygon_tagged_text;
qi::rule<Iterator,boost::ptr_vector<geometry_type>(),ascii::space_type> multipoint_tagged_text; qi::rule<Iterator,boost::ptr_vector<geometry_type>(),ascii::space_type> multipoint_tagged_text;
qi::rule<Iterator,boost::ptr_vector<geometry_type>(),ascii::space_type> multilinestring_tagged_text; qi::rule<Iterator,boost::ptr_vector<geometry_type>(),ascii::space_type> multilinestring_tagged_text;
qi::rule<Iterator,boost::ptr_vector<geometry_type>(),ascii::space_type> multipolygon_tagged_text; qi::rule<Iterator,boost::ptr_vector<geometry_type>(),ascii::space_type> multipolygon_tagged_text;
// //
qi::rule<Iterator,void(geometry_type*),ascii::space_type> point_text; qi::rule<Iterator,void(geometry_type*),ascii::space_type> point_text;
qi::rule<Iterator,void(geometry_type*),ascii::space_type> linestring_text; qi::rule<Iterator,void(geometry_type*),ascii::space_type> linestring_text;
qi::rule<Iterator,void(geometry_type*),ascii::space_type> polygon_text; qi::rule<Iterator,void(geometry_type*),ascii::space_type> polygon_text;
qi::rule<Iterator, qi::locals<geometry_type*>, boost::ptr_vector<geometry_type>(),ascii::space_type> multipoint_text; qi::rule<Iterator, qi::locals<geometry_type*>, boost::ptr_vector<geometry_type>(),ascii::space_type> multipoint_text;
qi::rule<Iterator, qi::locals<geometry_type*>, boost::ptr_vector<geometry_type>(),ascii::space_type> multilinestring_text; qi::rule<Iterator, qi::locals<geometry_type*>, boost::ptr_vector<geometry_type>(),ascii::space_type> multilinestring_text;
qi::rule<Iterator, qi::locals<geometry_type*>, boost::ptr_vector<geometry_type>(),ascii::space_type> multipolygon_text; qi::rule<Iterator, qi::locals<geometry_type*>, boost::ptr_vector<geometry_type>(),ascii::space_type> multipolygon_text;
// //
qi::rule<Iterator,void(CommandType,geometry_type*),ascii::space_type> point; qi::rule<Iterator,void(CommandType,geometry_type*),ascii::space_type> point;
qi::rule<Iterator,qi::locals<CommandType>,void(geometry_type*),ascii::space_type> points; qi::rule<Iterator,qi::locals<CommandType>,void(geometry_type*),ascii::space_type> points;
qi::rule<Iterator,ascii::space_type> empty_set; qi::rule<Iterator,ascii::space_type> empty_set;
boost::phoenix::function<push_vertex> push_vertex_; boost::phoenix::function<push_vertex> push_vertex_;
boost::phoenix::function<close_path> close_path_; boost::phoenix::function<close_path> close_path_;
boost::phoenix::function<cleanup> cleanup_; boost::phoenix::function<cleanup> cleanup_;
}; };
template <typename Iterator> template <typename Iterator>