boost 1.56 support

This commit is contained in:
Dane Springmeyer 2014-09-22 23:22:05 -07:00
parent 9c947232e9
commit 8c4a5d53d3
13 changed files with 312 additions and 47 deletions

View file

@ -1431,7 +1431,7 @@ if not preconfigured:
env["CAIRO_ALL_LIBS"] = ['cairo']
if env['RUNTIME_LINK'] == 'static':
env["CAIRO_ALL_LIBS"].extend(
['pixman-1','expat','fontconfig','iconv']
['pixman-1','expat','iconv']
)
# todo - run actual checkLib?
env['HAS_CAIRO'] = True

View file

@ -125,7 +125,11 @@ struct alpha_conv_impl
struct hsl_conv_impl
{
#ifdef BOOST_SPIRIT_USE_PHOENIX_V3
template<typename T>
#else
template<typename T0,typename T1, typename T2, typename T3>
#endif
struct result
{
typedef void type;
@ -413,7 +417,11 @@ struct alpha_conv_impl
struct hsl_conv_impl
{
#ifdef BOOST_SPIRIT_USE_PHOENIX_V3
template<typename T>
#else
template<typename T0,typename T1, typename T2, typename T3>
#endif
struct result
{
typedef void type;

View file

@ -65,7 +65,11 @@ struct unicode_impl
struct regex_match_impl
{
#ifdef BOOST_SPIRIT_USE_PHOENIX_V3
template <typename T>
#else
template <typename T0, typename T1>
#endif
struct result
{
typedef expr_node type;
@ -82,7 +86,11 @@ struct regex_match_impl
struct regex_replace_impl
{
template <typename T0, typename T1, typename T2>
#ifdef BOOST_SPIRIT_USE_PHOENIX_V3
template <typename T>
#else
template <typename T0, typename T1>
#endif
struct result
{
typedef expr_node type;

View file

@ -145,7 +145,7 @@ expression_grammar<Iterator>::expression_grammar(mapnik::transcoder const& tr)
multiplicative_expr = unary_expr [_val = _1]
>> *( '*' >> unary_expr [_val *= _1]
| '/' >> unary_expr [_val /= _1]
| '%' >> unary_expr [_val %= _1]
| '%' >> unary_expr [_val %= construct<mapnik::expr_node>(_1)] //needed by clang++ with -std=c++11
| regex_match_expr[_val = regex_match_(_val, _1)]
| regex_replace_expr(_val) [_val = _1]
)

View file

@ -66,6 +66,30 @@ public:
mapnik::transcoder const& tr_;
};
#ifdef BOOST_SPIRIT_USE_PHOENIX_V3
struct put_property
{
typedef void result_type;
explicit put_property(mapnik::transcoder const& tr)
: tr_(tr) {}
template <typename T0,typename T1, typename T2>
result_type operator() (T0 & feature, T1 const& key, T2 const& val) const
{
feature.put_new(key, boost::apply_visitor(attribute_value_visitor(tr_),val));
}
mapnik::transcoder const& tr_;
};
struct extract_geometry
{
typedef boost::ptr_vector<mapnik::geometry_type>& result_type;
template <typename T>
result_type operator() (T & feature) const
{
return feature.paths();
}
};
#else
struct put_property
{
template <typename T0,typename T1, typename T2>
@ -100,6 +124,7 @@ struct extract_geometry
return feature.paths();
}
};
#endif
template <typename Iterator, typename FeatureType>
struct feature_grammar :

View file

@ -38,11 +38,8 @@
#include <boost/spirit/include/phoenix_fusion.hpp>
#include <boost/spirit/include/phoenix_function.hpp>
#include <boost/spirit/include/phoenix_statement.hpp>
#include <boost/fusion/include/boost_tuple.hpp>
#include <boost/math/special_functions/trunc.hpp> // trunc to avoid needing C++11
//#define BOOST_SPIRIT_USE_PHOENIX_V3 1
#include <boost/fusion/adapted/boost_tuple.hpp>
#include <boost/math/special_functions/trunc.hpp> // for vc++ and android whose c++11 libs lack std::trunct
namespace boost { namespace spirit { namespace traits {
@ -61,6 +58,68 @@ namespace phoenix = boost::phoenix;
namespace {
#ifdef BOOST_SPIRIT_USE_PHOENIX_V3
struct get_type
{
typedef int result_type;
result_type operator() (geometry_type const& geom) const
{
return static_cast<int>(geom.type());
}
};
struct get_first
{
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));
return coord;
}
};
struct multi_geometry_type
{
typedef boost::tuple<unsigned,bool> result_type;
result_type operator() (geometry_container const& geom) const
{
unsigned type = 0u;
bool collection = false;
geometry_container::const_iterator itr = geom.begin();
geometry_container::const_iterator end = geom.end();
for ( ; itr != end; ++itr)
{
if (type != 0u && itr->type() != type)
{
collection = true;
break;
}
type = itr->type();
}
if (geom.size() > 1) type +=3;
return boost::tuple<unsigned,bool>(type, collection);
}
};
struct not_empty
{
typedef bool result_type;
result_type operator() (geometry_container const& cont) const
{
geometry_container::const_iterator itr = cont.begin();
geometry_container::const_iterator end = cont.end();
for ( ; itr != end; ++itr)
{
if (itr->size() > 0) return true;
}
return false;
}
};
#else
struct get_type
{
template <typename T>
@ -100,7 +159,7 @@ struct multi_geometry_type
for ( ; itr != end; ++itr)
{
if (type != 0u && itr->type() != type)
if (type != 0u && static_cast<unsigned>(itr->type()) != type)
{
collection = true;
break;
@ -113,6 +172,28 @@ struct multi_geometry_type
};
struct not_empty
{
template <typename T>
struct result { typedef bool type; };
bool operator() (geometry_container const& cont) const
{
geometry_container::const_iterator itr = cont.begin();
geometry_container::const_iterator end = cont.end();
for (; itr!=end; ++itr)
{
if (itr->size() > 0) return true;
}
return false;
}
};
#endif
template <typename T>
struct json_coordinate_policy : karma::real_policies<T>
{
@ -123,7 +204,7 @@ struct json_coordinate_policy : karma::real_policies<T>
{
if (n == 0.0) return 0;
using namespace boost::spirit;
return static_cast<unsigned>(15 - boost::math::trunc(log10(traits::get_absolute_value(n))));
return static_cast<unsigned>(14 - boost::math::trunc(log10(traits::get_absolute_value(n))));
}
template <typename OutputIterator>
@ -135,7 +216,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);
@ -153,6 +234,7 @@ struct geometry_generator_grammar :
: geometry_generator_grammar::base_type(coordinates)
{
using boost::spirit::karma::uint_;
using boost::spirit::bool_;
using boost::spirit::karma::_val;
using boost::spirit::karma::_1;
using boost::spirit::karma::lit;
@ -182,15 +264,15 @@ struct geometry_generator_grammar :
point_coord = &uint_
<< lit('[')
<< coord_type << lit(',') << coord_type
<< lit("]")
<< lit(']')
;
polygon_coord %= ( &uint_(mapnik::SEG_MOVETO) << eps[_r1 += 1]
<< karma::string[ if_ (_r1 > 1) [_1 = "],["]
.else_[_1 = '[' ]] | &uint_ << lit(','))
<< lit('[') << coord_type
<< lit(',')
<< coord_type << lit(']')
<< karma::string[ if_ (_r1 > 1u) [_1 = "],["]
.else_[_1 = '[' ]]
|
&uint_(mapnik::SEG_LINETO)
<< lit(',')) << lit('[') << coord_type << lit(',') << coord_type << lit(']')
;
coords2 %= *polygon_coord(_a)
@ -205,7 +287,6 @@ struct geometry_generator_grammar :
karma::rule<OutputIterator, geometry_type const& ()> point;
karma::rule<OutputIterator, geometry_type const& ()> linestring;
karma::rule<OutputIterator, geometry_type const& ()> polygon;
karma::rule<OutputIterator, geometry_type const& ()> coords;
karma::rule<OutputIterator, karma::locals<unsigned>, geometry_type const& ()> coords2;
karma::rule<OutputIterator, geometry_type::value_type ()> point_coord;
@ -235,6 +316,7 @@ struct multi_geometry_generator_grammar :
using boost::spirit::karma::_1;
using boost::spirit::karma::_a;
using boost::spirit::karma::_r1;
using boost::spirit::bool_;
geometry_types.add
(mapnik::Point,"\"Point\"")
@ -245,7 +327,7 @@ struct multi_geometry_generator_grammar :
(mapnik::Polygon + 3,"\"MultiPolygon\"")
;
start %= ( eps(phoenix::at_c<1>(_a))[_a = _multi_type(_val)]
start %= ( eps(phoenix::at_c<1>(_a))[_a = multi_type_(_val)]
<< lit("{\"type\":\"GeometryCollection\",\"geometries\":[")
<< geometry_collection << lit("]}")
|
@ -255,13 +337,13 @@ struct multi_geometry_generator_grammar :
geometry_collection = -(geometry2 % lit(','))
;
geometry = (lit("{\"type\":")
<< geometry_types[_1 = phoenix::at_c<0>(_a)][_a = _multi_type(_val)]
<< lit(",\"coordinates\":")
<< karma::string[ if_ (phoenix::at_c<0>(_a) > 3) [_1 = '[']]
<< coordinates
<< karma::string[ if_ (phoenix::at_c<0>(_a) > 3) [_1 = ']']]
<< lit('}')) | lit("null")
geometry = ( &bool_(true)[_1 = not_empty_(_val)] << lit("{\"type\":")
<< geometry_types[_1 = phoenix::at_c<0>(_a)][_a = multi_type_(_val)]
<< lit(",\"coordinates\":")
<< karma::string[ phoenix::if_ (phoenix::at_c<0>(_a) > 3u) [_1 = '['].else_[_1 = ""]]
<< coordinates
<< karma::string[ phoenix::if_ (phoenix::at_c<0>(_a) > 3u) [_1 = ']'].else_[_1 = ""]]
<< lit('}')) | lit("null")
;
geometry2 = lit("{\"type\":")
@ -287,8 +369,9 @@ struct multi_geometry_generator_grammar :
karma::rule<OutputIterator, geometry_container const&()> coordinates;
geometry_generator_grammar<OutputIterator> path;
// phoenix
phoenix::function<multi_geometry_type> _multi_type;
phoenix::function<multi_geometry_type> multi_type_;
phoenix::function<get_type > type_;
phoenix::function<not_empty> not_empty_;
// symbols table
karma::symbols<unsigned, char const*> geometry_types;
};

View file

@ -37,6 +37,58 @@ namespace qi = boost::spirit::qi;
namespace standard_wide = boost::spirit::standard_wide;
using standard_wide::space_type;
#ifdef BOOST_SPIRIT_USE_PHOENIX_V3
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
{
BOOST_ASSERT( path!=0 );
path->push_vertex(x,y,c);
}
};
struct close_path
{
typedef void result_type;
template <typename T>
result_type operator() (T path) const
{
BOOST_ASSERT( path!=0 );
if (path->size() > 2u) // to form a polygon ring we need at least 3 vertices
{
path->close_path();
}
}
};
struct cleanup
{
typedef void result_type;
template <typename T0>
void operator() (T0 & path) const
{
if (path) delete path, path=0;
}
};
struct where_message
{
typedef std::string result_type;
template <typename Iterator>
std::string operator() (Iterator first, Iterator last, std::size_t size) const
{
std::string str(first, last);
if (str.length() > size)
return str.substr(0, size) + "..." ;
return str;
}
};
#else
struct push_vertex
{
template <typename T0,typename T1, typename T2, typename T3>
@ -65,8 +117,11 @@ struct close_path
void operator() (T path) const
{
BOOST_ASSERT( path!=0 );
path->close_path();
}
if (path->size() > 2u) // to form a polygon ring we need at least 3 vertices
{
path->close_path();
}
}
};
struct cleanup
@ -101,12 +156,13 @@ struct where_message
return str;
}
};
#endif
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

@ -45,7 +45,12 @@ inline double deg2rad(double deg)
template <typename PathType>
struct move_to
{
#ifdef BOOST_SPIRIT_USE_PHOENIX_V3
template <typename T0>
#else
template <typename T0, typename T1>
#endif
struct result
{
typedef void type;
@ -66,7 +71,11 @@ struct move_to
template <typename PathType>
struct hline_to
{
#ifdef BOOST_SPIRIT_USE_PHOENIX_V3
template <typename T0>
#else
template <typename T0, typename T1>
#endif
struct result
{
typedef void type;
@ -88,7 +97,11 @@ struct hline_to
template <typename PathType>
struct vline_to
{
#ifdef BOOST_SPIRIT_USE_PHOENIX_V3
template <typename T0>
#else
template <typename T0, typename T1>
#endif
struct result
{
typedef void type;
@ -109,7 +122,11 @@ struct vline_to
template <typename PathType>
struct line_to
{
#ifdef BOOST_SPIRIT_USE_PHOENIX_V3
template <typename T0>
#else
template <typename T0, typename T1>
#endif
struct result
{
typedef void type;
@ -131,7 +148,11 @@ struct line_to
template <typename PathType>
struct curve4
{
#ifdef BOOST_SPIRIT_USE_PHOENIX_V3
template <typename T0>
#else
template <typename T0, typename T1, typename T2, typename T3>
#endif
struct result
{
typedef void type;
@ -156,7 +177,11 @@ struct curve4
template <typename PathType>
struct curve4_smooth
{
#ifdef BOOST_SPIRIT_USE_PHOENIX_V3
template <typename T0>
#else
template <typename T0, typename T1, typename T2>
#endif
struct result
{
typedef void type;
@ -178,7 +203,11 @@ struct curve4_smooth
template <typename PathType>
struct curve3
{
#ifdef BOOST_SPIRIT_USE_PHOENIX_V3
template <typename T0>
#else
template <typename T0, typename T1, typename T2>
#endif
struct result
{
typedef void type;
@ -201,7 +230,11 @@ struct curve3
template <typename PathType>
struct curve3_smooth
{
#ifdef BOOST_SPIRIT_USE_PHOENIX_V3
template <typename T0>
#else
template <typename T0, typename T1>
#endif
struct result
{
typedef void type;
@ -223,7 +256,11 @@ struct curve3_smooth
template <typename PathType>
struct arc_to
{
#ifdef BOOST_SPIRIT_USE_PHOENIX_V3
template <typename T0>
#else
template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5>
#endif
struct result
{
typedef void type;

View file

@ -50,7 +50,11 @@ namespace mapnik { namespace svg {
template <typename TransformType>
struct process_matrix
{
#ifdef BOOST_SPIRIT_USE_PHOENIX_V3
template <typename T0>
#else
template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5>
#endif
struct result
{
typedef void type;
@ -70,7 +74,11 @@ namespace mapnik { namespace svg {
template <typename TransformType>
struct process_rotate
{
#ifdef BOOST_SPIRIT_USE_PHOENIX_V3
template <typename T0>
#else
template <typename T0, typename T1, typename T2>
#endif
struct result
{
typedef void type;
@ -101,7 +109,11 @@ namespace mapnik { namespace svg {
template <typename TransformType>
struct process_translate
{
#ifdef BOOST_SPIRIT_USE_PHOENIX_V3
template <typename T0>
#else
template <typename T0, typename T1>
#endif
struct result
{
typedef void type;
@ -123,7 +135,11 @@ namespace mapnik { namespace svg {
template <typename TransformType>
struct process_scale
{
#ifdef BOOST_SPIRIT_USE_PHOENIX_V3
template <typename T0>
#else
template <typename T0, typename T1>
#endif
struct result
{
typedef void type;
@ -146,7 +162,11 @@ namespace mapnik { namespace svg {
template <typename TransformType>
struct process_skew
{
#ifdef BOOST_SPIRIT_USE_PHOENIX_V3
template <typename T0>
#else
template <typename T0, typename T1>
#endif
struct result
{
typedef void type;

View file

@ -23,6 +23,7 @@
#ifndef MAPNIK_GEOMETRY_SVG_GENERATOR_HPP
#define MAPNIK_GEOMETRY_SVG_GENERATOR_HPP
// mapnik
#include <mapnik/global.hpp>
#include <mapnik/geometry.hpp> // for container stuff
@ -41,13 +42,11 @@
#include <boost/fusion/include/boost_tuple.hpp>
#include <boost/type_traits/remove_pointer.hpp>
//#define BOOST_SPIRIT_USE_PHOENIX_V3 1
/*!
* adapted to conform to the concepts
* required by Karma to be recognized as a container of
* attributes for output generation.
*/
// adapted to conform to the concepts
// required by Karma to be recognized as a container of
// attributes for output generation.
namespace boost { namespace spirit { namespace traits {
// TODO - this needs to be made generic to any path type
@ -76,7 +75,7 @@ template <>
struct end_container<path_type const>
{
static mapnik::util::path_iterator<path_type>
call (path_type const& g)
call (path_type const& /*g*/)
{
return mapnik::util::path_iterator<path_type>();
}
@ -92,6 +91,31 @@ namespace mapnik { namespace util {
namespace svg_detail {
#ifdef BOOST_SPIRIT_USE_PHOENIX_V3
template <typename Geometry>
struct get_type
{
typedef int result_type;
result_type operator() (Geometry const& geom) const
{
return static_cast<int>(geom.type());
}
};
template <typename T>
struct get_first
{
typedef T geometry_type;
typedef typename geometry_type::value_type const result_type;
result_type operator() (geometry_type const& geom) const
{
typename geometry_type::value_type coord;
geom.rewind(0);
boost::get<0>(coord) = geom.vertex(&boost::get<1>(coord),&boost::get<2>(coord));
return coord;
}
};
#else
template <typename Geometry>
struct get_type
{
@ -112,7 +136,7 @@ namespace mapnik { namespace util {
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
typename geometry_type::value_type operator() (geometry_type const& geom) const
{
typename geometry_type::value_type coord;
geom.rewind(0);
@ -121,12 +145,13 @@ namespace mapnik { namespace util {
}
};
#endif
template <typename T>
struct coordinate_policy : karma::real_policies<T>
{
typedef boost::spirit::karma::real_policies<T> base_type;
static int floatfield(T n) { return base_type::fmtflags::fixed; }
static unsigned precision(T n) { return 6u ;}
static unsigned precision(T n) { return 4u ;}
};
}
@ -161,15 +186,15 @@ namespace mapnik { namespace util {
;
linestring = &uint_(mapnik::LineString)[_1 = _type(_val)]
<< svg_path << lit('\"')
<< lit("d=\"") << svg_path << lit("\"")
;
polygon = &uint_(mapnik::Polygon)[_1 = _type(_val)]
<< svg_path << lit('\"')
<< lit("d=\"") << svg_path << lit("\"")
;
svg_path %= ((&uint_(mapnik::SEG_MOVETO) << lit("d=\"") << lit('M')
| &uint_(mapnik::SEG_LINETO) [_a +=1] << karma::string [if_(_a == 1) [_1 = "L" ] ])
svg_path %= ((&uint_(mapnik::SEG_MOVETO) << lit('M')
| &uint_(mapnik::SEG_LINETO) [_a +=1] << karma::string [if_(_a == 1u) [_1 = "L" ].else_[_1 =""]])
<< lit(' ') << coordinate << lit(' ') << coordinate) % lit(' ')
;

View file

@ -40,7 +40,6 @@
#include <boost/type_traits/remove_pointer.hpp>
#include <boost/math/special_functions/trunc.hpp> // trunc to avoid needing C++11
//#define BOOST_SPIRIT_USE_PHOENIX_V3 1
namespace boost { namespace spirit { namespace traits {
@ -205,8 +204,7 @@ template <typename OutputIterator, typename GeometryContainer>
struct wkt_multi_generator :
karma::grammar<OutputIterator, karma::locals< boost::tuple<unsigned,bool> >, GeometryContainer const& ()>
{
typedef GeometryContainer geometry_contaner;
typedef boost::remove_pointer<typename geometry_container::value_type>::type geometry_type;
typedef typename boost::remove_pointer<typename GeometryContainer::value_type>::type geometry_type;
wkt_multi_generator();
// rules

View file

@ -40,12 +40,15 @@
namespace mapnik { namespace wkt {
using namespace boost::spirit;
using namespace boost::fusion;
using namespace boost::phoenix;
struct push_vertex
{
#ifdef BOOST_SPIRIT_USE_PHOENIX_V3
template <typename T>
#else
template <typename T0,typename T1, typename T2, typename T3>
#endif
struct result
{
typedef void type;

View file

@ -23,8 +23,10 @@
// TODO https://github.com/mapnik/mapnik/issues/1658
#include <boost/version.hpp>
#if BOOST_VERSION >= 105200
#ifndef BOOST_SPIRIT_USE_PHOENIX_V3
#define BOOST_SPIRIT_USE_PHOENIX_V3
#endif
#endif
// mapnik
#include <mapnik/json/feature_collection_parser.hpp>