From 58927b404c8028d566debd64a88b963837f76539 Mon Sep 17 00:00:00 2001 From: artemp Date: Wed, 24 Apr 2013 16:40:35 +0100 Subject: [PATCH] c++11 + replace BOOST_FOREACH with for( : ) + remove boost/foreach.hpp + fix benchmarks (17,18) --- benchmark/run.cpp | 126 ++---------------- bindings/python/mapnik_geometry.cpp | 2 +- bindings/python/mapnik_query.cpp | 7 +- bindings/python/python_grid_utils.cpp | 8 +- include/mapnik/cairo_context.hpp | 2 +- .../mapnik/feature_style_processor_impl.hpp | 39 +++--- include/mapnik/font_engine_freetype.hpp | 4 +- include/mapnik/hit_test_filter.hpp | 4 +- include/mapnik/image_filter.hpp | 4 +- include/mapnik/marker_helpers.hpp | 4 +- include/mapnik/polygon_clipper.hpp | 10 +- include/mapnik/svg/svg_renderer_agg.hpp | 4 +- include/mapnik/transform_processor.hpp | 8 +- include/mapnik/vertex_converters.hpp | 2 +- plugins/input/geojson/geojson_datasource.cpp | 4 +- plugins/input/python/python_datasource.cpp | 6 +- src/agg/agg_renderer.cpp | 4 +- src/agg/process_line_pattern_symbolizer.cpp | 4 +- src/agg/process_line_symbolizer.cpp | 6 +- .../process_polygon_pattern_symbolizer.cpp | 4 +- src/agg/process_polygon_symbolizer.cpp | 4 +- src/cairo_renderer.cpp | 6 +- src/deepcopy.cpp | 8 +- src/feature_type_style.cpp | 4 +- src/font_engine_freetype.cpp | 6 +- src/formatting/list.cpp | 13 +- src/grid/process_line_symbolizer.cpp | 5 +- .../process_polygon_pattern_symbolizer.cpp | 5 +- src/grid/process_polygon_symbolizer.cpp | 5 +- src/image_util.cpp | 4 +- src/parse_path.cpp | 12 +- src/placement_finder.cpp | 4 +- src/svg/output/process_symbolizers.cpp | 2 +- src/svg/svg_parser.cpp | 78 +++++------ src/transform_expression.cpp | 4 +- tests/cpp_tests/clipping_test.cpp | 4 +- tests/cpp_tests/geometry_converters_test.cpp | 4 +- tests/cpp_tests/map_request_test.cpp | 4 +- utils/geometry_to_wkb/main.cpp | 6 +- 39 files changed, 157 insertions(+), 273 deletions(-) diff --git a/benchmark/run.cpp b/benchmark/run.cpp index 658df8adf..ece56bde4 100644 --- a/benchmark/run.cpp +++ b/benchmark/run.cpp @@ -410,69 +410,6 @@ struct test8 #include -class rule_cache_move -{ -private: - rule_cache_move(rule_cache_move const& other) = delete; // no copy ctor - rule_cache_move& operator=(rule_cache_move const& other) = delete; // no assignment op -public: - typedef std::vector rule_ptrs; - rule_cache_move() - : if_rules_(), - else_rules_(), - also_rules_() {} - - rule_cache_move(rule_cache_move && rhs) // move ctor - : if_rules_(std::move(rhs.if_rules_)), - else_rules_(std::move(rhs.else_rules_)), - also_rules_(std::move(rhs.also_rules_)) - {} - - rule_cache_move& operator=(rule_cache_move && rhs) // move assign - { - std::swap(if_rules_, rhs.if_rules_); - std::swap(else_rules_,rhs.else_rules_); - std::swap(also_rules_, rhs.also_rules_); - return *this; - } - - void add_rule(rule const& r) - { - if (r.has_else_filter()) - { - else_rules_.push_back(&r); - } - else if (r.has_also_filter()) - { - also_rules_.push_back(&r); - } - else - { - if_rules_.push_back(&r); - } - } - - rule_ptrs const& get_if_rules() const - { - return if_rules_; - } - - rule_ptrs const& get_else_rules() const - { - return else_rules_; - } - - rule_ptrs const& get_also_rules() const - { - return also_rules_; - } - -private: - rule_ptrs if_rules_; - rule_ptrs else_rules_; - rule_ptrs also_rules_; -}; - struct test9 { unsigned iter_; @@ -504,10 +441,10 @@ struct test9 void operator()() { for (unsigned i=0;i rule_caches; + std::vector rule_caches; for (unsigned i=0;i rule_ptrs; - rule_cache_heap() - : if_rules_(), - else_rules_(), - also_rules_() {} - - void add_rule(rule const& r) - { - if (r.has_else_filter()) - { - else_rules_.push_back(&r); - } - else if (r.has_also_filter()) - { - also_rules_.push_back(&r); - } - else - { - if_rules_.push_back(&r); - } - } - - rule_ptrs const& get_if_rules() const - { - return if_rules_; - } - - rule_ptrs const& get_else_rules() const - { - return else_rules_; - } - - rule_ptrs const& get_also_rules() const - { - return also_rules_; - } - -private: - rule_ptrs if_rules_; - rule_ptrs else_rules_; - rule_ptrs also_rules_; -}; - struct test10 { unsigned iter_; @@ -593,9 +484,9 @@ 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); for (unsigned i=0;iadd_rule(rules_[i]); } @@ -646,8 +537,9 @@ struct test11 ps.line_to(extent_.maxx(), extent_.maxy()); ps.line_to(extent_.maxx(), extent_.miny()); ps.close_polygon(); - for (unsigned i=0;i envelope_impl(path_type & p) { mapnik::box2d b; bool first = true; - BOOST_FOREACH(mapnik::geometry_type const& geom, p) + for (mapnik::geometry_type const& geom : p) { if (first) { diff --git a/bindings/python/mapnik_query.cpp b/bindings/python/mapnik_query.cpp index 3c6138a23..a991f2e12 100644 --- a/bindings/python/mapnik_query.cpp +++ b/bindings/python/mapnik_query.cpp @@ -22,7 +22,7 @@ // boost #include -#include + // mapnik #include @@ -55,7 +55,7 @@ struct names_to_list static PyObject* convert(std::set const& names) { boost::python::list l; - BOOST_FOREACH( std::string const& name, names ) + for ( std::string const& name : names ) { l.append(name); } @@ -86,6 +86,3 @@ void export_query() return_value_policy()) ) .def("add_property_name", &query::add_property_name); } - - - diff --git a/bindings/python/python_grid_utils.cpp b/bindings/python/python_grid_utils.cpp index 952f5ce36..0ab20048e 100644 --- a/bindings/python/python_grid_utils.cpp +++ b/bindings/python/python_grid_utils.cpp @@ -23,7 +23,7 @@ // boost #include #include -#include + // mapnik #include @@ -240,7 +240,7 @@ void write_features(T const& grid_type, std::set const& attributes = grid_type.property_names(); typename T::feature_type::const_iterator feat_end = g_features.end(); - BOOST_FOREACH ( std::string const& key_item, key_order ) + for ( std::string const& key_item :key_order ) { if (key_item.empty()) { @@ -256,7 +256,7 @@ void write_features(T const& grid_type, bool found = false; boost::python::dict feat; mapnik::feature_ptr feature = feat_itr->second; - BOOST_FOREACH ( std::string const& attr, attributes ) + for ( std::string const& attr : attributes ) { if (attr == "__id__") { @@ -300,7 +300,7 @@ void grid_encode_utf(T const& grid_type, // convert key order to proper python list boost::python::list keys_a; - BOOST_FOREACH ( typename T::lookup_type const& key_id, key_order ) + for ( typename T::lookup_type const& key_id : key_order ) { keys_a.append(key_id); } diff --git a/include/mapnik/cairo_context.hpp b/include/mapnik/cairo_context.hpp index db4e8b1e3..daa6a3e7e 100644 --- a/include/mapnik/cairo_context.hpp +++ b/include/mapnik/cairo_context.hpp @@ -211,7 +211,7 @@ public: units_ = grad.get_units(); - BOOST_FOREACH ( mapnik::stop_pair const& st, grad.get_stop_array() ) + for ( mapnik::stop_pair const& st : grad.get_stop_array() ) { mapnik::color const& stop_color = st.second; double r= static_cast (stop_color.red())/255.0; diff --git a/include/mapnik/feature_style_processor_impl.hpp b/include/mapnik/feature_style_processor_impl.hpp index ec6b1a5c0..39cfcfab4 100644 --- a/include/mapnik/feature_style_processor_impl.hpp +++ b/include/mapnik/feature_style_processor_impl.hpp @@ -49,7 +49,6 @@ // boost #include #include -#include #include // stl @@ -167,7 +166,7 @@ void feature_style_processor::apply(double scale_denom) scale_denom = mapnik::scale_denominator(m_.scale(),proj.is_geographic()); scale_denom *= scale_factor_; - BOOST_FOREACH ( layer const& lyr, m_.layers() ) + for ( layer const& lyr : m_.layers() ) { if (lyr.visible(scale_denom)) { @@ -341,7 +340,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces { // check for styles needing compositing operations applied // https://github.com/mapnik/mapnik/issues/1477 - BOOST_FOREACH(std::string const& style_name, style_names) + for (std::string const& style_name : style_names) { boost::optional style=m_.find_style(style_name); if (!style) @@ -403,7 +402,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces std::vector rule_caches; // iterate through all named styles collecting active styles and attribute names - BOOST_FOREACH(std::string const& style_name, style_names) + for (std::string const& style_name : style_names) { boost::optional style=m_.find_style(style_name); if (!style) @@ -444,29 +443,29 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces if (p.attribute_collection_policy() == COLLECT_ALL) { layer_descriptor lay_desc = ds->get_descriptor(); - BOOST_FOREACH(attribute_descriptor const& desc, lay_desc.get_descriptors()) + for (attribute_descriptor const& desc : lay_desc.get_descriptors()) { q.add_property_name(desc.get_name()); } } else { - BOOST_FOREACH(std::string const& name, names) + for (std::string const& name : names) { q.add_property_name(name); } } // Update filter_factor for all enabled raster layers. - BOOST_FOREACH (feature_type_style const* style, active_styles) + for (feature_type_style const* style : active_styles) { - BOOST_FOREACH(rule const& r, style->get_rules()) + for (rule const& r : style->get_rules()) { if (r.active(scale_denom) && ds->type() == datasource::Raster && ds->params().get("filter_factor",0.0) == 0.0) { - BOOST_FOREACH (rule::symbolizers::value_type sym, r.get_symbolizers()) + for (rule::symbolizers::value_type sym : r.get_symbolizers()) { // if multiple raster symbolizers, last will be respected // should we warn or throw? @@ -503,7 +502,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces // We're at a value boundary, so render what we have // up to this point. int i = 0; - BOOST_FOREACH (feature_type_style const* style, active_styles) + for (feature_type_style const* style : active_styles) { render_style(lay, p, style, rule_caches[i], style_names[i], cache.features(q), prj_trans); @@ -516,7 +515,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces } int i = 0; - BOOST_FOREACH (feature_type_style const* style, active_styles) + for (feature_type_style const* style : active_styles) { render_style(lay, p, style, rule_caches[i], style_names[i], cache.features(q), prj_trans); @@ -537,18 +536,18 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces } } int i = 0; - BOOST_FOREACH (feature_type_style const* style, active_styles) + for (feature_type_style const* style : active_styles) { render_style(lay, p, style, rule_caches[i], style_names[i], cache.features(q), prj_trans); - i++; + ++i; } } // We only have a single style and no grouping. else { int i = 0; - BOOST_FOREACH (feature_type_style const* style, active_styles) + for (feature_type_style const* style : active_styles) { render_style(lay, p, style, rule_caches[i], style_names[i], ds->features(q), prj_trans); @@ -603,7 +602,7 @@ void feature_style_processor::render_style( bool do_else = true; bool do_also = false; - BOOST_FOREACH(rule const* r, rc.get_if_rules() ) + for (rule const* r : rc.get_if_rules() ) { expression_ptr const& expr=r->get_filter(); value_type result = boost::apply_visitor(evaluate(*feature),*expr); @@ -624,7 +623,7 @@ void feature_style_processor::render_style( if(!p.process(symbols,*feature,prj_trans)) { - BOOST_FOREACH (symbolizer const& sym, symbols) + for (symbolizer const& sym : symbols) { boost::apply_visitor(symbol_dispatch(p,*feature,prj_trans),sym); } @@ -639,7 +638,7 @@ void feature_style_processor::render_style( } if (do_else) { - BOOST_FOREACH( rule const* r, rc.get_else_rules() ) + for (rule const* r : rc.get_else_rules() ) { #if defined(RENDERING_STATS) feat_processed = true; @@ -652,7 +651,7 @@ void feature_style_processor::render_style( // process one by one. if(!p.process(symbols,*feature,prj_trans)) { - BOOST_FOREACH (symbolizer const& sym, symbols) + for (symbolizer const& sym : symbols) { boost::apply_visitor(symbol_dispatch(p,*feature,prj_trans),sym); } @@ -661,7 +660,7 @@ void feature_style_processor::render_style( } if (do_also) { - BOOST_FOREACH( rule const* r, rc.get_also_rules() ) + for ( rule const* r : rc.get_also_rules() ) { #if defined(RENDERING_STATS) feat_processed = true; @@ -674,7 +673,7 @@ void feature_style_processor::render_style( // process one by one. if(!p.process(symbols,*feature,prj_trans)) { - BOOST_FOREACH (symbolizer const& sym, symbols) + for (symbolizer const& sym : symbols) { boost::apply_visitor(symbol_dispatch(p,*feature,prj_trans),sym); } diff --git a/include/mapnik/font_engine_freetype.hpp b/include/mapnik/font_engine_freetype.hpp index 5d4736125..c3e6af289 100644 --- a/include/mapnik/font_engine_freetype.hpp +++ b/include/mapnik/font_engine_freetype.hpp @@ -42,7 +42,7 @@ #include #include #include -#include + #ifdef MAPNIK_THREADSAFE #include #endif @@ -194,7 +194,7 @@ public: { std::vector const& names = fset.get_face_names(); face_set_ptr face_set = boost::make_shared(); - BOOST_FOREACH( std::string const& name, names) + for ( std::string const& name : names) { face_ptr face = get_face(name); if (face) diff --git a/include/mapnik/hit_test_filter.hpp b/include/mapnik/hit_test_filter.hpp index 792c8c12e..18a644a33 100644 --- a/include/mapnik/hit_test_filter.hpp +++ b/include/mapnik/hit_test_filter.hpp @@ -27,7 +27,7 @@ #include #include // boost -#include + namespace mapnik { class hit_test_filter @@ -40,7 +40,7 @@ public: bool pass(Feature & feature) { - BOOST_FOREACH(geometry_type & geom, feature.paths()) + for (geometry_type & geom : feature.paths()) { if (label::hit_test(geom, x_,y_,tol_)) return true; diff --git a/include/mapnik/image_filter.hpp b/include/mapnik/image_filter.hpp index c11bd2e66..18e6a3e38 100644 --- a/include/mapnik/image_filter.hpp +++ b/include/mapnik/image_filter.hpp @@ -32,7 +32,7 @@ #include #include #include -#include + // agg #include "agg_basics.h" @@ -417,7 +417,7 @@ void apply_filter(Src & src, colorize_alpha const& op) double step = 1.0/(size-1); double offset = 0.0; - BOOST_FOREACH( mapnik::filter::color_stop const& stop, op) + for ( mapnik::filter::color_stop const& stop : op) { mapnik::color const& c = stop.color; double stop_offset = stop.offset; diff --git a/include/mapnik/marker_helpers.hpp b/include/mapnik/marker_helpers.hpp index 41431a177..6940a7b47 100644 --- a/include/mapnik/marker_helpers.hpp +++ b/include/mapnik/marker_helpers.hpp @@ -490,7 +490,7 @@ void apply_markers_multi(feature_impl & feature, Converter& converter, markers_s // TODO: consider using true area for polygon types double maxarea = 0; geometry_type* largest = 0; - BOOST_FOREACH(geometry_type & geom, feature.paths()) + for (geometry_type & geom : feature.paths()) { const box2d& env = geom.envelope(); double area = env.width() * env.height(); @@ -511,7 +511,7 @@ void apply_markers_multi(feature_impl & feature, Converter& converter, markers_s { MAPNIK_LOG_WARN(marker_symbolizer) << "marker_multi_policy != 'each' has no effect with marker_placement != 'point'"; } - BOOST_FOREACH(geometry_type & path, feature.paths()) + for (geometry_type & path : feature.paths()) { converter.apply(path); } diff --git a/include/mapnik/polygon_clipper.hpp b/include/mapnik/polygon_clipper.hpp index 7bcb65b85..8d4284a4d 100644 --- a/include/mapnik/polygon_clipper.hpp +++ b/include/mapnik/polygon_clipper.hpp @@ -31,7 +31,7 @@ #include // boost -#include + #include #include #include @@ -189,10 +189,10 @@ private: std::cerr << ex.what() << std::endl; } - BOOST_FOREACH(polygon_2d const& poly, clipped_polygons) + for (polygon_2d const& poly : clipped_polygons) { bool move_to = true; - BOOST_FOREACH(point_2d const& c, boost::geometry::exterior_ring(poly)) + for (point_2d const& c : boost::geometry::exterior_ring(poly)) { if (move_to) { @@ -206,10 +206,10 @@ private: } output_.close_path(); // interior rings - BOOST_FOREACH(polygon_2d::inner_container_type::value_type const& ring, boost::geometry::interior_rings(poly)) + for (polygon_2d::inner_container_type::value_type const& ring : boost::geometry::interior_rings(poly)) { move_to = true; - BOOST_FOREACH(point_2d const& c, ring) + for (point_2d const& c : ring) { if (move_to) { diff --git a/include/mapnik/svg/svg_renderer_agg.hpp b/include/mapnik/svg/svg_renderer_agg.hpp index 778e726ca..90bb636a1 100644 --- a/include/mapnik/svg/svg_renderer_agg.hpp +++ b/include/mapnik/svg/svg_renderer_agg.hpp @@ -31,7 +31,7 @@ #include // boost -#include + // agg #include "agg_path_storage.h" @@ -138,7 +138,7 @@ public: grad.get_control_points(x1,y1,x2,y2,radius); m_gradient_lut.remove_all(); - BOOST_FOREACH ( mapnik::stop_pair const& st, grad.get_stop_array() ) + for ( mapnik::stop_pair const& st : grad.get_stop_array() ) { mapnik::color const& stop_color = st.second; unsigned r = stop_color.red(); diff --git a/include/mapnik/transform_processor.hpp b/include/mapnik/transform_processor.hpp index d720c4350..71cfb42e0 100644 --- a/include/mapnik/transform_processor.hpp +++ b/include/mapnik/transform_processor.hpp @@ -33,10 +33,10 @@ #include // boost -#include + #include #include - +#include // agg #include @@ -190,7 +190,7 @@ struct transform_processor { attribute_collector collect(names); - BOOST_FOREACH (transform_node const& node, list) + for (transform_node const& node : list) { boost::apply_visitor(collect, *node); } @@ -205,7 +205,7 @@ struct transform_processor MAPNIK_LOG_DEBUG(transform) << "transform: begin with " << to_string(matrix_node(tr)); #endif - BOOST_REVERSE_FOREACH (transform_node const& node, list) + for (transform_node const& node : boost::adaptors::reverse(list)) { boost::apply_visitor(eval, *node); #ifdef MAPNIK_LOG diff --git a/include/mapnik/vertex_converters.hpp b/include/mapnik/vertex_converters.hpp index a21d9befc..67c62210a 100644 --- a/include/mapnik/vertex_converters.hpp +++ b/include/mapnik/vertex_converters.hpp @@ -43,7 +43,7 @@ #include #include -#include + #include // mapnik diff --git a/plugins/input/geojson/geojson_datasource.cpp b/plugins/input/geojson/geojson_datasource.cpp index 153597cda..c16be6c1f 100644 --- a/plugins/input/geojson/geojson_datasource.cpp +++ b/plugins/input/geojson/geojson_datasource.cpp @@ -31,7 +31,7 @@ #include #include #include -#include + #include #include #include @@ -123,7 +123,7 @@ geojson_datasource::geojson_datasource(parameters const& params) bool first = true; std::size_t count=0; - BOOST_FOREACH (mapnik::feature_ptr f, features_) + for (mapnik::feature_ptr f : features_) { mapnik::box2d const& box = f->envelope(); if (first) diff --git a/plugins/input/python/python_datasource.cpp b/plugins/input/python/python_datasource.cpp index 3c8795503..ac8c04fc5 100644 --- a/plugins/input/python/python_datasource.cpp +++ b/plugins/input/python/python_datasource.cpp @@ -7,7 +7,7 @@ #include // boost -#include + #include #include #include @@ -26,7 +26,7 @@ python_datasource::python_datasource(parameters const& params) factory_(*params.get("factory", "")) { // extract any remaining parameters as keyword args for the factory - BOOST_FOREACH(const mapnik::parameters::value_type& kv, params) + for (const mapnik::parameters::value_type& kv : params) { if((kv.first != "type") && (kv.first != "factory")) { @@ -73,7 +73,7 @@ python_datasource::python_datasource(parameters const& params) // prepare the arguments boost::python::dict kwargs; typedef std::map::value_type kv_type; - BOOST_FOREACH(const kv_type& kv, kwargs_) + for (kv_type const& kv : kwargs_) { kwargs[boost::python::str(kv.first)] = boost::python::str(kv.second); } diff --git a/src/agg/agg_renderer.cpp b/src/agg/agg_renderer.cpp index f3e6cea3a..f2dd04e65 100644 --- a/src/agg/agg_renderer.cpp +++ b/src/agg/agg_renderer.cpp @@ -265,7 +265,7 @@ void agg_renderer::end_style_processing(feature_type_style const& st) { blend_from = true; mapnik::filter::filter_visitor visitor(*current_buffer_); - BOOST_FOREACH(mapnik::filter::filter_type const& filter_tag, st.image_filters()) + for (mapnik::filter::filter_type const& filter_tag : st.image_filters()) { boost::apply_visitor(visitor, filter_tag); } @@ -282,7 +282,7 @@ void agg_renderer::end_style_processing(feature_type_style const& st) } // apply any 'direct' image filters mapnik::filter::filter_visitor visitor(pixmap_); - BOOST_FOREACH(mapnik::filter::filter_type const& filter_tag, st.direct_image_filters()) + for (mapnik::filter::filter_type const& filter_tag : st.direct_image_filters()) { boost::apply_visitor(visitor, filter_tag); } diff --git a/src/agg/process_line_pattern_symbolizer.cpp b/src/agg/process_line_pattern_symbolizer.cpp index 1f9f679fd..cc9ff6b0e 100644 --- a/src/agg/process_line_pattern_symbolizer.cpp +++ b/src/agg/process_line_pattern_symbolizer.cpp @@ -49,7 +49,7 @@ #include "agg_conv_clip_polyline.h" // boost -#include + namespace { @@ -150,7 +150,7 @@ void agg_renderer::process(line_pattern_symbolizer const& sym, if (sym.simplify_tolerance() > 0.0) converter.set(); // optional simplify converter if (sym.smooth() > 0.0) converter.set(); // optional smooth converter - BOOST_FOREACH(geometry_type & geom, feature.paths()) + for (geometry_type & geom : feature.paths()) { if (geom.size() > 1) { diff --git a/src/agg/process_line_symbolizer.cpp b/src/agg/process_line_symbolizer.cpp index e32b9b257..d540b227b 100644 --- a/src/agg/process_line_symbolizer.cpp +++ b/src/agg/process_line_symbolizer.cpp @@ -44,7 +44,7 @@ #include "agg_rasterizer_outline_aa.h" // boost -#include + // stl #include @@ -129,7 +129,7 @@ void agg_renderer::process(line_symbolizer const& sym, if (sym.simplify_tolerance() > 0.0) converter.set(); // optional simplify converter if (sym.smooth() > 0.0) converter.set(); // optional smooth converter - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for (geometry_type & geom : feature.paths()) { if (geom.size() > 1) { @@ -152,7 +152,7 @@ void agg_renderer::process(line_symbolizer const& sym, if (stroke_.has_dash()) converter.set(); converter.set(); //always stroke - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for (geometry_type & geom : feature.paths()) { if (geom.size() > 1) { diff --git a/src/agg/process_polygon_pattern_symbolizer.cpp b/src/agg/process_polygon_pattern_symbolizer.cpp index da43f91b3..915fe4124 100644 --- a/src/agg/process_polygon_pattern_symbolizer.cpp +++ b/src/agg/process_polygon_pattern_symbolizer.cpp @@ -21,7 +21,7 @@ *****************************************************************************/ // boost -#include + // mapnik #include @@ -157,7 +157,7 @@ void agg_renderer::process(polygon_pattern_symbolizer const& sym, if (sym.simplify_tolerance() > 0.0) converter.set(); // optional simplify converter if (sym.smooth() > 0.0) converter.set(); // optional smooth converter - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for ( geometry_type & geom : feature.paths()) { if (geom.size() > 2) { diff --git a/src/agg/process_polygon_symbolizer.cpp b/src/agg/process_polygon_symbolizer.cpp index febd2a514..962ebe4f8 100644 --- a/src/agg/process_polygon_symbolizer.cpp +++ b/src/agg/process_polygon_symbolizer.cpp @@ -21,7 +21,7 @@ *****************************************************************************/ // boost -#include + // mapnik #include @@ -68,7 +68,7 @@ void agg_renderer::process(polygon_symbolizer const& sym, if (sym.simplify_tolerance() > 0.0) converter.set(); // optional simplify converter if (sym.smooth() > 0.0) converter.set(); // optional smooth converter - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for (geometry_type & geom : feature.paths()) { if (geom.size() > 2) { diff --git a/src/cairo_renderer.cpp b/src/cairo_renderer.cpp index 16d331421..1a649799f 100644 --- a/src/cairo_renderer.cpp +++ b/src/cairo_renderer.cpp @@ -332,7 +332,7 @@ void cairo_renderer_base::process(polygon_symbolizer const& sym, if (sym.simplify_tolerance() > 0.0) converter.set(); // optional simplify converter if (sym.smooth() > 0.0) converter.set(); // optional smooth converter - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for ( geometry_type & geom : feature.paths()) { if (geom.size() > 2) { @@ -495,7 +495,7 @@ void cairo_renderer_base::process(line_symbolizer const& sym, if (sym.simplify_tolerance() > 0.0) converter.set(); // optional simplify converter if (sym.smooth() > 0.0) converter.set(); // optional smooth converter - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for (geometry_type & geom : feature.paths()) { if (geom.size() > 1) { @@ -869,7 +869,7 @@ void cairo_renderer_base::process(polygon_pattern_symbolizer const& sym, if (sym.simplify_tolerance() > 0.0) converter.set(); // optional simplify converter if (sym.smooth() > 0.0) converter.set(); // optional smooth converter - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for ( geometry_type & geom : feature.paths()) { if (geom.size() > 2) { diff --git a/src/deepcopy.cpp b/src/deepcopy.cpp index 3460da544..39a947c15 100644 --- a/src/deepcopy.cpp +++ b/src/deepcopy.cpp @@ -44,7 +44,7 @@ // boost #include -#include + namespace mapnik { namespace util { @@ -98,12 +98,12 @@ namespace mapnik { namespace util { // fontsets typedef std::map fontsets; - BOOST_FOREACH ( fontsets::value_type const& kv,map_in.fontsets()) + for (fontsets::value_type const& kv : map_in.fontsets()) { map_out.insert_fontset(kv.first,kv.second); } - BOOST_FOREACH ( layer const& lyr_in, map_in.layers()) + for ( layer const& lyr_in : map_in.layers()) { layer lyr_out(lyr_in); datasource_ptr ds_in = lyr_in.datasource(); @@ -124,7 +124,7 @@ namespace mapnik { namespace util { typedef style_cont::value_type value_type; style_cont const& styles = map_in.styles(); - BOOST_FOREACH ( value_type const& kv, styles ) + for ( value_type const& kv : styles ) { feature_type_style const& style_in = kv.second; feature_type_style style_out(style_in,true); // deep copy diff --git a/src/feature_type_style.cpp b/src/feature_type_style.cpp index f041b714f..87bbad984 100644 --- a/src/feature_type_style.cpp +++ b/src/feature_type_style.cpp @@ -24,7 +24,7 @@ #include // boost -#include + namespace mapnik { @@ -91,7 +91,7 @@ rules& feature_type_style::get_rules_nonconst() bool feature_type_style::active(double scale_denom) const { - BOOST_FOREACH(rule const& r, rules_) + for (rule const& r : rules_) { if (r.active(scale_denom)) { diff --git a/src/font_engine_freetype.cpp b/src/font_engine_freetype.cpp index 97bdba91e..c5e681328 100644 --- a/src/font_engine_freetype.cpp +++ b/src/font_engine_freetype.cpp @@ -280,7 +280,7 @@ font_face_set::size_type font_face_set::size() const glyph_ptr font_face_set::get_glyph(unsigned c) const { - BOOST_FOREACH ( face_ptr const& face, faces_) + for ( face_ptr const& face : faces_) { FT_UInt g = face->get_char(c); if (g) return boost::make_shared(face, g); @@ -387,7 +387,7 @@ void font_face_set::get_string_info(string_info & info, UnicodeString const& ust void font_face_set::set_pixel_sizes(unsigned size) { - BOOST_FOREACH ( face_ptr const& face, faces_) + for ( face_ptr const& face : faces_) { face->set_pixel_sizes(size); } @@ -395,7 +395,7 @@ void font_face_set::set_pixel_sizes(unsigned size) void font_face_set::set_character_sizes(double size) { - BOOST_FOREACH ( face_ptr const& face, faces_) + for ( face_ptr const& face : faces_) { face->set_character_sizes(size); } diff --git a/src/formatting/list.cpp b/src/formatting/list.cpp index d9ac17374..777e78b85 100644 --- a/src/formatting/list.cpp +++ b/src/formatting/list.cpp @@ -25,7 +25,7 @@ #include // boost -#include + #include namespace mapnik { @@ -36,7 +36,7 @@ namespace formatting { void list_node::to_xml(boost::property_tree::ptree & xml) const { - BOOST_FOREACH(node_ptr const& node, children_) + for (node_ptr const& node : children_) { node->to_xml(xml); } @@ -44,17 +44,17 @@ void list_node::to_xml(boost::property_tree::ptree & xml) const void list_node::apply(char_properties const& p, feature_impl const& feature, processed_text &output) const -{ - BOOST_FOREACH(node_ptr const& node, children_) +{ + for (node_ptr const& node : children_) { node->apply(p, feature, output); - } + } } void list_node::add_expressions(expression_set &output) const { - BOOST_FOREACH(node_ptr const& node, children_) + for (node_ptr const& node : children_) { node->add_expressions(output); } @@ -81,4 +81,3 @@ std::vector const& list_node::get_children() const } } // ns mapnik } // ns formatting - diff --git a/src/grid/process_line_symbolizer.cpp b/src/grid/process_line_symbolizer.cpp index c188b6473..502a85c24 100644 --- a/src/grid/process_line_symbolizer.cpp +++ b/src/grid/process_line_symbolizer.cpp @@ -38,7 +38,7 @@ #include "agg_conv_dash.h" // boost -#include + // stl #include @@ -96,7 +96,7 @@ void grid_renderer::process(line_symbolizer const& sym, if (stroke_.has_dash()) converter.set(); converter.set(); //always stroke - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for ( geometry_type & geom : feature.paths()) { if (geom.size() > 1) { @@ -119,4 +119,3 @@ template void grid_renderer::process(line_symbolizer const&, proj_transform const&); } - diff --git a/src/grid/process_polygon_pattern_symbolizer.cpp b/src/grid/process_polygon_pattern_symbolizer.cpp index 38145858f..956458f18 100644 --- a/src/grid/process_polygon_pattern_symbolizer.cpp +++ b/src/grid/process_polygon_pattern_symbolizer.cpp @@ -21,7 +21,7 @@ *****************************************************************************/ // boost -#include + // mapnik #include @@ -64,7 +64,7 @@ void grid_renderer::process(polygon_pattern_symbolizer const& sym, if (sym.smooth() > 0.0) converter.set(); // optional smooth converter - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for ( geometry_type & geom : feature.paths()) { if (geom.size() > 2) { @@ -96,4 +96,3 @@ template void grid_renderer::process(polygon_pattern_symbolizer const&, proj_transform const&); } - diff --git a/src/grid/process_polygon_symbolizer.cpp b/src/grid/process_polygon_symbolizer.cpp index 5195760f9..ffa79fc6d 100644 --- a/src/grid/process_polygon_symbolizer.cpp +++ b/src/grid/process_polygon_symbolizer.cpp @@ -21,7 +21,7 @@ *****************************************************************************/ // boost -#include + // mapnik #include @@ -69,7 +69,7 @@ void grid_renderer::process(polygon_symbolizer const& sym, if (sym.smooth() > 0.0) converter.set(); // optional smooth converter - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for ( geometry_type & geom : feature.paths()) { if (geom.size() > 2) { @@ -98,4 +98,3 @@ template void grid_renderer::process(polygon_symbolizer const&, proj_transform const&); } - diff --git a/src/image_util.cpp b/src/image_util.cpp index 2e74e6e83..ce4d026da 100644 --- a/src/image_util.cpp +++ b/src/image_util.cpp @@ -68,7 +68,7 @@ extern "C" #endif // boost -#include + #include // stl @@ -149,7 +149,7 @@ void handle_png_options(std::string const& type, if (type.length() > 6){ boost::char_separator sep(":"); boost::tokenizer< boost::char_separator > tokens(type, sep); - BOOST_FOREACH(std::string t, tokens) + for (std::string const& t : tokens) { if (t == "png" || t == "png24" || t == "png32") { diff --git a/src/parse_path.cpp b/src/parse_path.cpp index b502128e4..6cdfabd37 100644 --- a/src/parse_path.cpp +++ b/src/parse_path.cpp @@ -30,7 +30,7 @@ // boost #include -#include + #include namespace mapnik { @@ -44,8 +44,8 @@ path_expression_ptr parse_path(std::string const& str) path_expression_ptr parse_path(std::string const& str, path_expression_grammar const& g) { - path_expression path; - + path_expression path; + std::string::const_iterator itr = str.begin(); std::string::const_iterator end = str.end(); bool r = qi::phrase_parse(itr, end, g, boost::spirit::standard_wide::space, path); @@ -125,7 +125,7 @@ std::string path_processor::evaluate(path_expression const& path,feature_impl co { std::string out; path_processor_detail::path_visitor_ eval(out,f); - BOOST_FOREACH( mapnik::path_component const& token, path) + for ( mapnik::path_component const& token : path) boost::apply_visitor(eval,token); return out; } @@ -134,7 +134,7 @@ std::string path_processor::to_string(path_expression const& path) { std::string str; path_processor_detail::to_string_ visitor(str); - BOOST_FOREACH( mapnik::path_component const& token, path) + for ( mapnik::path_component const& token : path) boost::apply_visitor(visitor,token); return str; } @@ -142,7 +142,7 @@ std::string path_processor::to_string(path_expression const& path) void path_processor::collect_attributes(path_expression const& path, std::set& names) { path_processor_detail::collect_ visitor(names); - BOOST_FOREACH( mapnik::path_component const& token, path) + for ( mapnik::path_component const& token : path) boost::apply_visitor(visitor,token); } diff --git a/src/placement_finder.cpp b/src/placement_finder.cpp index 0ad39f5c5..4532f224c 100644 --- a/src/placement_finder.cpp +++ b/src/placement_finder.cpp @@ -36,7 +36,7 @@ #include #include #include -#include + //stl #include @@ -501,7 +501,7 @@ void placement_finder::find_point_placement(double label_x, // check the placement of any additional envelopes if (!p.allow_overlap && !additional_boxes_.empty()) { - BOOST_FOREACH(box2d const& box, additional_boxes_) + for (box2d const& box : additional_boxes_) { box2d pt(box.minx() + current_placement->center.x, box.miny() + current_placement->center.y, diff --git a/src/svg/output/process_symbolizers.cpp b/src/svg/output/process_symbolizers.cpp index c6db3ea62..088e38b55 100644 --- a/src/svg/output/process_symbolizers.cpp +++ b/src/svg/output/process_symbolizers.cpp @@ -36,7 +36,7 @@ bool svg_renderer::process(rule::symbolizers const& syms, // process each symbolizer to collect its (path) information. // path information (attributes from line_ and polygon_ symbolizers) // is collected with the path_attributes_ data member. - BOOST_FOREACH(symbolizer const& sym, syms) + for (symbolizer const& sym : syms) { boost::apply_visitor(symbol_dispatch(*this, feature, prj_trans), sym); } diff --git a/src/svg/svg_parser.cpp b/src/svg/svg_parser.cpp index 266c8cdb6..a48a65bb0 100644 --- a/src/svg/svg_parser.cpp +++ b/src/svg/svg_parser.cpp @@ -34,7 +34,7 @@ #include #include #include -#include + #include #include @@ -213,7 +213,7 @@ void start_element(svg_parser & parser, xmlTextReaderPtr reader) if (xmlStrEqual(name, BAD_CAST "path")) { parse_path(parser,reader); - } + } else if (xmlStrEqual(name, BAD_CAST "polygon") ) { parse_polygon(parser,reader); @@ -227,7 +227,7 @@ void start_element(svg_parser & parser, xmlTextReaderPtr reader) parse_line(parser,reader); } else if (xmlStrEqual(name, BAD_CAST "rect")) - { + { parse_rect(parser,reader); } else if (xmlStrEqual(name, BAD_CAST "circle")) @@ -416,7 +416,7 @@ void parse_attr(svg_parser & parser, const xmlChar * name, const xmlChar * value void parse_attr(svg_parser & parser, xmlTextReaderPtr reader) { const xmlChar *name, *value; - + if (xmlTextReaderMoveToFirstAttribute(reader) == 1) { do @@ -430,7 +430,7 @@ void parse_attr(svg_parser & parser, xmlTextReaderPtr reader) typedef cont_type::value_type value_type; cont_type vec; parse_style((const char*)value, vec); - BOOST_FOREACH(value_type kv , vec ) + for (value_type kv : vec ) { parse_attr(parser,BAD_CAST kv.first.c_str(),BAD_CAST kv.second.c_str()); } @@ -550,33 +550,33 @@ void parse_line(svg_parser & parser, xmlTextReaderPtr reader) double y2 = 0.0; value = xmlTextReaderGetAttribute(reader, BAD_CAST "x1"); - if (value) + if (value) { x1 = parse_double((const char*)value); xmlFree(value); } - + value = xmlTextReaderGetAttribute(reader, BAD_CAST "y1"); - if (value) + if (value) { y1 = parse_double((const char*)value); xmlFree(value); } - + value = xmlTextReaderGetAttribute(reader, BAD_CAST "x2"); - if (value) + if (value) { x2 = parse_double((const char*)value); xmlFree(value); } - + value = xmlTextReaderGetAttribute(reader, BAD_CAST "y2"); - if (value) + if (value) { y2 = parse_double((const char*)value); xmlFree(value); } - + parser.path_.begin_path(); parser.path_.move_to(x1, y1); parser.path_.line_to(x2, y2); @@ -591,26 +591,26 @@ void parse_circle(svg_parser & parser, xmlTextReaderPtr reader) double cy = 0.0; double r = 0.0; value = xmlTextReaderGetAttribute(reader, BAD_CAST "cx"); - if (value) + if (value) { cx = parse_double((const char*)value); xmlFree(value); } value = xmlTextReaderGetAttribute(reader, BAD_CAST "cy"); - if (value) + if (value) { cy = parse_double((const char*)value); xmlFree(value); } - + value = xmlTextReaderGetAttribute(reader, BAD_CAST "r"); - if (value) + if (value) { r = parse_double((const char*)value); xmlFree(value); } - + parser.path_.begin_path(); if(r != 0.0) @@ -632,33 +632,33 @@ void parse_ellipse(svg_parser & parser, xmlTextReaderPtr reader) double ry = 0.0; value = xmlTextReaderGetAttribute(reader, BAD_CAST "cx"); - if (value) + if (value) { cx = parse_double((const char*)value); xmlFree(value); } - + value = xmlTextReaderGetAttribute(reader, BAD_CAST "cy"); - if (value) + if (value) { cy = parse_double((const char*)value); xmlFree(value); } - + value = xmlTextReaderGetAttribute(reader, BAD_CAST "rx"); - if (value) + if (value) { rx = parse_double((const char*)value); xmlFree(value); } - + value = xmlTextReaderGetAttribute(reader, BAD_CAST "ry"); - if (value) + if (value) { ry = parse_double((const char*)value); xmlFree(value); } - + parser.path_.begin_path(); if(rx != 0.0 && ry != 0.0) @@ -742,7 +742,7 @@ void parse_rect(svg_parser & parser, xmlTextReaderPtr reader) if(rx < 0.0) throw std::runtime_error("parse_rect: Invalid rx"); if(ry < 0.0) throw std::runtime_error("parse_rect: Invalid ry"); parser.path_.begin_path(); - + if(rounded) { agg::rounded_rect r; @@ -778,7 +778,7 @@ void parse_gradient_stop(svg_parser & parser, xmlTextReaderPtr reader) double opacity = 1.0; value = xmlTextReaderGetAttribute(reader, BAD_CAST "offset"); - if (value) + if (value) { offset = parse_double((const char*)value); xmlFree(value); @@ -792,7 +792,7 @@ void parse_gradient_stop(svg_parser & parser, xmlTextReaderPtr reader) cont_type vec; parse_style((const char*)value, vec); - BOOST_FOREACH(value_type kv , vec ) + for (value_type kv : vec ) { if (kv.first == "stop-color") { @@ -870,7 +870,7 @@ bool parse_common_gradient(svg_parser & parser, xmlTextReaderPtr reader) // check if we should inherit from another tag value = xmlTextReaderGetAttribute(reader, BAD_CAST "xlink:href"); - if (value) + if (value) { if (value[0] == '#') { @@ -886,7 +886,7 @@ bool parse_common_gradient(svg_parser & parser, xmlTextReaderPtr reader) } xmlFree(value); } - + value = xmlTextReaderGetAttribute(reader, BAD_CAST "gradientUnits"); if (value) { @@ -900,7 +900,7 @@ bool parse_common_gradient(svg_parser & parser, xmlTextReaderPtr reader) } xmlFree(value); } - + value = xmlTextReaderGetAttribute(reader, BAD_CAST "gradientTransform"); if (value) { @@ -939,14 +939,14 @@ void parse_radial_gradient(svg_parser & parser, xmlTextReaderPtr reader) bool has_percent=true; value = xmlTextReaderGetAttribute(reader, BAD_CAST "cx"); - if (value) + if (value) { cx = parse_double_optional_percent((const char*)value, has_percent); xmlFree(value); } value = xmlTextReaderGetAttribute(reader, BAD_CAST "cy"); - if (value) + if (value) { cy = parse_double_optional_percent((const char*)value, has_percent); xmlFree(value); @@ -1003,28 +1003,28 @@ void parse_linear_gradient(svg_parser & parser, xmlTextReaderPtr reader) bool has_percent=true; value = xmlTextReaderGetAttribute(reader, BAD_CAST "x1"); - if (value) + if (value) { x1 = parse_double_optional_percent((const char*)value, has_percent); xmlFree(value); } value = xmlTextReaderGetAttribute(reader, BAD_CAST "x2"); - if (value) + if (value) { x2 = parse_double_optional_percent((const char*)value, has_percent); xmlFree(value); } value = xmlTextReaderGetAttribute(reader, BAD_CAST "y1"); - if (value) + if (value) { y1 = parse_double_optional_percent((const char*)value, has_percent); xmlFree(value); } - + value = xmlTextReaderGetAttribute(reader, BAD_CAST "y2"); - if (value) + if (value) { y2 = parse_double_optional_percent((const char*)value, has_percent); xmlFree(value); diff --git a/src/transform_expression.cpp b/src/transform_expression.cpp index 157dee202..0bf3b8ec2 100644 --- a/src/transform_expression.cpp +++ b/src/transform_expression.cpp @@ -25,7 +25,7 @@ #include // boost -#include + // stl #include @@ -132,7 +132,7 @@ std::string to_expression_string(transform_list const& list) std::streamsize first = 1; transform_node_to_expression_string to_string(os); - BOOST_FOREACH (transform_node const& node, list) + for (transform_node const& node : list) { os.write(" ", first ? (first = 0) : 1); boost::apply_visitor(to_string, *node); diff --git a/tests/cpp_tests/clipping_test.cpp b/tests/cpp_tests/clipping_test.cpp index 457cacfec..5e37f8f8a 100644 --- a/tests/cpp_tests/clipping_test.cpp +++ b/tests/cpp_tests/clipping_test.cpp @@ -6,7 +6,7 @@ // boost #include #include -#include + // stl #include @@ -52,7 +52,7 @@ void parse_geom(mapnik::geometry_type & geom, std::string const& geom_string) { std::vector vertices; boost::split(vertices, geom_string, boost::is_any_of(",")); - BOOST_FOREACH(std::string const& vert, vertices) + for (std::string const& vert : vertices) { std::vector commands; boost::split(commands, vert, boost::is_any_of(" ")); diff --git a/tests/cpp_tests/geometry_converters_test.cpp b/tests/cpp_tests/geometry_converters_test.cpp index fc7423c5e..90b5c99d4 100644 --- a/tests/cpp_tests/geometry_converters_test.cpp +++ b/tests/cpp_tests/geometry_converters_test.cpp @@ -68,7 +68,7 @@ boost::optional linestring_bbox_clipping(mapnik::box2d bbox throw std::runtime_error("Failed to parse WKT"); } - BOOST_FOREACH( geometry_type & geom, p) + for (geometry_type & geom : p) { converter.apply(geom); } @@ -108,7 +108,7 @@ boost::optional polygon_bbox_clipping(mapnik::box2d bbox, throw std::runtime_error("Failed to parse WKT"); } - BOOST_FOREACH( geometry_type & geom, p) + for (geometry_type & geom : p) { converter.apply(geom); } diff --git a/tests/cpp_tests/map_request_test.cpp b/tests/cpp_tests/map_request_test.cpp index 716e41a3b..05f031993 100644 --- a/tests/cpp_tests/map_request_test.cpp +++ b/tests/cpp_tests/map_request_test.cpp @@ -17,7 +17,7 @@ #include #include #include -#include + bool compare_images(std::string const& src_fn,std::string const& dest_fn) { @@ -100,7 +100,7 @@ int main( int, char*[] ) mapnik::projection map_proj(m.srs(),true); double scale_denom = mapnik::scale_denominator(req.scale(),map_proj.is_geographic()); scale_denom *= scale_factor; - BOOST_FOREACH ( mapnik::layer const& lyr, m.layers() ) + for (mapnik::layer const& lyr : m.layers() ) { if (lyr.visible(scale_denom)) { diff --git a/utils/geometry_to_wkb/main.cpp b/utils/geometry_to_wkb/main.cpp index 5dd23aa32..b8048f283 100644 --- a/utils/geometry_to_wkb/main.cpp +++ b/utils/geometry_to_wkb/main.cpp @@ -29,7 +29,7 @@ #include #include -#include + int main (int argc, char ** argv ) @@ -70,7 +70,7 @@ int main (int argc, char ** argv ) mapnik::query q(ds->envelope()); mapnik::layer_descriptor layer_desc = ds->get_descriptor(); - BOOST_FOREACH ( mapnik::attribute_descriptor const& attr_desc, layer_desc.get_descriptors()) + for (mapnik::attribute_descriptor const& attr_desc : layer_desc.get_descriptors()) { q.add_property_name(attr_desc.get_name()); } @@ -82,7 +82,7 @@ int main (int argc, char ** argv ) { std::cerr << *f << std::endl; boost::ptr_vector & paths = f->paths(); - BOOST_FOREACH ( mapnik::geometry_type const& geom, paths) + for (mapnik::geometry_type const& geom : paths) { // NDR {