From c73e48fa589223ff3760d2bb8dfdc4f972fd1de5 Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 19 Apr 2013 09:50:50 +0100 Subject: [PATCH] + use std::unique_ptr instead of std::auto_ptr (deprecated!) --- benchmark/run.cpp | 17 +++++------ bindings/python/mapnik_geometry.cpp | 7 +++-- bindings/python/mapnik_image.cpp | 8 +++--- include/mapnik/css_color_grammar.hpp | 2 ++ include/mapnik/css_color_grammar_def.hpp | 2 ++ include/mapnik/expression_grammar.hpp | 2 ++ .../mapnik/feature_style_processor_impl.hpp | 22 ++++++++------- include/mapnik/image_filter_grammar.hpp | 1 + .../json/feature_collection_grammar.hpp | 21 +++++++------- .../mapnik/json/feature_generator_grammar.hpp | 2 ++ include/mapnik/json/feature_grammar.hpp | 1 + .../json/geometry_generator_grammar.hpp | 3 +- include/mapnik/json/geometry_grammar.hpp | 2 ++ include/mapnik/path_expression_grammar.hpp | 1 + include/mapnik/placement_finder.hpp | 4 +-- include/mapnik/rule_cache.hpp | 10 +++---- include/mapnik/svg/svg_path_grammar.hpp | 1 + .../mapnik/transform_expression_grammar.hpp | 1 + include/mapnik/util/dasharray_parser.hpp | 12 ++++---- .../mapnik/util/geometry_svg_generator.hpp | 3 +- include/mapnik/util/geometry_to_svg.hpp | 2 ++ .../mapnik/util/geometry_wkt_generator.hpp | 6 +++- include/mapnik/wkt/wkt_grammar.hpp | 2 ++ plugins/input/ogr/ogr_converter.cpp | 12 ++++---- plugins/input/raster/raster_datasource.cpp | 2 +- plugins/input/raster/raster_featureset.cpp | 2 +- plugins/input/shape/shape_featureset.cpp | 8 +++--- .../input/shape/shape_index_featureset.cpp | 8 +++--- plugins/input/shape/shape_io.cpp | 12 ++++---- src/conversions.cpp | 2 ++ src/expression_grammar.cpp | 4 ++- src/json/feature_collection_parser.cpp | 6 ++-- src/json/feature_grammar.cpp | 1 + src/json/geojson_generator.cpp | 16 +++++++---- src/json/geometry_grammar.cpp | 2 ++ src/json/geometry_parser.cpp | 2 ++ src/marker_cache.cpp | 2 +- src/placement_finder.cpp | 28 +++++++++---------- src/text_placements/simple.cpp | 2 ++ src/transform_expression_grammar.cpp | 1 + src/wkb.cpp | 24 ++++++++-------- tests/cpp_tests/conversions_test.cpp | 2 ++ tests/cpp_tests/geometry_converters_test.cpp | 6 ++-- tests/cpp_tests/image_io_test.cpp | 10 +++---- tests/cpp_tests/map_request_test.cpp | 4 +-- 45 files changed, 167 insertions(+), 121 deletions(-) diff --git a/benchmark/run.cpp b/benchmark/run.cpp index c20c153d3..38612f55d 100644 --- a/benchmark/run.cpp +++ b/benchmark/run.cpp @@ -12,6 +12,7 @@ #include #include #include +#include // boost #include @@ -92,7 +93,7 @@ void benchmark(T & test_runner, std::string const& name) bool compare_images(std::string const& src_fn,std::string const& dest_fn) { - std::auto_ptr reader1(mapnik::get_image_reader(dest_fn,"png")); + std::unique_ptr reader1(mapnik::get_image_reader(dest_fn,"png")); if (!reader1.get()) { throw mapnik::image_reader_exception("Failed to load: " + dest_fn); @@ -100,7 +101,7 @@ bool compare_images(std::string const& src_fn,std::string const& dest_fn) boost::shared_ptr image_ptr1 = boost::make_shared(reader1->width(),reader1->height()); reader1->read(0,0,image_ptr1->data()); - std::auto_ptr reader2(mapnik::get_image_reader(src_fn,"png")); + std::unique_ptr reader2(mapnik::get_image_reader(src_fn,"png")); if (!reader2.get()) { throw mapnik::image_reader_exception("Failed to load: " + src_fn); @@ -162,7 +163,7 @@ struct test2 im_() { std::string filename("./benchmark/data/multicolor.png"); - std::auto_ptr reader(mapnik::get_image_reader(filename,"png")); + std::unique_ptr reader(mapnik::get_image_reader(filename,"png")); if (!reader.get()) { throw mapnik::image_reader_exception("Failed to load: " + filename); @@ -410,8 +411,8 @@ struct test8 #include #if BOOST_VERSION >= 105300 -#include -#include +//#include +//#include class rule_cache_move { @@ -593,13 +594,13 @@ struct test10 void operator()() { for (unsigned i=0;i rule_caches; + std::vector > rule_caches; for (unsigned i=0;i rc(new rule_cache_heap); + std::unique_ptr rc(new rule_cache_heap); for (unsigned i=0;iadd_rule(rules_[i]); } - rule_caches.push_back(rc); + rule_caches.push_back(std::move(rc)); } } } diff --git a/bindings/python/mapnik_geometry.cpp b/bindings/python/mapnik_geometry.cpp index 1a949c6aa..0b7a344fb 100644 --- a/bindings/python/mapnik_geometry.cpp +++ b/bindings/python/mapnik_geometry.cpp @@ -40,7 +40,7 @@ #if BOOST_VERSION >= 104700 #include #include -#include +//#include #endif namespace { @@ -229,7 +229,8 @@ std::string to_geojson( path_type const& geom) std::string to_svg( geometry_type const& geom) { -#if BOOST_VERSION >= 104700 + +#if 0 // BOOST_VERSION >= 104700 std::string svg; // Use Python String directly ? bool result = mapnik::util::to_svg(svg,geom); if (!result) @@ -280,7 +281,7 @@ void export_geometry() #endif using mapnik::geometry_type; - class_, boost::noncopyable>("Geometry2d",no_init) + class_, boost::noncopyable>("Geometry2d",no_init) .def("envelope",&geometry_type::envelope) // .def("__str__",&geometry_type::to_string) .def("type",&geometry_type::type) diff --git a/bindings/python/mapnik_image.cpp b/bindings/python/mapnik_image.cpp index f6c0550d0..c916bde3b 100644 --- a/bindings/python/mapnik_image.cpp +++ b/bindings/python/mapnik_image.cpp @@ -151,7 +151,7 @@ boost::shared_ptr open_from_file(std::string const& filename) boost::optional type = type_from_filename(filename); if (type) { - std::auto_ptr reader(get_image_reader(filename,*type)); + std::unique_ptr reader(get_image_reader(filename,*type)); if (reader.get()) { @@ -166,7 +166,7 @@ boost::shared_ptr open_from_file(std::string const& filename) boost::shared_ptr fromstring(std::string const& str) { - std::auto_ptr reader(get_image_reader(str.c_str(),str.size())); + std::unique_ptr reader(get_image_reader(str.c_str(),str.size())); if (reader.get()) { boost::shared_ptr image_ptr = boost::make_shared(reader->width(),reader->height()); @@ -182,15 +182,15 @@ boost::shared_ptr frombuffer(PyObject * obj) Py_ssize_t buffer_len; if (PyObject_AsReadBuffer(obj, &buffer, &buffer_len) == 0) { - std::auto_ptr reader(get_image_reader(reinterpret_cast(buffer),buffer_len)); + std::unique_ptr reader(get_image_reader(reinterpret_cast(buffer),buffer_len)); if (reader.get()) { boost::shared_ptr image_ptr = boost::make_shared(reader->width(),reader->height()); reader->read(0,0,image_ptr->data()); return image_ptr; } - throw mapnik::image_reader_exception("Failed to load image from buffer" ); } + throw mapnik::image_reader_exception("Failed to load image from buffer" ); } diff --git a/include/mapnik/css_color_grammar.hpp b/include/mapnik/css_color_grammar.hpp index a15f0fa87..51d498428 100644 --- a/include/mapnik/css_color_grammar.hpp +++ b/include/mapnik/css_color_grammar.hpp @@ -23,6 +23,8 @@ #ifndef MAPNIK_CSS_COLOR_GRAMMAR_HPP #define MAPNIK_CSS_COLOR_GRAMMAR_HPP +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + // mapnik #include diff --git a/include/mapnik/css_color_grammar_def.hpp b/include/mapnik/css_color_grammar_def.hpp index 028411ba1..57768e895 100644 --- a/include/mapnik/css_color_grammar_def.hpp +++ b/include/mapnik/css_color_grammar_def.hpp @@ -23,6 +23,8 @@ #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 2702048a3..50ac37ded 100644 --- a/include/mapnik/expression_grammar.hpp +++ b/include/mapnik/expression_grammar.hpp @@ -23,6 +23,8 @@ #ifndef MAPNIK_EXPRESSIONS_GRAMMAR_HPP #define MAPNIK_EXPRESSIONS_GRAMMAR_HPP +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + // mapnik #include #include diff --git a/include/mapnik/feature_style_processor_impl.hpp b/include/mapnik/feature_style_processor_impl.hpp index eade195b3..f1a893d71 100644 --- a/include/mapnik/feature_style_processor_impl.hpp +++ b/include/mapnik/feature_style_processor_impl.hpp @@ -54,7 +54,7 @@ // stl #include - +#include #if defined(RENDERING_STATS) #include @@ -400,7 +400,9 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces attribute_collector collector(names); double filt_factor = 1.0; directive_collector d_collector(filt_factor); - boost::ptr_vector rule_caches; + + std::vector > rule_caches; + //boost::ptr_vector rule_caches; // iterate through all named styles collecting active styles and attribute names BOOST_FOREACH(std::string const& style_name, style_names) @@ -417,12 +419,12 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces std::vector const& rules = style->get_rules(); bool active_rules = false; - std::auto_ptr rc(new rule_cache); - BOOST_FOREACH(rule const& r, rules) + std::unique_ptr rc_ptr(new rule_cache); + for (auto const& r : rules) { if (r.active(scale_denom)) { - rc->add_rule(r); + rc_ptr->add_rule(r); active_rules = true; if (ds->type() == datasource::Vector) { @@ -433,7 +435,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces } if (active_rules) { - rule_caches.push_back(rc); + rule_caches.push_back(std::move(rc_ptr)); active_styles.push_back(&(*style)); } } @@ -505,7 +507,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces int i = 0; BOOST_FOREACH (feature_type_style const* style, active_styles) { - render_style(lay, p, style, rule_caches[i], style_names[i], + render_style(lay, p, style, *rule_caches[i], style_names[i], cache.features(q), prj_trans); i++; } @@ -518,7 +520,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces int i = 0; BOOST_FOREACH (feature_type_style const* style, active_styles) { - render_style(lay, p, style, rule_caches[i], style_names[i], + render_style(lay, p, style, *rule_caches[i], style_names[i], cache.features(q), prj_trans); i++; } @@ -539,7 +541,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces int i = 0; BOOST_FOREACH (feature_type_style const* style, active_styles) { - render_style(lay, p, style, rule_caches[i], style_names[i], + render_style(lay, p, style, *rule_caches[i], style_names[i], cache.features(q), prj_trans); i++; } @@ -550,7 +552,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces int i = 0; BOOST_FOREACH (feature_type_style const* style, active_styles) { - render_style(lay, p, style, rule_caches[i], style_names[i], + render_style(lay, p, style, *rule_caches[i], style_names[i], ds->features(q), prj_trans); i++; } diff --git a/include/mapnik/image_filter_grammar.hpp b/include/mapnik/image_filter_grammar.hpp index 4f4523278..919b2b9d4 100644 --- a/include/mapnik/image_filter_grammar.hpp +++ b/include/mapnik/image_filter_grammar.hpp @@ -23,6 +23,7 @@ #ifndef MAPNIK_IMAGE_FILITER_GRAMMAR_HPP #define MAPNIK_IMAGE_FILITER_GRAMMAR_HPP +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // boost #include #include diff --git a/include/mapnik/json/feature_collection_grammar.hpp b/include/mapnik/json/feature_collection_grammar.hpp index 43b8db635..29ca15f34 100644 --- a/include/mapnik/json/feature_collection_grammar.hpp +++ b/include/mapnik/json/feature_collection_grammar.hpp @@ -28,6 +28,7 @@ #include #include +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // spirit::qi #include #include @@ -42,14 +43,14 @@ using standard_wide::space_type; struct generate_id { typedef int result_type; - + generate_id(int start) : id_(start) {} - + int operator() () const { return id_++; - } + } mutable int id_; }; @@ -76,7 +77,7 @@ struct feature_collection_grammar : feature_collection = lit('{') >> (type | features) % lit(",") >> lit('}') ; - + type = lit("\"type\"") > lit(":") > lit("\"FeatureCollection\"") ; @@ -86,29 +87,29 @@ struct feature_collection_grammar : > -(feature(_val) % lit(',')) > lit(']') ; - + feature = eps[_a = phoenix::construct(new_(ctx_,generate_id_()))] >> feature_g(*_a)[push_back(_r1,_a)] ; - + type.name("type"); features.name("features"); feature.name("feature"); feature_g.name("feature-grammar"); - + qi::on_error ( feature_collection , std::clog << phoenix::val("Error parsing GeoJSON ") - << qi::_4 + << qi::_4 << phoenix::val(" here: \"") - << construct(qi::_3, qi::_2) + << construct(qi::_3, qi::_2) << phoenix::val("\"") << std::endl ); } - + context_ptr ctx_; qi::rule(), space_type> feature_collection; // START qi::rule type; diff --git a/include/mapnik/json/feature_generator_grammar.hpp b/include/mapnik/json/feature_generator_grammar.hpp index d5d16c47d..3f0f16c96 100644 --- a/include/mapnik/json/feature_generator_grammar.hpp +++ b/include/mapnik/json/feature_generator_grammar.hpp @@ -23,6 +23,8 @@ #ifndef MAPNIK_JSON_FEATURE_GENERATOR_GRAMMAR_HPP #define MAPNIK_JSON_FEATURE_GENERATOR_GRAMMAR_HPP +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + // mapnik #include #include diff --git a/include/mapnik/json/feature_grammar.hpp b/include/mapnik/json/feature_grammar.hpp index 18c2125e2..e26fc4342 100644 --- a/include/mapnik/json/feature_grammar.hpp +++ b/include/mapnik/json/feature_grammar.hpp @@ -30,6 +30,7 @@ #include #include +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // spirit::qi #include #include diff --git a/include/mapnik/json/geometry_generator_grammar.hpp b/include/mapnik/json/geometry_generator_grammar.hpp index 47974c201..a54253e01 100644 --- a/include/mapnik/json/geometry_generator_grammar.hpp +++ b/include/mapnik/json/geometry_generator_grammar.hpp @@ -23,6 +23,7 @@ #ifndef MAPNIK_JSON_GEOMETRY_GENERATOR_GRAMMAR_HPP #define MAPNIK_JSON_GEOMETRY_GENERATOR_GRAMMAR_HPP +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // mapnik #include #include @@ -42,8 +43,6 @@ #include // trunc to avoid needing C++11 -//#define BOOST_SPIRIT_USE_PHOENIX_V3 1 - namespace boost { namespace spirit { namespace traits { // make gcc and darwin toolsets happy. diff --git a/include/mapnik/json/geometry_grammar.hpp b/include/mapnik/json/geometry_grammar.hpp index 32b05ec3d..308f0048a 100644 --- a/include/mapnik/json/geometry_grammar.hpp +++ b/include/mapnik/json/geometry_grammar.hpp @@ -27,6 +27,8 @@ #include // for geometry_type #include // for CommandType +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + // spirit::qi #include #include diff --git a/include/mapnik/path_expression_grammar.hpp b/include/mapnik/path_expression_grammar.hpp index a03511215..68f6e93da 100644 --- a/include/mapnik/path_expression_grammar.hpp +++ b/include/mapnik/path_expression_grammar.hpp @@ -26,6 +26,7 @@ // mapnik #include +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // spirit2 #include #include diff --git a/include/mapnik/placement_finder.hpp b/include/mapnik/placement_finder.hpp index 1c5f67c10..7b6e73369 100644 --- a/include/mapnik/placement_finder.hpp +++ b/include/mapnik/placement_finder.hpp @@ -103,14 +103,14 @@ private: // otherwise it will autodetect the orientation. // If >= 50% of the characters end up upside down, it will be retried the other way. // RETURN: 1/-1 depending which way up the string ends up being. - std::auto_ptr get_placement_offset(std::vector const& path_positions, + std::unique_ptr get_placement_offset(std::vector const& path_positions, std::vector const& path_distances, int & orientation, unsigned index, double distance); ///Tests whether the given text_path be placed without a collision // Returns true if it can // NOTE: This edits p.envelopes so it can be used afterwards (you must clear it otherwise) - bool test_placement(std::auto_ptr const& current_placement, int orientation); + bool test_placement(std::unique_ptr const& current_placement, int orientation); ///Does a line-circle intersect calculation // NOTE: Follow the strict pre conditions diff --git a/include/mapnik/rule_cache.hpp b/include/mapnik/rule_cache.hpp index 4a805b990..920b40334 100644 --- a/include/mapnik/rule_cache.hpp +++ b/include/mapnik/rule_cache.hpp @@ -41,9 +41,9 @@ class rule_cache public: typedef std::vector rule_ptrs; rule_cache() - : if_rules_(), - else_rules_(), - also_rules_() {} + : if_rules_(), + else_rules_(), + also_rules_() {} void add_rule(rule const& r) { @@ -65,12 +65,12 @@ public: { return if_rules_; } - + rule_ptrs const& get_else_rules() const { return else_rules_; } - + rule_ptrs const& get_also_rules() const { return also_rules_; diff --git a/include/mapnik/svg/svg_path_grammar.hpp b/include/mapnik/svg/svg_path_grammar.hpp index 851a501c2..940cdbc76 100644 --- a/include/mapnik/svg/svg_path_grammar.hpp +++ b/include/mapnik/svg/svg_path_grammar.hpp @@ -26,6 +26,7 @@ // mapnik #include +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // spirit #include #include diff --git a/include/mapnik/transform_expression_grammar.hpp b/include/mapnik/transform_expression_grammar.hpp index 886ffaa1f..fb113f07a 100644 --- a/include/mapnik/transform_expression_grammar.hpp +++ b/include/mapnik/transform_expression_grammar.hpp @@ -27,6 +27,7 @@ #include #include +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // spirit #include diff --git a/include/mapnik/util/dasharray_parser.hpp b/include/mapnik/util/dasharray_parser.hpp index e1e4c1271..ba2534bd6 100644 --- a/include/mapnik/util/dasharray_parser.hpp +++ b/include/mapnik/util/dasharray_parser.hpp @@ -23,6 +23,8 @@ #ifndef MAPNIK_UTIL_DASHARRAY_PARSER_HPP #define MAPNIK_UTIL_DASHARRAY_PARSER_HPP +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + #include #include #include @@ -44,10 +46,10 @@ bool parse_dasharray(Iterator first, Iterator last, std::vector& dasharr using qi::lexeme; #endif using phoenix::push_back; - // SVG + // SVG // dasharray ::= (length | percentage) (comma-wsp dasharray)? // no support for 'percentage' as viewport is unknown at load_map - // + // bool r = phrase_parse(first, last, (double_[push_back(phoenix::ref(dasharray), _1)] % #if BOOST_VERSION > 104200 @@ -57,10 +59,10 @@ bool parse_dasharray(Iterator first, Iterator last, std::vector& dasharr #endif | lit("none")), qi::ascii::space); - - if (first != last) + + if (first != last) return false; - + return r; } diff --git a/include/mapnik/util/geometry_svg_generator.hpp b/include/mapnik/util/geometry_svg_generator.hpp index 070521031..d6b8726cb 100644 --- a/include/mapnik/util/geometry_svg_generator.hpp +++ b/include/mapnik/util/geometry_svg_generator.hpp @@ -23,6 +23,8 @@ #ifndef MAPNIK_GEOMETRY_SVG_GENERATOR_HPP #define MAPNIK_GEOMETRY_SVG_GENERATOR_HPP +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + // mapnik #include #include // for container stuff @@ -41,7 +43,6 @@ #include #include -//#define BOOST_SPIRIT_USE_PHOENIX_V3 1 /*! * adapted to conform to the concepts diff --git a/include/mapnik/util/geometry_to_svg.hpp b/include/mapnik/util/geometry_to_svg.hpp index d7294d878..b24a666b7 100644 --- a/include/mapnik/util/geometry_to_svg.hpp +++ b/include/mapnik/util/geometry_to_svg.hpp @@ -28,6 +28,8 @@ #include #include +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + // boost #include diff --git a/include/mapnik/util/geometry_wkt_generator.hpp b/include/mapnik/util/geometry_wkt_generator.hpp index 79f9fe1fd..2fb8a77bb 100644 --- a/include/mapnik/util/geometry_wkt_generator.hpp +++ b/include/mapnik/util/geometry_wkt_generator.hpp @@ -23,11 +23,15 @@ #ifndef MAPNIK_GEOMETRY_WKT_GENERATOR_HPP #define MAPNIK_GEOMETRY_WKT_GENERATOR_HPP +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + // mapnik #include #include #include // for CommandType::SEG_MOVETO +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + // boost #include #include @@ -40,7 +44,7 @@ #include #include // trunc to avoid needing C++11 -//#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + namespace boost { namespace spirit { namespace traits { diff --git a/include/mapnik/wkt/wkt_grammar.hpp b/include/mapnik/wkt/wkt_grammar.hpp index e7e986f59..1d09cda62 100644 --- a/include/mapnik/wkt/wkt_grammar.hpp +++ b/include/mapnik/wkt/wkt_grammar.hpp @@ -23,6 +23,8 @@ #ifndef MAPNIK_WKT_GRAMMAR_HPP #define MAPNIK_WKT_GRAMMAR_HPP +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + #include #include // spirit::qi diff --git a/plugins/input/ogr/ogr_converter.cpp b/plugins/input/ogr/ogr_converter.cpp index 8892ef1f9..cce0336e5 100644 --- a/plugins/input/ogr/ogr_converter.cpp +++ b/plugins/input/ogr/ogr_converter.cpp @@ -79,21 +79,21 @@ void ogr_converter::convert_geometry(OGRGeometry* geom, feature_ptr feature) void ogr_converter::convert_point(OGRPoint* geom, feature_ptr feature) { - std::auto_ptr point(new geometry_type(mapnik::Point)); + std::unique_ptr point(new geometry_type(mapnik::Point)); point->move_to(geom->getX(), geom->getY()); - feature->paths().push_back(point); + feature->paths().push_back(point.release()); } void ogr_converter::convert_linestring(OGRLineString* geom, feature_ptr feature) { int num_points = geom->getNumPoints(); - std::auto_ptr line(new geometry_type(mapnik::LineString)); + std::unique_ptr line(new geometry_type(mapnik::LineString)); line->move_to(geom->getX(0), geom->getY(0)); for (int i = 1; i < num_points; ++i) { line->line_to (geom->getX(i), geom->getY(i)); } - feature->paths().push_back(line); + feature->paths().push_back(line.release()); } void ogr_converter::convert_polygon(OGRPolygon* geom, feature_ptr feature) @@ -108,7 +108,7 @@ void ogr_converter::convert_polygon(OGRPolygon* geom, feature_ptr feature) capacity += interior->getNumPoints(); } - std::auto_ptr poly(new geometry_type(mapnik::Polygon)); + std::unique_ptr poly(new geometry_type(mapnik::Polygon)); poly->move_to(exterior->getX(0), exterior->getY(0)); for (int i = 1; i < num_points; ++i) @@ -127,7 +127,7 @@ void ogr_converter::convert_polygon(OGRPolygon* geom, feature_ptr feature) } poly->close_path(); } - feature->paths().push_back(poly); + feature->paths().push_back(poly.release()); } void ogr_converter::convert_multipoint(OGRMultiPoint* geom, feature_ptr feature) diff --git a/plugins/input/raster/raster_datasource.cpp b/plugins/input/raster/raster_datasource.cpp index 25541857d..9bce16e31 100644 --- a/plugins/input/raster/raster_datasource.cpp +++ b/plugins/input/raster/raster_datasource.cpp @@ -118,7 +118,7 @@ raster_datasource::raster_datasource(parameters const& params) try { - std::auto_ptr reader(mapnik::get_image_reader(filename_, format_)); + std::unique_ptr reader(mapnik::get_image_reader(filename_, format_)); if (reader.get()) { width_ = reader->width(); diff --git a/plugins/input/raster/raster_featureset.cpp b/plugins/input/raster/raster_featureset.cpp index 729052df5..62e5c6401 100644 --- a/plugins/input/raster/raster_featureset.cpp +++ b/plugins/input/raster/raster_featureset.cpp @@ -70,7 +70,7 @@ feature_ptr raster_featureset::next() try { - std::auto_ptr reader(mapnik::get_image_reader(curIter_->file(),curIter_->format())); + std::unique_ptr reader(mapnik::get_image_reader(curIter_->file(),curIter_->format())); MAPNIK_LOG_DEBUG(raster) << "raster_featureset: Reader=" << curIter_->format() << "," << curIter_->file() << ",size(" << curIter_->width() << "," << curIter_->height() << ")"; diff --git a/plugins/input/shape/shape_featureset.cpp b/plugins/input/shape/shape_featureset.cpp index 4550d832b..01176bc48 100644 --- a/plugins/input/shape/shape_featureset.cpp +++ b/plugins/input/shape/shape_featureset.cpp @@ -89,9 +89,9 @@ feature_ptr shape_featureset::next() double y = record.read_double(); if (!filter_.pass(mapnik::box2d(x,y,x,y))) continue; - std::auto_ptr point(new geometry_type(mapnik::Point)); + std::unique_ptr point(new geometry_type(mapnik::Point)); point->move_to(x, y); - feature->paths().push_back(point); + feature->paths().push_back(point.release()); break; } case shape_io::shape_multipoint: @@ -105,9 +105,9 @@ feature_ptr shape_featureset::next() { double x = record.read_double(); double y = record.read_double(); - std::auto_ptr point(new geometry_type(mapnik::Point)); + std::unique_ptr point(new geometry_type(mapnik::Point)); point->move_to(x, y); - feature->paths().push_back(point); + feature->paths().push_back(point.release()); } break; } diff --git a/plugins/input/shape/shape_index_featureset.cpp b/plugins/input/shape/shape_index_featureset.cpp index 78836a030..73871f9e9 100644 --- a/plugins/input/shape/shape_index_featureset.cpp +++ b/plugins/input/shape/shape_index_featureset.cpp @@ -99,9 +99,9 @@ feature_ptr shape_index_featureset::next() { double x = record.read_double(); double y = record.read_double(); - std::auto_ptr point(new geometry_type(mapnik::Point)); + std::unique_ptr point(new geometry_type(mapnik::Point)); point->move_to(x, y); - feature->paths().push_back(point); + feature->paths().push_back(point.release()); break; } case shape_io::shape_multipoint: @@ -115,9 +115,9 @@ feature_ptr shape_index_featureset::next() { double x = record.read_double(); double y = record.read_double(); - std::auto_ptr point(new geometry_type(mapnik::Point)); + std::unique_ptr point(new geometry_type(mapnik::Point)); point->move_to(x, y); - feature->paths().push_back(point); + feature->paths().push_back(point.release()); } break; } diff --git a/plugins/input/shape/shape_io.cpp b/plugins/input/shape/shape_io.cpp index 538d59b29..6493ef248 100644 --- a/plugins/input/shape/shape_io.cpp +++ b/plugins/input/shape/shape_io.cpp @@ -97,7 +97,7 @@ void shape_io::read_polyline( shape_file::record_type & record, mapnik::geometry int num_points = record.read_ndr_integer(); if (num_parts == 1) { - std::auto_ptr line(new geometry_type(mapnik::LineString)); + std::unique_ptr line(new geometry_type(mapnik::LineString)); record.skip(4); double x = record.read_double(); double y = record.read_double(); @@ -108,7 +108,7 @@ void shape_io::read_polyline( shape_file::record_type & record, mapnik::geometry y = record.read_double(); line->line_to(x, y); } - geom.push_back(line); + geom.push_back(line.release()); } else { @@ -121,7 +121,7 @@ void shape_io::read_polyline( shape_file::record_type & record, mapnik::geometry int start, end; for (int k = 0; k < num_parts; ++k) { - std::auto_ptr line(new geometry_type(mapnik::LineString)); + std::unique_ptr line(new geometry_type(mapnik::LineString)); start = parts[k]; if (k == num_parts - 1) { @@ -142,7 +142,7 @@ void shape_io::read_polyline( shape_file::record_type & record, mapnik::geometry y = record.read_double(); line->line_to(x, y); } - geom.push_back(line); + geom.push_back(line.release()); } } } @@ -160,7 +160,7 @@ void shape_io::read_polygon(shape_file::record_type & record, mapnik::geometry_c for (int k = 0; k < num_parts; ++k) { - std::auto_ptr poly(new geometry_type(mapnik::Polygon)); + std::unique_ptr poly(new geometry_type(mapnik::Polygon)); int start = parts[k]; int end; if (k == num_parts - 1) @@ -182,6 +182,6 @@ void shape_io::read_polygon(shape_file::record_type & record, mapnik::geometry_c poly->line_to(x, y); } poly->close_path(); - geom.push_back(poly); + geom.push_back(poly.release()); } } diff --git a/src/conversions.cpp b/src/conversions.cpp index c4abfff54..f7d6d67e6 100644 --- a/src/conversions.cpp +++ b/src/conversions.cpp @@ -26,6 +26,8 @@ #include +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + #include #if _MSC_VER diff --git a/src/expression_grammar.cpp b/src/expression_grammar.cpp index 0894be1c3..3c90f8777 100644 --- a/src/expression_grammar.cpp +++ b/src/expression_grammar.cpp @@ -20,6 +20,8 @@ * *****************************************************************************/ +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + // mapnik #include #include @@ -142,7 +144,7 @@ expression_grammar::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 %= _1] --> FIXME | regex_match_expr[_val = regex_match_(_val, _1)] | regex_replace_expr(_val) [_val = _1] ) diff --git a/src/json/feature_collection_parser.cpp b/src/json/feature_collection_parser.cpp index 97b753480..1daeba75c 100644 --- a/src/json/feature_collection_parser.cpp +++ b/src/json/feature_collection_parser.cpp @@ -22,9 +22,8 @@ // TODO https://github.com/mapnik/mapnik/issues/1658 #include -#if BOOST_VERSION >= 105200 -#define BOOST_SPIRIT_USE_PHOENIX_V3 -#endif + +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // mapnik #include @@ -65,4 +64,3 @@ namespace mapnik { namespace json { template class feature_collection_parser > >; }} - diff --git a/src/json/feature_grammar.cpp b/src/json/feature_grammar.cpp index aa83162bc..0c517072a 100644 --- a/src/json/feature_grammar.cpp +++ b/src/json/feature_grammar.cpp @@ -27,6 +27,7 @@ #include #include +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // boost #include diff --git a/src/json/geojson_generator.cpp b/src/json/geojson_generator.cpp index d178fe8d3..34ec5e811 100644 --- a/src/json/geojson_generator.cpp +++ b/src/json/geojson_generator.cpp @@ -25,6 +25,8 @@ #include #include +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + #if BOOST_VERSION >= 104700 #include @@ -34,26 +36,28 @@ namespace mapnik { namespace json { feature_generator::feature_generator() - : grammar_(new feature_generator_grammar()) {} + : grammar_(0) {} // new feature_generator_grammar()) {} feature_generator::~feature_generator() {} bool feature_generator::generate(std::string & geojson, mapnik::feature_impl const& f) { - sink_type sink(geojson); - return karma::generate(sink, *grammar_,f); + //sink_type sink(geojson); + //return karma::generate(sink, *grammar_,f); + return false; } geometry_generator::geometry_generator() - : grammar_(new multi_geometry_generator_grammar()) {} + : grammar_(0) {} //new multi_geometry_generator_grammar()) {} geometry_generator::~geometry_generator() {} bool geometry_generator::generate(std::string & geojson, mapnik::geometry_container const& g) { - sink_type sink(geojson); - return karma::generate(sink, *grammar_,g); +//sink_type sink(geojson); +// return karma::generate(sink, *grammar_,g); +return false; } }} diff --git a/src/json/geometry_grammar.cpp b/src/json/geometry_grammar.cpp index 84700633b..4ea45350e 100644 --- a/src/json/geometry_grammar.cpp +++ b/src/json/geometry_grammar.cpp @@ -26,6 +26,8 @@ // mapnik #include +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + // boost #include #include diff --git a/src/json/geometry_parser.cpp b/src/json/geometry_parser.cpp index 53c48ff73..f38690f1e 100644 --- a/src/json/geometry_parser.cpp +++ b/src/json/geometry_parser.cpp @@ -21,6 +21,8 @@ *****************************************************************************/ // mapnik +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + #include #include diff --git a/src/marker_cache.cpp b/src/marker_cache.cpp index a0971d035..a5feb4201 100644 --- a/src/marker_cache.cpp +++ b/src/marker_cache.cpp @@ -192,7 +192,7 @@ boost::optional marker_cache::find(std::string const& uri, else { // TODO - support reading images from string - std::auto_ptr reader(mapnik::get_image_reader(uri)); + std::unique_ptr reader(mapnik::get_image_reader(uri)); if (reader.get()) { unsigned width = reader->width(); diff --git a/src/placement_finder.cpp b/src/placement_finder.cpp index 0f7a3906e..0ad39f5c5 100644 --- a/src/placement_finder.cpp +++ b/src/placement_finder.cpp @@ -387,7 +387,7 @@ void placement_finder::find_point_placement(double label_x, double sina = std::sin(rad); double x, y; - std::auto_ptr current_placement(new text_path(label_x, label_y)); + std::unique_ptr current_placement(new text_path(label_x, label_y)); adjust_position(current_placement.get()); @@ -640,10 +640,10 @@ void placement_finder::find_line_placements(PathT & shape_path) { //Record details for the start of the string placement int orientation = 0; - std::auto_ptr current_placement = get_placement_offset(path_positions, path_distances, orientation, index, segment_length - (distance - target_distance) + (diff*dir)); + std::unique_ptr current_placement = get_placement_offset(path_positions, path_distances, orientation, index, segment_length - (distance - target_distance) + (diff*dir)); //We were unable to place here - if (current_placement.get() == NULL) + if (current_placement.get() == nullptr) continue; //Apply displacement @@ -710,7 +710,7 @@ void placement_finder::find_line_placements(PathT & shape_path) } template -std::auto_ptr placement_finder::get_placement_offset(std::vector const& path_positions, +std::unique_ptr placement_finder::get_placement_offset(std::vector const& path_positions, std::vector const& path_distances, int & orientation, unsigned index, @@ -723,7 +723,7 @@ std::auto_ptr placement_finder::get_placement_offset(std:: distance += path_distances[index]; } if (index <= 1 && distance < 0) //We've gone off the start, fail out - return std::auto_ptr(NULL); + return std::unique_ptr(nullptr); //Same thing, checking if we go off the end while (index < path_distances.size() && distance > path_distances[index]) @@ -732,7 +732,7 @@ std::auto_ptr placement_finder::get_placement_offset(std:: index++; } if (index >= path_distances.size()) - return std::auto_ptr(NULL); + return std::unique_ptr(nullptr); //Keep track of the initial index,distance incase we need to re-call get_placement_offset const unsigned initial_index = index; @@ -750,10 +750,10 @@ std::auto_ptr placement_finder::get_placement_offset(std:: double segment_length = path_distances[index]; if (segment_length == 0) { // Not allowed to place across on 0 length segments or discontinuities - return std::auto_ptr(NULL); + return std::unique_ptr(nullptr); } - std::auto_ptr current_placement( + std::unique_ptr current_placement( new text_path((old_x + dx*distance/segment_length), (old_y + dy*distance/segment_length) ) @@ -778,7 +778,7 @@ std::auto_ptr placement_finder::get_placement_offset(std:: //Coordinates this character will start at if (segment_length == 0) { // Not allowed to place across on 0 length segments or discontinuities - return std::auto_ptr(NULL); + return std::unique_ptr(nullptr); } double start_x = old_x + dx*distance/segment_length; double start_y = old_y + dy*distance/segment_length; @@ -806,7 +806,7 @@ std::auto_ptr placement_finder::get_placement_offset(std:: if (index >= path_positions.size()) //Bail out if we run off the end of the shape { //MAPNIK_LOG_ERROR(placement_finder) << "FAIL: Out of space"; - return std::auto_ptr(NULL); + return std::unique_ptr(nullptr); } new_x = path_positions[index].x; new_y = path_positions[index].y; @@ -843,7 +843,7 @@ std::auto_ptr placement_finder::get_placement_offset(std:: std::fabs(angle_delta) > p.max_char_angle_delta) { //MAPNIK_LOG_ERROR(placement_finder) << "FAIL: Too Bendy!"; - return std::auto_ptr(NULL); + return std::unique_ptr(nullptr); } double render_angle = angle; @@ -897,15 +897,15 @@ std::auto_ptr placement_finder::get_placement_offset(std:: { //Otherwise we have failed to find a placement //MAPNIK_LOG_ERROR(placement_finder) << "FAIL: Double upside-down!"; - return std::auto_ptr(NULL); + return std::unique_ptr(nullptr); } } - return current_placement; + return std::move(current_placement); } template -bool placement_finder::test_placement(std::auto_ptr const& current_placement, +bool placement_finder::test_placement(std::unique_ptr const& current_placement, int orientation) { //Create and test envelopes diff --git a/src/text_placements/simple.cpp b/src/text_placements/simple.cpp index ec5f812d0..25bd9d662 100644 --- a/src/text_placements/simple.cpp +++ b/src/text_placements/simple.cpp @@ -26,6 +26,8 @@ #include #include +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + // boost #include #include diff --git a/src/transform_expression_grammar.cpp b/src/transform_expression_grammar.cpp index 4c5ab6d0a..d707bab65 100644 --- a/src/transform_expression_grammar.cpp +++ b/src/transform_expression_grammar.cpp @@ -20,6 +20,7 @@ * *****************************************************************************/ +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // mapnik #include diff --git a/src/wkb.cpp b/src/wkb.cpp index ed8c627c3..cdfa3182e 100644 --- a/src/wkb.cpp +++ b/src/wkb.cpp @@ -250,9 +250,9 @@ private: { double x = read_double(); double y = read_double(); - std::auto_ptr pt(new geometry_type(Point)); + std::unique_ptr pt(new geometry_type(Point)); pt->move_to(x, y); - paths.push_back(pt); + paths.push_back(pt.release()); } void read_multipoint(boost::ptr_vector & paths) @@ -269,10 +269,10 @@ private: { double x = read_double(); double y = read_double(); - std::auto_ptr pt(new geometry_type(Point)); + std::unique_ptr pt(new geometry_type(Point)); pos_ += 8; // double z = read_double(); pt->move_to(x, y); - paths.push_back(pt); + paths.push_back(pt.release()); } void read_multipoint_xyz(boost::ptr_vector & paths) @@ -292,13 +292,13 @@ private: { CoordinateArray ar(num_points); read_coords(ar); - std::auto_ptr line(new geometry_type(LineString)); + std::unique_ptr line(new geometry_type(LineString)); line->move_to(ar[0].x, ar[0].y); for (int i = 1; i < num_points; ++i) { line->line_to(ar[i].x, ar[i].y); } - paths.push_back(line); + paths.push_back(line.release()); } } @@ -319,13 +319,13 @@ private: { CoordinateArray ar(num_points); read_coords_xyz(ar); - std::auto_ptr line(new geometry_type(LineString)); + std::unique_ptr line(new geometry_type(LineString)); line->move_to(ar[0].x, ar[0].y); for (int i = 1; i < num_points; ++i) { line->line_to(ar[i].x, ar[i].y); } - paths.push_back(line); + paths.push_back(line.release()); } } @@ -345,7 +345,7 @@ private: int num_rings = read_integer(); if (num_rings > 0) { - std::auto_ptr poly(new geometry_type(Polygon)); + std::unique_ptr poly(new geometry_type(Polygon)); for (int i = 0; i < num_rings; ++i) { int num_points = read_integer(); @@ -362,7 +362,7 @@ private: } } if (poly->size() > 3) // ignore if polygon has less than (3 + close_path) vertices - paths.push_back(poly); + paths.push_back(poly.release()); } } @@ -381,7 +381,7 @@ private: int num_rings = read_integer(); if (num_rings > 0) { - std::auto_ptr poly(new geometry_type(Polygon)); + std::unique_ptr poly(new geometry_type(Polygon)); for (int i = 0; i < num_rings; ++i) { int num_points = read_integer(); @@ -398,7 +398,7 @@ private: } } if (poly->size() > 2) // ignore if polygon has less than 3 vertices - paths.push_back(poly); + paths.push_back(poly.release()); } } diff --git a/tests/cpp_tests/conversions_test.cpp b/tests/cpp_tests/conversions_test.cpp index 023d7f703..e4fc02b22 100644 --- a/tests/cpp_tests/conversions_test.cpp +++ b/tests/cpp_tests/conversions_test.cpp @@ -1,3 +1,5 @@ +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + #include #include #include diff --git a/tests/cpp_tests/geometry_converters_test.cpp b/tests/cpp_tests/geometry_converters_test.cpp index fbf60a5c0..fc7423c5e 100644 --- a/tests/cpp_tests/geometry_converters_test.cpp +++ b/tests/cpp_tests/geometry_converters_test.cpp @@ -12,7 +12,7 @@ #if BOOST_VERSION >= 104700 #include #include -#include +//#include #endif #include @@ -29,14 +29,14 @@ struct output_geometry_backend { mapnik::vertex2d vtx(mapnik::vertex2d::no_init); path.rewind(0); - std::auto_ptr geom_ptr(new mapnik::geometry_type(type_)); + std::unique_ptr geom_ptr(new mapnik::geometry_type(type_)); while ((vtx.cmd = path.vertex(&vtx.x, &vtx.y)) != mapnik::SEG_END) { //std::cerr << vtx.x << "," << vtx.y << " cmd=" << vtx.cmd << std::endl; geom_ptr->push_vertex(vtx.x, vtx.y, (mapnik::CommandType)vtx.cmd); } - paths_.push_back(geom_ptr); + paths_.push_back(geom_ptr.release()); } boost::ptr_vector & paths_; mapnik::eGeomType type_; diff --git a/tests/cpp_tests/image_io_test.cpp b/tests/cpp_tests/image_io_test.cpp index 42363a3d2..401f5ce91 100644 --- a/tests/cpp_tests/image_io_test.cpp +++ b/tests/cpp_tests/image_io_test.cpp @@ -22,7 +22,7 @@ int main( int, char*[] ) BOOST_TEST( type ); try { - std::auto_ptr reader(mapnik::get_image_reader(should_throw,*type)); + std::unique_ptr reader(mapnik::get_image_reader(should_throw,*type)); BOOST_TEST( false ); } catch (std::exception const&) @@ -36,7 +36,7 @@ int main( int, char*[] ) BOOST_TEST( type ); try { - std::auto_ptr reader(mapnik::get_image_reader(should_throw,*type)); + std::unique_ptr reader(mapnik::get_image_reader(should_throw,*type)); BOOST_TEST( false ); } catch (std::exception const&) @@ -50,7 +50,7 @@ int main( int, char*[] ) BOOST_TEST( type ); try { - std::auto_ptr reader(mapnik::get_image_reader(should_throw,*type)); + std::unique_ptr reader(mapnik::get_image_reader(should_throw,*type)); BOOST_TEST( false ); } catch (std::exception const&) @@ -64,7 +64,7 @@ int main( int, char*[] ) BOOST_TEST( type ); try { - std::auto_ptr reader(mapnik::get_image_reader(should_throw,*type)); + std::unique_ptr reader(mapnik::get_image_reader(should_throw,*type)); BOOST_TEST( false ); } catch (std::exception const&) @@ -78,7 +78,7 @@ int main( int, char*[] ) BOOST_TEST( type ); try { - std::auto_ptr reader(mapnik::get_image_reader(should_throw,*type)); + std::unique_ptr reader(mapnik::get_image_reader(should_throw,*type)); BOOST_TEST( false ); } catch (std::exception const&) diff --git a/tests/cpp_tests/map_request_test.cpp b/tests/cpp_tests/map_request_test.cpp index d14474750..716e41a3b 100644 --- a/tests/cpp_tests/map_request_test.cpp +++ b/tests/cpp_tests/map_request_test.cpp @@ -22,7 +22,7 @@ bool compare_images(std::string const& src_fn,std::string const& dest_fn) { using namespace mapnik; - std::auto_ptr reader1(mapnik::get_image_reader(dest_fn,"png")); + std::unique_ptr reader1(mapnik::get_image_reader(dest_fn,"png")); if (!reader1.get()) { throw mapnik::image_reader_exception("Failed to load: " + dest_fn); @@ -30,7 +30,7 @@ bool compare_images(std::string const& src_fn,std::string const& dest_fn) boost::shared_ptr image_ptr1 = boost::make_shared(reader1->width(),reader1->height()); reader1->read(0,0,image_ptr1->data()); - std::auto_ptr reader2(mapnik::get_image_reader(src_fn,"png")); + std::unique_ptr reader2(mapnik::get_image_reader(src_fn,"png")); if (!reader2.get()) { throw mapnik::image_reader_exception("Failed to load: " + src_fn);