+ 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
#define MAPNIK_CSS_COLOR_GRAMMAR_HPP
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
// mapnik
#include <mapnik/color.hpp>
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
// spirit2
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/qi_action.hpp>
@ -99,13 +99,9 @@ inline int clip_int(int val)
struct percent_conv_impl
{
template <typename T>
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 <typename T>
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<typename T0,typename T1, typename T2, typename T3>
struct result
{
typedef void type;
};
typedef void result_type;
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;
// normalize values

View file

@ -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 <boost/version.hpp>

View file

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

View file

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

View file

@ -60,10 +60,8 @@ namespace {
struct get_type
{
template <typename T>
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<int>(geom.type());
}
@ -71,10 +69,8 @@ struct get_type
struct get_first
{
template <typename T>
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 <typename T>
struct result { typedef boost::tuple<unsigned,bool> type; };
boost::tuple<unsigned,bool> operator() (geometry_container const& geom) const
typedef boost::tuple<unsigned,bool> 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<T>
template <typename OutputIterator>
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);

View file

@ -41,14 +41,10 @@ using standard_wide::space_type;
struct push_vertex
{
template <typename T0,typename T1, typename T2, typename T3>
struct result
{
typedef void type;
};
typedef void result_type;
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 );
path->push_vertex(x,y,c);
@ -57,14 +53,10 @@ struct push_vertex
struct close_path
{
template <typename T>
struct result
{
typedef void type;
};
typedef void result_type;
template <typename T>
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 <typename T0>
struct result
{
typedef void type;
};
typedef void result_type;
template <typename T0>
void operator() (T0 & path) const
{
@ -89,7 +76,7 @@ struct cleanup
template <typename Iterator>
struct geometry_grammar :
qi::grammar<Iterator,qi::locals<int>, void(boost::ptr_vector<mapnik::geometry_type>& )
, space_type>
, space_type>
{
geometry_grammar();
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>
struct get_type
{
template <typename T>
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<int>(geom.type());
}
@ -109,11 +107,8 @@ namespace mapnik { namespace util {
struct get_first
{
typedef T geometry_type;
template <typename U>
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);

View file

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