diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0df4f091e..e5b33cff8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.6.0 hooks: - id: trailing-whitespace files: ^.*\.cmake|CMakeLists\.txt$ @@ -10,7 +10,7 @@ repos: files: ^.*\.cmake|CMakeLists\.txt$ - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v14.0.6 + rev: v18.1.3 hooks: - id: clang-format types_or: [c++, c] diff --git a/benchmark/include/bench_framework.hpp b/benchmark/include/bench_framework.hpp index 0acfe234e..c51fa4cee 100644 --- a/benchmark/include/bench_framework.hpp +++ b/benchmark/include/bench_framework.hpp @@ -15,8 +15,6 @@ #include // snprintf #include #include -#include -#include #include #include #include diff --git a/benchmark/src/test_getline.cpp b/benchmark/src/test_getline.cpp index d6b6996fa..4cfc5cbbd 100644 --- a/benchmark/src/test_getline.cpp +++ b/benchmark/src/test_getline.cpp @@ -9,7 +9,7 @@ class test : public benchmark::test_case : test_case(params) , line_data_("this is one line\nand this is a second line\nand a third line") { - boost::optional line_data = params.get("line"); + auto line_data = params.get("line"); if (line_data) { line_data_ = *line_data; @@ -57,7 +57,7 @@ class test2 : public benchmark::test_case : test_case(params) , line_data_("this is one line\nand this is a second line\nand a third line") { - boost::optional line_data = params.get("line"); + auto line_data = params.get("line"); if (line_data) { line_data_ = *line_data; diff --git a/benchmark/src/test_rendering.cpp b/benchmark/src/test_rendering.cpp index 3905af922..c28da8859 100644 --- a/benchmark/src/test_rendering.cpp +++ b/benchmark/src/test_rendering.cpp @@ -26,14 +26,14 @@ class test : public benchmark::test_case , scale_factor_(*params.get("scale_factor", 1.0)) , preview_(*params.get("preview", "")) { - boost::optional map = params.get("map"); + const auto map = params.get("map"); if (!map) { throw std::runtime_error("please provide a --map arg"); } xml_ = *map; - boost::optional ext = params.get("extent"); + const auto ext = params.get("extent"); if (ext && !ext->empty()) { if (!extent_.from_string(*ext)) @@ -101,7 +101,7 @@ int main(int argc, char** argv) { mapnik::parameters params; benchmark::handle_args(argc, argv, params); - boost::optional name = params.get("name"); + const auto name = params.get("name"); if (!name) { std::clog << "please provide a name for this test\n"; diff --git a/benchmark/src/test_rendering_shared_map.cpp b/benchmark/src/test_rendering_shared_map.cpp index bf5078bbf..1d7cb8a66 100644 --- a/benchmark/src/test_rendering_shared_map.cpp +++ b/benchmark/src/test_rendering_shared_map.cpp @@ -64,14 +64,14 @@ class test : public benchmark::test_case , preview_(*params.get("preview", "")) , im_(m_->width(), m_->height()) { - boost::optional map = params.get("map"); + const auto map = params.get("map"); if (!map) { throw std::runtime_error("please provide a --map= arg"); } xml_ = *map; - boost::optional ext = params.get("extent"); + auto ext = params.get("extent"); mapnik::load_map(*m_, xml_, true); if (ext && !ext->empty()) { @@ -156,7 +156,7 @@ int main(int argc, char** argv) { mapnik::parameters params; benchmark::handle_args(argc, argv, params); - boost::optional name = params.get("name"); + const auto name = params.get("name"); if (!name) { std::clog << "please provide a name for this test\n"; diff --git a/demo/viewer/mainwindow.cpp b/demo/viewer/mainwindow.cpp index 2b211bca9..908bc1eca 100644 --- a/demo/viewer/mainwindow.cpp +++ b/demo/viewer/mainwindow.cpp @@ -38,7 +38,7 @@ // mapnik #ifndef Q_MOC_RUN // QT moc chokes on BOOST_JOIN -//#include +// #include #include #include #include diff --git a/include/mapnik/attribute_collector.hpp b/include/mapnik/attribute_collector.hpp index 771406faf..72fb16585 100644 --- a/include/mapnik/attribute_collector.hpp +++ b/include/mapnik/attribute_collector.hpp @@ -175,14 +175,14 @@ struct symbolizer_attributes void operator()(raster_symbolizer const& sym) { - boost::optional filter_factor = get_optional(sym, keys::filter_factor); + const auto filter_factor = get_optional(sym, keys::filter_factor); if (filter_factor) { filter_factor_ = *filter_factor; } else { - boost::optional scaling_method = get_optional(sym, keys::scaling); + const auto scaling_method = get_optional(sym, keys::scaling); if (scaling_method && *scaling_method != SCALING_NEAR) { filter_factor_ = 2; diff --git a/include/mapnik/datasource.hpp b/include/mapnik/datasource.hpp index b08a5f993..6145e1b43 100644 --- a/include/mapnik/datasource.hpp +++ b/include/mapnik/datasource.hpp @@ -38,6 +38,7 @@ #include #include #include +#include namespace mapnik { @@ -91,7 +92,7 @@ class MAPNIK_DECL datasource : private util::noncopyable // default implementation without context use features method return features(q); } - virtual boost::optional get_geometry_type() const = 0; + virtual std::optional get_geometry_type() const = 0; virtual featureset_ptr features(query const& q) const = 0; virtual featureset_ptr features_at_point(coord2d const& pt, double tol = 0) const = 0; virtual box2d envelope() const = 0; diff --git a/include/mapnik/debug.hpp b/include/mapnik/debug.hpp index 161bb8298..33f0f1ff1 100644 --- a/include/mapnik/debug.hpp +++ b/include/mapnik/debug.hpp @@ -96,10 +96,7 @@ class MAPNIK_DECL logger : public singleton, } // format - static std::string const& get_format() - { - return format_; - } + static std::string const& get_format() { return format_; } static void set_format(std::string const& format) { @@ -211,10 +208,7 @@ class base_log : public util::noncopyable private: #ifdef MAPNIK_LOG - inline bool check_severity() - { - return Severity >= logger::get_object_severity(object_name_); - } + inline bool check_severity() { return Severity >= logger::get_object_severity(object_name_); } typename output_policy::stream_buffer streambuf_; std::string object_name_; diff --git a/include/mapnik/enumeration.hpp b/include/mapnik/enumeration.hpp index d5b08736e..7a27a45e4 100644 --- a/include/mapnik/enumeration.hpp +++ b/include/mapnik/enumeration.hpp @@ -35,11 +35,7 @@ #include #include #include -#if __cpp_lib_string_view >= 201606L #include -#endif - -#include namespace mapnik { @@ -62,60 +58,9 @@ class illegal_enum_value : public std::exception }; namespace detail { -#if __cpp_lib_string_view >= 201606L -using mapnik_string_view = std::string_view; -#else -class mapnik_string_view // use std::string_view in C++17 -{ - public: - - template - constexpr mapnik_string_view(const char (&s)[N]) - : size_(N) - , data_(s) - {} - - constexpr mapnik_string_view(const char* s, std::size_t N) - : size_(N) - , data_(s) - {} - - constexpr char operator[](std::size_t index) const - { - return (index >= size_) ? throw std::out_of_range("Invalid index.") : data_[index]; - } - - constexpr char const* data() const { return data_; } - - private: - std::size_t size_; - const char* data_; -}; - -constexpr bool mapnik_string_view_equals(mapnik_string_view const& a, char const* b, std::size_t i) -{ - if (a[i] != b[i]) - { - return false; - } - else if (a[i] == 0 || b[i] == 0) - { - return true; - } - else - { - return mapnik_string_view_equals(a, b, i + 1); - } -} - -constexpr bool operator==(mapnik_string_view const& a, char const* b) -{ - return mapnik_string_view_equals(a, b, 0); -} -#endif template -using EnumStringT = std::tuple; +using EnumStringT = std::tuple; template using EnumMapT = std::array, N>; @@ -189,13 +134,13 @@ struct MAPNIK_DECL enumeration std::map fnc_name##_lookup() \ { \ std::map val_map; \ - std::transform( \ - fnc_name##_map.begin(), \ - fnc_name##_map.end(), \ - std::inserter(val_map, val_map.end()), \ - [](const mapnik::detail::EnumStringT& val) { \ - return std::pair{std::get<0>(val), std::string{std::get<1>(val).data()}}; \ - }); \ + std::transform(fnc_name##_map.begin(), \ + fnc_name##_map.end(), \ + std::inserter(val_map, val_map.end()), \ + [](const mapnik::detail::EnumStringT& val) { \ + return std::pair{std::get<0>(val), \ + std::string{std::get<1>(val).data()}}; \ + }); \ return val_map; \ } diff --git a/include/mapnik/evaluate_global_attributes.hpp b/include/mapnik/evaluate_global_attributes.hpp index a2e298789..cb6411fb9 100644 --- a/include/mapnik/evaluate_global_attributes.hpp +++ b/include/mapnik/evaluate_global_attributes.hpp @@ -131,11 +131,11 @@ struct evaluate_expression }; template -struct evaluate_expression +struct evaluate_expression { using value_type = T; - evaluate_expression(boost::none_t) {} + evaluate_expression(std::nullopt_t) {} value_type operator()(attribute const&) const { @@ -265,7 +265,7 @@ std::tuple pre_evaluate_expression(expression_ptr const& expr) { try { - return std::make_tuple(util::apply_visitor(mapnik::evaluate_expression(boost::none), *expr), + return std::make_tuple(util::apply_visitor(mapnik::evaluate_expression(std::nullopt), *expr), true); } catch (...) diff --git a/include/mapnik/extend_converter.hpp b/include/mapnik/extend_converter.hpp index 0e295af01..640e25edd 100644 --- a/include/mapnik/extend_converter.hpp +++ b/include/mapnik/extend_converter.hpp @@ -29,7 +29,6 @@ MAPNIK_DISABLE_WARNING_PUSH MAPNIK_DISABLE_UNUSED_VARIABLE #include -#include #include #include #include @@ -37,6 +36,7 @@ MAPNIK_DISABLE_WARNING_POP // stl #include +#include namespace mapnik { @@ -91,7 +91,7 @@ struct store { m.v2 = m.v1; m.v1 = e.vertex; - m.output = boost::none; + m.output = std::nullopt; } }; @@ -177,7 +177,7 @@ struct extender_def : public msm::front::state_machine_def : extend_length(extend_length) {} - boost::optional output; + std::optional output; vertex2d v1, v2; double extend_length; }; diff --git a/include/mapnik/feature_factory.hpp b/include/mapnik/feature_factory.hpp index 05358d31e..bb2a7dfaf 100644 --- a/include/mapnik/feature_factory.hpp +++ b/include/mapnik/feature_factory.hpp @@ -28,7 +28,7 @@ #include // boost -//#include +// #include namespace mapnik { struct feature_factory diff --git a/include/mapnik/feature_style_processor_impl.hpp b/include/mapnik/feature_style_processor_impl.hpp index 801f3c255..8cd483183 100644 --- a/include/mapnik/feature_style_processor_impl.hpp +++ b/include/mapnik/feature_style_processor_impl.hpp @@ -248,7 +248,7 @@ void feature_style_processor::prepare_layer(layer_rendering_material& box2d buffered_query_ext(query_ext); // buffered double buffer_padding = 2.0 * scale * p.scale_factor(); - boost::optional layer_buffer_size = lay.buffer_size(); + const auto layer_buffer_size = lay.buffer_size(); if (layer_buffer_size) // if layer overrides buffer size, use this value to compute buffered extent { buffer_padding *= *layer_buffer_size; @@ -261,7 +261,7 @@ void feature_style_processor::prepare_layer(layer_rendering_material& buffered_query_ext.height(query_ext.height() + buffer_padding); // clip buffered extent by maximum extent, if supplied - boost::optional> const& maximum_extent = m_.maximum_extent(); + auto&& maximum_extent = m_.maximum_extent(); if (maximum_extent) { buffered_query_ext.clip(*maximum_extent); diff --git a/include/mapnik/feature_type_style.hpp b/include/mapnik/feature_type_style.hpp index a6e63d527..f96989fdf 100644 --- a/include/mapnik/feature_type_style.hpp +++ b/include/mapnik/feature_type_style.hpp @@ -29,15 +29,11 @@ #include #include #include -#include -MAPNIK_DISABLE_WARNING_PUSH -#include -#include -MAPNIK_DISABLE_WARNING_POP // stl #include #include +#include namespace mapnik { @@ -56,7 +52,7 @@ class MAPNIK_DECL feature_type_style std::vector filters_; std::vector direct_filters_; // comp-op - boost::optional comp_op_; + std::optional comp_op_; float opacity_; bool image_filters_inflate_; friend void swap(feature_type_style& lhs, feature_type_style& rhs); @@ -87,7 +83,7 @@ class MAPNIK_DECL feature_type_style std::vector& direct_image_filters(); // compositing void set_comp_op(composite_mode_e comp_op); - boost::optional comp_op() const; + std::optional comp_op() const; void set_opacity(float opacity); float get_opacity() const; void set_image_filters_inflate(bool inflate); diff --git a/include/mapnik/font_engine_freetype.hpp b/include/mapnik/font_engine_freetype.hpp index d2c0d034c..b4ec0dd10 100644 --- a/include/mapnik/font_engine_freetype.hpp +++ b/include/mapnik/font_engine_freetype.hpp @@ -35,11 +35,7 @@ #include #include // pair #include - -namespace boost { -template -class optional; -} +#include namespace mapnik { @@ -117,7 +113,7 @@ class MAPNIK_DECL face_manager face_ptr get_face(std::string const& name); face_set_ptr get_face_set(std::string const& name); face_set_ptr get_face_set(font_set const& fset); - face_set_ptr get_face_set(std::string const& name, boost::optional fset); + face_set_ptr get_face_set(std::string const& name, std::optional fset); stroker_ptr get_stroker() const { return stroker_; } private: diff --git a/include/mapnik/hextree.hpp b/include/mapnik/hextree.hpp index 06aa63f06..7a0f160cc 100644 --- a/include/mapnik/hextree.hpp +++ b/include/mapnik/hextree.hpp @@ -152,10 +152,7 @@ class hextree : private util::noncopyable ~hextree() {} - void setMaxColors(unsigned max_colors) - { - max_colors_ = max_colors; - } + void setMaxColors(unsigned max_colors) { max_colors_ = max_colors; } void setGamma(double g) { @@ -166,15 +163,9 @@ class hextree : private util::noncopyable } } - void setTransMode(unsigned t) - { - trans_mode_ = t; - } + void setTransMode(unsigned t) { trans_mode_ = t; } - transparency_mode_t getTransMode() const - { - return trans_mode_; - } + transparency_mode_t getTransMode() const { return trans_mode_; } // process alpha value based on trans_mode_ std::uint8_t preprocessAlpha(std::uint8_t a) const diff --git a/include/mapnik/image_compositing.hpp b/include/mapnik/image_compositing.hpp index 79aee3a5a..f826621a8 100644 --- a/include/mapnik/image_compositing.hpp +++ b/include/mapnik/image_compositing.hpp @@ -26,14 +26,9 @@ #include #include -#include -MAPNIK_DISABLE_WARNING_PUSH -#include -#include -MAPNIK_DISABLE_WARNING_POP - // stl #include +#include namespace mapnik { @@ -80,8 +75,8 @@ enum composite_mode_e { divide }; -MAPNIK_DECL boost::optional comp_op_from_string(std::string const& name); -MAPNIK_DECL boost::optional comp_op_to_string(composite_mode_e comp_op); +MAPNIK_DECL std::optional comp_op_from_string(std::string const& name); +MAPNIK_DECL std::optional comp_op_to_string(composite_mode_e comp_op); template MAPNIK_DECL void composite(T& dst, T const& src, composite_mode_e mode, float opacity = 1, int dx = 0, int dy = 0); diff --git a/include/mapnik/image_options.hpp b/include/mapnik/image_options.hpp index a9913e3ba..236eacda7 100644 --- a/include/mapnik/image_options.hpp +++ b/include/mapnik/image_options.hpp @@ -25,17 +25,12 @@ #include #include - -#include -MAPNIK_DISABLE_WARNING_PUSH -#include -#include -MAPNIK_DISABLE_WARNING_POP +#include namespace mapnik { -using image_options_map = std::map>; -inline std::string to_string(boost::optional const& val) +using image_options_map = std::map>; +inline std::string to_string(std::optional const& val) { return val ? *val : ""; } diff --git a/include/mapnik/image_reader.hpp b/include/mapnik/image_reader.hpp index 3df39244b..063dea1a9 100644 --- a/include/mapnik/image_reader.hpp +++ b/include/mapnik/image_reader.hpp @@ -30,15 +30,9 @@ #include #include -#include -MAPNIK_DISABLE_WARNING_PUSH -#include -#include -MAPNIK_DISABLE_WARNING_POP - // stl -#include #include +#include namespace mapnik { @@ -62,7 +56,7 @@ struct MAPNIK_DECL image_reader : private util::noncopyable virtual unsigned width() const = 0; virtual unsigned height() const = 0; virtual bool has_alpha() const = 0; - virtual boost::optional> bounding_box() const = 0; + virtual std::optional> bounding_box() const = 0; virtual void read(unsigned x, unsigned y, image_rgba8& image) = 0; virtual image_any read(unsigned x, unsigned y, unsigned width, unsigned height) = 0; virtual ~image_reader() {} diff --git a/include/mapnik/image_scaling.hpp b/include/mapnik/image_scaling.hpp index 15201d8aa..da61c3e42 100644 --- a/include/mapnik/image_scaling.hpp +++ b/include/mapnik/image_scaling.hpp @@ -28,13 +28,8 @@ #include // stl -#include - -#include -MAPNIK_DISABLE_WARNING_PUSH -#include -#include -MAPNIK_DISABLE_WARNING_POP +#include +#include namespace mapnik { @@ -58,8 +53,8 @@ enum scaling_method_e { SCALING_BLACKMAN }; -MAPNIK_DECL boost::optional scaling_method_from_string(std::string const& name); -MAPNIK_DECL boost::optional scaling_method_to_string(scaling_method_e scaling_method); +MAPNIK_DECL std::optional scaling_method_from_string(std::string const& name); +MAPNIK_DECL std::optional scaling_method_to_string(scaling_method_e scaling_method); template MAPNIK_DECL void scale_image_agg(T& target, @@ -70,7 +65,7 @@ MAPNIK_DECL void scale_image_agg(T& target, double x_off_f, double y_off_f, double filter_factor, - boost::optional const& nodata_value); + std::optional const& nodata_value); template inline void scale_image_agg(T& target, T const& source, @@ -89,7 +84,7 @@ inline void scale_image_agg(T& target, x_off_f, y_off_f, filter_factor, - boost::optional()); + std::optional()); } } // namespace mapnik diff --git a/include/mapnik/image_util.hpp b/include/mapnik/image_util.hpp index f701c9494..ae63c5162 100644 --- a/include/mapnik/image_util.hpp +++ b/include/mapnik/image_util.hpp @@ -32,12 +32,12 @@ MAPNIK_DISABLE_WARNING_PUSH #include #include -#include MAPNIK_DISABLE_WARNING_POP // stl #include #include +#include namespace mapnik { @@ -361,25 +361,23 @@ inline bool is_webp(std::string const& filename) return boost::algorithm::iends_with(filename, std::string(".webp")); } -inline boost::optional type_from_filename(std::string const& filename) - +inline std::optional type_from_filename(std::string const& filename) { - using result_type = boost::optional; if (is_png(filename)) - return result_type("png"); + return "png"; if (is_jpeg(filename)) - return result_type("jpeg"); + return "jpeg"; if (is_tiff(filename)) - return result_type("tiff"); + return "tiff"; if (is_pdf(filename)) - return result_type("pdf"); + return "pdf"; if (is_svg(filename)) - return result_type("svg"); + return "svg"; if (is_ps(filename)) - return result_type("ps"); + return "ps"; if (is_webp(filename)) - return result_type("webp"); - return result_type(); + return "webp"; + return std::nullopt; } inline std::string guess_type(std::string const& filename) diff --git a/include/mapnik/json/topology.hpp b/include/mapnik/json/topology.hpp index a15094192..f500f6971 100644 --- a/include/mapnik/json/topology.hpp +++ b/include/mapnik/json/topology.hpp @@ -26,12 +26,7 @@ #include #include -#include -MAPNIK_DISABLE_WARNING_PUSH -#include -#include -MAPNIK_DISABLE_WARNING_POP - +#include #include #include #include @@ -53,37 +48,37 @@ using properties = std::vector; struct point { coordinate coord; - boost::optional props; + std::optional props; }; struct multi_point { std::vector points; - boost::optional props; + std::optional props; }; struct linestring { std::vector rings; - boost::optional props; + std::optional props; }; struct multi_linestring { std::vector> lines; - boost::optional props; + std::optional props; }; struct polygon { std::vector> rings; - boost::optional props; + std::optional props; }; struct multi_polygon { std::vector>> polygons; - boost::optional props; + std::optional props; }; struct empty @@ -118,8 +113,8 @@ struct topology { std::vector geometries; std::vector arcs; - boost::optional tr; - boost::optional bbox; + std::optional tr; + std::optional bbox; }; } // namespace topojson diff --git a/include/mapnik/layer.hpp b/include/mapnik/layer.hpp index ea577965b..190d0c011 100644 --- a/include/mapnik/layer.hpp +++ b/include/mapnik/layer.hpp @@ -210,15 +210,15 @@ class MAPNIK_DECL layer // compositing void set_comp_op(composite_mode_e comp_op); - boost::optional comp_op() const; + std::optional comp_op() const; void set_opacity(double opacity); double get_opacity() const; void set_maximum_extent(box2d const& box); - boost::optional> const& maximum_extent() const; + std::optional> const& maximum_extent() const; void reset_maximum_extent(); void set_buffer_size(int size); - boost::optional const& buffer_size() const; + std::optional const& buffer_size() const; void reset_buffer_size(); ~layer(); @@ -235,9 +235,9 @@ class MAPNIK_DECL layer std::vector styles_; std::vector layers_; datasource_ptr ds_; - boost::optional buffer_size_; - boost::optional> maximum_extent_; - boost::optional comp_op_; + std::optional buffer_size_; + std::optional> maximum_extent_; + std::optional comp_op_; double opacity_; }; } // namespace mapnik diff --git a/include/mapnik/map.hpp b/include/mapnik/map.hpp index 5afc17a7e..01881c3dd 100644 --- a/include/mapnik/map.hpp +++ b/include/mapnik/map.hpp @@ -33,11 +33,8 @@ #include #include #include -#include -MAPNIK_DISABLE_WARNING_PUSH -#include -#include -MAPNIK_DISABLE_WARNING_POP + +#include // stl #include @@ -84,8 +81,8 @@ class MAPNIK_DECL Map : boost::equality_comparable unsigned height_; std::string srs_; int buffer_size_; - boost::optional background_; - boost::optional background_image_; + std::optional background_; + std::optional background_image_; composite_mode_e background_image_comp_op_; float background_image_opacity_; std::map styles_; @@ -93,10 +90,10 @@ class MAPNIK_DECL Map : boost::equality_comparable std::vector layers_; aspect_fix_mode aspectFixMode_; box2d current_extent_; - boost::optional> maximum_extent_; + std::optional> maximum_extent_; std::string base_path_; parameters extra_params_; - boost::optional font_directory_; + std::optional font_directory_; freetype_engine::font_file_mapping_type font_file_mapping_; freetype_engine::font_memory_cache_type font_memory_cache_; @@ -318,7 +315,7 @@ class MAPNIK_DECL Map : boost::equality_comparable * @return Background color as boost::optional * object */ - boost::optional const& background() const; + std::optional const& background() const; /*! \brief Set the map background image filename. * @param image_filename Background image filename. @@ -329,7 +326,7 @@ class MAPNIK_DECL Map : boost::equality_comparable * @return Background image path as std::string * object */ - boost::optional const& background_image() const; + std::optional const& background_image() const; /*! \brief Set the compositing operation uses to blend the background image into the background color. * @param comp_op compositing operation. @@ -369,7 +366,7 @@ class MAPNIK_DECL Map : boost::equality_comparable /*! \brief Get the map maximum extent as box2d */ - boost::optional> const& maximum_extent() const; + std::optional> const& maximum_extent() const; void reset_maximum_extent(); @@ -467,7 +464,7 @@ class MAPNIK_DECL Map : boost::equality_comparable */ void set_extra_parameters(parameters& params); - boost::optional const& font_directory() const { return font_directory_; } + std::optional const& font_directory() const { return font_directory_; } void set_font_directory(std::string const& dir) { font_directory_ = dir; } diff --git a/include/mapnik/mapped_memory_cache.hpp b/include/mapnik/mapped_memory_cache.hpp index 4b3e01797..045f379b4 100644 --- a/include/mapnik/mapped_memory_cache.hpp +++ b/include/mapnik/mapped_memory_cache.hpp @@ -31,12 +31,7 @@ #include #include #include - -#include -MAPNIK_DISABLE_WARNING_PUSH -#include -#include -MAPNIK_DISABLE_WARNING_POP +#include namespace boost { namespace interprocess { @@ -64,7 +59,7 @@ class MAPNIK_DECL mapped_memory_cache : public singleton find(std::string const& key, bool update_cache = false); + std::optional find(std::string const& key, bool update_cache = false); void clear(); }; diff --git a/include/mapnik/memory_datasource.hpp b/include/mapnik/memory_datasource.hpp index 9591c8181..7e799156f 100644 --- a/include/mapnik/memory_datasource.hpp +++ b/include/mapnik/memory_datasource.hpp @@ -46,7 +46,7 @@ class MAPNIK_DECL memory_datasource : public datasource virtual featureset_ptr features(query const& q) const; virtual featureset_ptr features_at_point(coord2d const& pt, double tol = 0) const; virtual box2d envelope() const; - virtual boost::optional get_geometry_type() const; + virtual std::optional get_geometry_type() const; virtual layer_descriptor get_descriptor() const; // void push(feature_ptr feature); diff --git a/include/mapnik/offset_converter.hpp b/include/mapnik/offset_converter.hpp index 938f119d3..8712b61a0 100644 --- a/include/mapnik/offset_converter.hpp +++ b/include/mapnik/offset_converter.hpp @@ -561,15 +561,13 @@ struct offset_converter if (bulge_steps == 0) { // inside turn (sharp/obtuse angle) - MAPNIK_LOG_DEBUG(ctrans) << "offset_converter:" - << " Sharp joint [<< inside turn " + MAPNIK_LOG_DEBUG(ctrans) << "offset_converter:" << " Sharp joint [<< inside turn " << static_cast(util::degrees(joint_angle)) << " degrees >>]"; } else { // outside turn (reflex angle) - MAPNIK_LOG_DEBUG(ctrans) << "offset_converter:" - << " Bulge joint >)) outside turn " + MAPNIK_LOG_DEBUG(ctrans) << "offset_converter:" << " Bulge joint >)) outside turn " << static_cast(util::degrees(joint_angle)) << " degrees ((< with " << bulge_steps << " segments"; } @@ -640,10 +638,7 @@ struct offset_converter return cur_.cmd; } - void push_vertex(vertex2d const& v) - { - vertices_.push_back(v); - } + void push_vertex(vertex2d const& v) { vertices_.push_back(v); } Geometry& geom_; double offset_; diff --git a/include/mapnik/palette.hpp b/include/mapnik/palette.hpp index 0a0216041..7eda359c9 100644 --- a/include/mapnik/palette.hpp +++ b/include/mapnik/palette.hpp @@ -46,7 +46,7 @@ MAPNIK_DISABLE_WARNING_POP #include #include -#define U2RED(x) ((x)&0xff) +#define U2RED(x) ((x) & 0xff) #define U2GREEN(x) (((x) >> 8) & 0xff) #define U2BLUE(x) (((x) >> 16) & 0xff) #define U2ALPHA(x) (((x) >> 24) & 0xff) diff --git a/include/mapnik/params.hpp b/include/mapnik/params.hpp index cc0fd2842..f6da507ed 100644 --- a/include/mapnik/params.hpp +++ b/include/mapnik/params.hpp @@ -28,15 +28,10 @@ #include #include -#include -MAPNIK_DISABLE_WARNING_PUSH -#include -#include -MAPNIK_DISABLE_WARNING_POP - // stl #include #include +#include namespace mapnik { @@ -72,33 +67,33 @@ class MAPNIK_DECL parameters : public param_map public: parameters() {} template - boost::optional get(std::string const& key) const; + std::optional get(std::string const& key) const; template - boost::optional get(std::string const& key, T const& default_opt_value) const; + std::optional get(std::string const& key, T const& default_opt_value) const; }; #ifdef _MSC_VER -template MAPNIK_DECL boost::optional parameters::get(std::string const& key) const; -template MAPNIK_DECL boost::optional parameters::get(std::string const& key, - std::string const& default_opt_value) const; -template MAPNIK_DECL boost::optional parameters::get(std::string const& key) const; -template MAPNIK_DECL boost::optional parameters::get(std::string const& key, - value_double const& default_opt_value) const; +template MAPNIK_DECL std::optional parameters::get(std::string const& key) const; +template MAPNIK_DECL std::optional parameters::get(std::string const& key, + std::string const& default_opt_value) const; +template MAPNIK_DECL std::optional parameters::get(std::string const& key) const; +template MAPNIK_DECL std::optional parameters::get(std::string const& key, + value_double const& default_opt_value) const; -template MAPNIK_DECL boost::optional parameters::get(std::string const& key) const; -template MAPNIK_DECL boost::optional parameters::get(std::string const& key, - value_integer const& default_opt_value) const; +template MAPNIK_DECL std::optional parameters::get(std::string const& key) const; +template MAPNIK_DECL std::optional parameters::get(std::string const& key, + value_integer const& default_opt_value) const; -template MAPNIK_DECL boost::optional parameters::get(std::string const& key) const; -template MAPNIK_DECL boost::optional parameters::get(std::string const& key, - value_bool const& default_opt_value) const; +template MAPNIK_DECL std::optional parameters::get(std::string const& key) const; +template MAPNIK_DECL std::optional parameters::get(std::string const& key, + value_bool const& default_opt_value) const; -template MAPNIK_DECL boost::optional parameters::get(std::string const& key) const; -template MAPNIK_DECL boost::optional +template MAPNIK_DECL std::optional parameters::get(std::string const& key) const; +template MAPNIK_DECL std::optional parameters::get(std::string const& key, mapnik::boolean_type const& default_opt_value) const; -template MAPNIK_DECL boost::optional parameters::get(std::string const& key) const; -template MAPNIK_DECL boost::optional +template MAPNIK_DECL std::optional parameters::get(std::string const& key) const; +template MAPNIK_DECL std::optional parameters::get(std::string const& key, mapnik::value_null const& default_opt_value) const; #endif diff --git a/include/mapnik/params_impl.hpp b/include/mapnik/params_impl.hpp index 0429d1b89..9d25a8957 100644 --- a/include/mapnik/params_impl.hpp +++ b/include/mapnik/params_impl.hpp @@ -32,7 +32,6 @@ #include MAPNIK_DISABLE_WARNING_PUSH #include -#include #include MAPNIK_DISABLE_WARNING_POP @@ -40,6 +39,7 @@ MAPNIK_DISABLE_WARNING_POP #include #include #include +#include namespace mapnik { namespace detail { @@ -47,13 +47,13 @@ namespace detail { template struct extract_value { - static inline boost::optional do_extract_from_string(std::string const& /*source*/) + static inline std::optional do_extract_from_string(std::string const& /*source*/) { std::ostringstream s; s << "No conversion from std::string to " << typeid(T).name(); throw std::runtime_error(s.str()); } - static inline boost::optional do_extract_from_bool(value_bool const& /*source*/) + static inline std::optional do_extract_from_bool(value_bool const& /*source*/) { std::ostringstream s; s << "No conversion from boolean to " << typeid(T).name(); @@ -64,110 +64,103 @@ struct extract_value template<> struct extract_value { - static inline boost::optional do_extract_from_string(std::string const& source) + static inline std::optional do_extract_from_string(std::string const& source) { bool result; if (mapnik::util::string2bool(source, result)) - return boost::optional(result); - return boost::optional(); + return std::optional(result); + return std::nullopt; } - static inline boost::optional do_extract_from_bool(value_bool const& source) - { - return boost::optional(source); - } + static inline std::optional do_extract_from_bool(value_bool const& source) { return source; } }; template<> struct extract_value { - static inline boost::optional do_extract_from_string(std::string const& source) + static inline std::optional do_extract_from_string(std::string const& source) { bool result; if (mapnik::util::string2bool(source, result)) - return boost::optional(result); - return boost::optional(); + return std::optional(result); + return std::nullopt; } - static inline boost::optional do_extract_from_bool(value_bool const& source) + static inline std::optional do_extract_from_bool(value_bool const& source) { - return boost::optional(source); + return std::optional(source); } }; template<> struct extract_value { - static inline boost::optional do_extract_from_string(std::string const& source) + static inline std::optional do_extract_from_string(std::string const& source) { mapnik::value_integer result; if (mapnik::util::string2int(source, result)) - return boost::optional(result); - return boost::optional(); + return std::optional(result); + return std::nullopt; } - static inline boost::optional do_extract_from_bool(value_bool const& source) + static inline std::optional do_extract_from_bool(value_bool const& source) { - return boost::optional(boost::lexical_cast(source)); + return std::optional(boost::lexical_cast(source)); } }; template<> struct extract_value { - static inline boost::optional do_extract_from_string(std::string const& source) + static inline std::optional do_extract_from_string(std::string const& source) { mapnik::value_double result; if (mapnik::util::string2double(source, result)) - return boost::optional(result); - return boost::optional(); + return std::optional(result); + return std::nullopt; } - static inline boost::optional do_extract_from_bool(value_bool const& source) + static inline std::optional do_extract_from_bool(value_bool const& source) { - return boost::optional(boost::lexical_cast(source)); + return std::optional(boost::lexical_cast(source)); } }; template<> struct extract_value { - static inline boost::optional do_extract_from_string(std::string const&) + static inline std::optional do_extract_from_string(std::string const&) { - return boost::optional(); // FIXME + return std::nullopt; // FIXME } - static inline boost::optional do_extract_from_bool(value_bool const&) + static inline std::optional do_extract_from_bool(value_bool const&) { - return boost::optional(); // FIXME + return std::nullopt; // FIXME } }; template<> struct extract_value { - static inline boost::optional do_extract_from_string(std::string const& source) + static inline std::optional do_extract_from_string(std::string const& source) { - return boost::optional(source); + return std::optional(source); } - static inline boost::optional do_extract_from_bool(value_bool const& source) + static inline std::optional do_extract_from_bool(value_bool const& source) { - if (source) - { - return boost::optional("true"); - } - return boost::optional("false"); + return source ? "true" : "false"; } }; template -boost::optional param_cast(std::string const& source) +std::optional param_cast(std::string const& source) { return extract_value::do_extract_from_string(source); } template -boost::optional param_cast(value_bool const& source) +std::optional param_cast(value_bool const& source) { return extract_value::do_extract_from_bool(source); } @@ -177,7 +170,7 @@ boost::optional param_cast(value_bool const& source) template struct value_extractor_visitor { - value_extractor_visitor(boost::optional& var) + value_extractor_visitor(std::optional& var) : var_(var) {} @@ -200,7 +193,7 @@ struct value_extractor_visitor } } - boost::optional& var_; + std::optional& var_; }; namespace params_detail { @@ -209,11 +202,11 @@ template struct converter { using value_type = T; - using return_type = boost::optional; + using return_type = std::optional; static return_type - extract(parameters const& params, std::string const& name, boost::optional const& default_opt_value) + extract(parameters const& params, std::string const& name, std::optional const& default_opt_value) { - boost::optional result(default_opt_value); + std::optional result(default_opt_value); parameters::const_iterator itr = params.find(name); if (itr != params.end()) { @@ -226,15 +219,15 @@ struct converter } // end namespace params_detail template -boost::optional parameters::get(std::string const& key) const +std::optional parameters::get(std::string const& key) const { - return params_detail::converter::extract(*this, key, boost::none); + return params_detail::converter::extract(*this, key, std::nullopt); } template -boost::optional parameters::get(std::string const& key, T const& default_opt_value) const +std::optional parameters::get(std::string const& key, T const& default_opt_value) const { - return params_detail::converter::extract(*this, key, boost::optional(default_opt_value)); + return params_detail::converter::extract(*this, key, std::optional(default_opt_value)); } } // namespace mapnik diff --git a/include/mapnik/projection.hpp b/include/mapnik/projection.hpp index 5b65ea8d8..e7d906795 100644 --- a/include/mapnik/projection.hpp +++ b/include/mapnik/projection.hpp @@ -73,7 +73,7 @@ class MAPNIK_DECL projection bool operator!=(const projection& other) const; bool is_initialized() const; bool is_geographic() const; - boost::optional well_known() const; + std::optional well_known() const; std::string const& params() const; void forward(double& x, double& y) const; void inverse(double& x, double& y) const; diff --git a/include/mapnik/raster.hpp b/include/mapnik/raster.hpp index 99288b039..bd89327a7 100644 --- a/include/mapnik/raster.hpp +++ b/include/mapnik/raster.hpp @@ -29,11 +29,7 @@ #include #include -#include -MAPNIK_DISABLE_WARNING_PUSH -#include -#include -MAPNIK_DISABLE_WARNING_POP +#include namespace mapnik { @@ -44,7 +40,7 @@ class raster : private util::noncopyable box2d query_ext_; image_any data_; double filter_factor_; - boost::optional nodata_; + std::optional nodata_; template raster(box2d const& ext, box2d const& query_ext, ImageData&& data, double filter_factor) @@ -64,7 +60,7 @@ class raster : private util::noncopyable void set_nodata(double _nodata) { nodata_ = _nodata; } - boost::optional const& nodata() const { return nodata_; } + std::optional const& nodata() const { return nodata_; } double get_filter_factor() const { return filter_factor_; } diff --git a/include/mapnik/raster_colorizer.hpp b/include/mapnik/raster_colorizer.hpp index 9813c724a..642e31063 100644 --- a/include/mapnik/raster_colorizer.hpp +++ b/include/mapnik/raster_colorizer.hpp @@ -42,14 +42,9 @@ #include #include -#include -MAPNIK_DISABLE_WARNING_PUSH -#include -#include -MAPNIK_DISABLE_WARNING_POP - #include #include +#include namespace mapnik { @@ -193,7 +188,7 @@ class MAPNIK_DECL raster_colorizer colorizer_stops const& get_stops() const { return stops_; } template - void colorize(image_rgba8& out, T const& in, boost::optional const& nodata, feature_impl const& f) const; + void colorize(image_rgba8& out, T const& in, std::optional const& nodata, feature_impl const& f) const; //! \brief Perform the translation of input to output //! diff --git a/include/mapnik/renderer_common/process_raster_symbolizer.hpp b/include/mapnik/renderer_common/process_raster_symbolizer.hpp index dd11bf61b..6c772d3b9 100644 --- a/include/mapnik/renderer_common/process_raster_symbolizer.hpp +++ b/include/mapnik/renderer_common/process_raster_symbolizer.hpp @@ -31,6 +31,7 @@ #include #include #include +#include #include MAPNIK_DISABLE_WARNING_PUSH @@ -66,7 +67,7 @@ struct image_dispatcher raster_symbolizer const& sym, feature_impl const& feature, F& composite, - boost::optional const& nodata, + std::optional const& nodata, bool need_scaling) : start_x_(start_x) , start_y_(start_y) @@ -156,7 +157,7 @@ struct image_dispatcher raster_symbolizer const& sym_; feature_impl const& feature_; composite_function& composite_; - boost::optional const& nodata_; + std::optional const& nodata_; bool need_scaling_; }; @@ -181,7 +182,7 @@ struct image_warp_dispatcher raster_symbolizer const& sym, feature_impl const& feature, F& composite, - boost::optional const& nodata) + std::optional const& nodata) : prj_trans_(prj_trans) , start_x_(start_x) , start_y_(start_y) @@ -265,7 +266,7 @@ struct image_warp_dispatcher raster_symbolizer const& sym_; feature_impl const& feature_; composite_function& composite_; - boost::optional const& nodata_; + std::optional const& nodata_; }; } // namespace detail diff --git a/include/mapnik/simplify.hpp b/include/mapnik/simplify.hpp index f92d08aad..94688e555 100644 --- a/include/mapnik/simplify.hpp +++ b/include/mapnik/simplify.hpp @@ -6,19 +6,14 @@ // stl #include - -#include -MAPNIK_DISABLE_WARNING_PUSH -#include -#include -MAPNIK_DISABLE_WARNING_POP +#include namespace mapnik { enum simplify_algorithm_e { radial_distance = 0, douglas_peucker, visvalingam_whyatt, zhao_saalfeld }; -MAPNIK_DECL boost::optional simplify_algorithm_from_string(std::string const& name); -MAPNIK_DECL boost::optional simplify_algorithm_to_string(simplify_algorithm_e algorithm); +MAPNIK_DECL std::optional simplify_algorithm_from_string(std::string const& name); +MAPNIK_DECL std::optional simplify_algorithm_to_string(simplify_algorithm_e algorithm); } // namespace mapnik diff --git a/include/mapnik/span_image_filter.hpp b/include/mapnik/span_image_filter.hpp index 72e338686..9f5619724 100644 --- a/include/mapnik/span_image_filter.hpp +++ b/include/mapnik/span_image_filter.hpp @@ -24,13 +24,6 @@ #define MAPNIK_SPAN_IMAGE_FILTER_INCLUDED #include - -#include -MAPNIK_DISABLE_WARNING_PUSH -#include -#include -MAPNIK_DISABLE_WARNING_POP - #include MAPNIK_DISABLE_WARNING_PUSH #include @@ -38,7 +31,7 @@ MAPNIK_DISABLE_WARNING_PUSH #include "agg_span_image_filter_rgba.h" MAPNIK_DISABLE_WARNING_POP -#include +#include namespace mapnik { @@ -58,7 +51,7 @@ class span_image_resample_gray_affine : public agg::span_image_resample_affine const& nodata_value) + std::optional const& nodata_value) : base_type(src, inter, filter) , nodata_value_(nodata_value) {} @@ -152,7 +145,7 @@ class span_image_resample_gray_affine : public agg::span_image_resample_affine nodata_value_; + std::optional nodata_value_; }; template @@ -170,7 +163,7 @@ class span_image_resample_rgba_affine : public agg::span_image_resample_rgba_aff span_image_resample_rgba_affine(source_type& src, interpolator_type& inter, agg::image_filter_lut const& _filter, - boost::optional const& nodata_value) + std::optional const& nodata_value) : agg::span_image_resample_rgba_affine(src, inter, _filter) {} }; diff --git a/include/mapnik/sse.hpp b/include/mapnik/sse.hpp index e2438977d..7cde352ec 100644 --- a/include/mapnik/sse.hpp +++ b/include/mapnik/sse.hpp @@ -26,7 +26,7 @@ #include #include -#define ROUND_DOWN(x, s) ((x) & ~((s)-1)) +#define ROUND_DOWN(x, s) ((x) & ~((s) - 1)) typedef union { __m128i v; diff --git a/include/mapnik/svg/svg_parser.hpp b/include/mapnik/svg/svg_parser.hpp index 909f58e1c..f4c4b9630 100644 --- a/include/mapnik/svg/svg_parser.hpp +++ b/include/mapnik/svg/svg_parser.hpp @@ -35,8 +35,7 @@ #include #include #include -// boost -#include +#include namespace boost { namespace property_tree { @@ -109,7 +108,7 @@ class MAPNIK_DECL svg_parser : private util::noncopyable std::map gradient_map_; std::map const*> node_cache_; mapnik::css_data css_data_; - boost::optional vbox_{}; + std::optional vbox_{}; double normalized_diagonal_ = 0.0; agg::trans_affine viewbox_tr_{}; std::deque font_sizes_{}; diff --git a/include/mapnik/svg/svg_renderer_agg.hpp b/include/mapnik/svg/svg_renderer_agg.hpp index 8afed5c74..91c0fd6f0 100644 --- a/include/mapnik/svg/svg_renderer_agg.hpp +++ b/include/mapnik/svg/svg_renderer_agg.hpp @@ -613,15 +613,9 @@ class renderer_agg : util::noncopyable } #endif - inline VertexSource& source() const - { - return source_; - } + inline VertexSource& source() const { return source_; } - inline group const& svg_group() const - { - return svg_group_; - } + inline group const& svg_group() const { return svg_group_; } private: diff --git a/include/mapnik/symbolizer.hpp b/include/mapnik/symbolizer.hpp index b24dab7e4..be895bcdf 100644 --- a/include/mapnik/symbolizer.hpp +++ b/include/mapnik/symbolizer.hpp @@ -50,12 +50,7 @@ #include #include #include - -#include -MAPNIK_DISABLE_WARNING_PUSH -#include -#include -MAPNIK_DISABLE_WARNING_POP +#include namespace mapnik { @@ -129,21 +124,21 @@ struct enum_traits template<> struct enum_traits { - using result_type = boost::optional; + using result_type = std::optional; static result_type from_string(std::string const& str) { return comp_op_from_string(str); } }; template<> struct enum_traits { - using result_type = boost::optional; + using result_type = std::optional; static result_type from_string(std::string const& str) { return scaling_method_from_string(str); } }; template<> struct enum_traits { - using result_type = boost::optional; + using result_type = std::optional; static result_type from_string(std::string const& str) { return simplify_algorithm_from_string(str); } }; @@ -151,7 +146,7 @@ struct enum_traits template<> \ struct enum_traits \ { \ - using result_type = boost::optional; \ + using result_type = std::optional; \ static result_type from_string(std::string const& str) \ { \ enumeration enum_; \ @@ -433,7 +428,7 @@ T get(symbolizer_base const& sym, } template -boost::optional +std::optional get_optional(symbolizer_base const& sym, keys key, mapnik::feature_impl const& feature, attributes const& vars) { using const_iterator = symbolizer_base::cont_type::const_iterator; @@ -442,7 +437,7 @@ boost::optional { return util::apply_visitor(extract_value(feature, vars), itr->second); } - return boost::optional(); + return std::nullopt; } template @@ -470,7 +465,7 @@ T get(symbolizer_base const& sym, keys key, T const& default_value) } template -boost::optional get_optional(symbolizer_base const& sym, keys key) +std::optional get_optional(symbolizer_base const& sym, keys key) { using const_iterator = symbolizer_base::cont_type::const_iterator; const_iterator itr = sym.properties.find(key); @@ -478,7 +473,7 @@ boost::optional get_optional(symbolizer_base const& sym, keys key) { return util::apply_visitor(extract_raw_value(), itr->second); } - return boost::optional{}; + return std::nullopt; } } // namespace mapnik diff --git a/include/mapnik/symbolizer_utils.hpp b/include/mapnik/symbolizer_utils.hpp index e2deacd62..0d4e0c9e8 100644 --- a/include/mapnik/symbolizer_utils.hpp +++ b/include/mapnik/symbolizer_utils.hpp @@ -384,14 +384,14 @@ struct set_symbolizer_property_impl using value_type = T; try { - boost::optional val = node.get_opt_attr(name); + const auto val = node.get_opt_attr(name); if (val) put(sym, key, *val); } catch (config_error const& ex) { // try parsing as an expression - boost::optional val = node.get_opt_attr(name); + const auto val = node.get_opt_attr(name); if (val) { // first try pre-evaluate expressions which don't have dynamic properties @@ -419,7 +419,7 @@ struct set_symbolizer_property_impl { static void apply(Symbolizer& sym, keys key, std::string const& name, xml_node const& node) { - boost::optional transform = node.get_opt_attr(name); + const auto transform = node.get_opt_attr(name); if (transform) put(sym, key, mapnik::parse_transform(*transform)); } @@ -430,7 +430,7 @@ struct set_symbolizer_property_impl { static void apply(Symbolizer& sym, keys key, std::string const& name, xml_node const& node) { - boost::optional str = node.get_opt_attr(name); + const auto str = node.get_opt_attr(name); if (str) { dash_array dash; @@ -440,14 +440,14 @@ struct set_symbolizer_property_impl } else { - boost::optional val = node.get_opt_attr(name); + const auto val = node.get_opt_attr(name); if (val) { // first try pre-evaluate expressions which don't have dynamic properties - auto result = pre_evaluate_expression(*val); - if (std::get<1>(result)) + const auto [value, is_evaluated] = pre_evaluate_expression(*val); + if (is_evaluated) { - set_property_from_value(sym, key, std::get<0>(result)); + set_property_from_value(sym, key, value); } else { @@ -471,25 +471,24 @@ struct set_symbolizer_property_impl static void apply(Symbolizer& sym, keys key, std::string const& name, xml_node const& node) { using value_type = T; - boost::optional enum_str = node.get_opt_attr(name); + const auto enum_str = node.get_opt_attr(name); if (enum_str) { - boost::optional enum_val = detail::enum_traits::from_string(*enum_str); + const auto enum_val = detail::enum_traits::from_string(*enum_str); if (enum_val) { put(sym, key, *enum_val); } else { - boost::optional val = node.get_opt_attr(name); + const auto val = node.get_opt_attr(name); if (val) { // first try pre-evaluating expression - auto result = pre_evaluate_expression(*val); - if (std::get<1>(result)) + const auto [result_value, is_evaluated] = pre_evaluate_expression(*val); + if (is_evaluated) { - boost::optional enum_val2 = - detail::enum_traits::from_string(std::get<0>(result).to_string()); + const auto enum_val2 = detail::enum_traits::from_string(result_value.to_string()); if (enum_val2) { put(sym, key, *enum_val); diff --git a/include/mapnik/text/formatting/format.hpp b/include/mapnik/text/formatting/format.hpp index e84eb7b53..ecc8455a6 100644 --- a/include/mapnik/text/formatting/format.hpp +++ b/include/mapnik/text/formatting/format.hpp @@ -50,19 +50,19 @@ class MAPNIK_DECL format_node : public node void set_child(node_ptr child); node_ptr get_child() const; - boost::optional face_name; - boost::optional fontset; - boost::optional text_size; - boost::optional character_spacing; - boost::optional line_spacing; - boost::optional text_opacity; - boost::optional wrap_before; - boost::optional repeat_wrap_char; - boost::optional text_transform; - boost::optional fill; - boost::optional halo_fill; - boost::optional halo_radius; - boost::optional ff_settings; + std::optional face_name; + std::optional fontset; + std::optional text_size; + std::optional character_spacing; + std::optional line_spacing; + std::optional text_opacity; + std::optional wrap_before; + std::optional repeat_wrap_char; + std::optional text_transform; + std::optional fill; + std::optional halo_fill; + std::optional halo_radius; + std::optional ff_settings; private: node_ptr child_; diff --git a/include/mapnik/text/formatting/layout.hpp b/include/mapnik/text/formatting/layout.hpp index 80078b0e2..5fc49c025 100644 --- a/include/mapnik/text/formatting/layout.hpp +++ b/include/mapnik/text/formatting/layout.hpp @@ -25,12 +25,7 @@ #include #include - -#include -MAPNIK_DISABLE_WARNING_PUSH -#include -#include -MAPNIK_DISABLE_WARNING_POP +#include namespace mapnik { namespace formatting { @@ -48,18 +43,18 @@ class MAPNIK_DECL layout_node : public node void set_child(node_ptr child); node_ptr get_child() const; // - boost::optional dx; - boost::optional dy; - boost::optional halign; - boost::optional valign; - boost::optional jalign; - boost::optional text_ratio; - boost::optional wrap_width; - boost::optional wrap_char; - boost::optional wrap_before; - boost::optional repeat_wrap_char; - boost::optional rotate_displacement; - boost::optional orientation; + std::optional dx; + std::optional dy; + std::optional halign; + std::optional valign; + std::optional jalign; + std::optional text_ratio; + std::optional wrap_width; + std::optional wrap_char; + std::optional wrap_before; + std::optional repeat_wrap_char; + std::optional rotate_displacement; + std::optional orientation; private: node_ptr child_; diff --git a/include/mapnik/text/properties_util.hpp b/include/mapnik/text/properties_util.hpp index ade172348..6f810907b 100644 --- a/include/mapnik/text/properties_util.hpp +++ b/include/mapnik/text/properties_util.hpp @@ -60,13 +60,13 @@ struct set_property_from_xml_impl { try { - boost::optional val_ = node.get_opt_attr(name); + const auto val_ = node.get_opt_attr(name); if (val_) val = *val_; } catch (config_error const& ex) { - boost::optional val_ = node.get_opt_attr(name); + const auto val_ = node.get_opt_attr(name); if (val_) val = *val_; else @@ -86,13 +86,13 @@ struct set_property_from_xml_impl { try { - boost::optional val_ = node.get_opt_attr(name); + const auto val_ = node.get_opt_attr(name); if (val_) val = *val_; } catch (config_error const& ex) { - boost::optional val_ = node.get_opt_attr(name); + const auto val_ = node.get_opt_attr(name); if (val_) val = *val_; else @@ -112,7 +112,7 @@ struct set_property_from_xml_impl { try { - boost::optional enum_str = node.get_opt_attr(name); + const auto enum_str = node.get_opt_attr(name); if (enum_str) { target_enum_type e; @@ -122,7 +122,7 @@ struct set_property_from_xml_impl } catch (...) { - boost::optional expr = node.get_opt_attr(name); + const auto expr = node.get_opt_attr(name); if (expr) val = *expr; else diff --git a/include/mapnik/text/text_properties.hpp b/include/mapnik/text/text_properties.hpp index 7e157d24a..9d996362d 100644 --- a/include/mapnik/text/text_properties.hpp +++ b/include/mapnik/text/text_properties.hpp @@ -35,11 +35,11 @@ // stl #include +#include #include MAPNIK_DISABLE_WARNING_PUSH #include -#include #include MAPNIK_DISABLE_WARNING_POP @@ -53,7 +53,7 @@ namespace detail { struct evaluated_format_properties { std::string face_name; - boost::optional fontset; + std::optional fontset; double text_size; double character_spacing; double line_spacing; @@ -113,7 +113,7 @@ struct MAPNIK_DECL format_properties void add_expressions(expression_set& output) const; std::string face_name; - boost::optional fontset; + std::optional fontset; // expressions symbolizer_base::value_type text_size; symbolizer_base::value_type character_spacing; diff --git a/include/mapnik/util/file_io.hpp b/include/mapnik/util/file_io.hpp index e29cadfa0..3648dcd87 100644 --- a/include/mapnik/util/file_io.hpp +++ b/include/mapnik/util/file_io.hpp @@ -60,25 +60,13 @@ class file : public util::noncopyable } } - inline bool is_open() const - { - return file_ ? true : false; - } + inline bool is_open() const { return file_ ? true : false; } - explicit operator bool() const - { - return this->is_open(); - } + explicit operator bool() const { return this->is_open(); } - inline std::FILE* get() const - { - return file_.get(); - } + inline std::FILE* get() const { return file_.get(); } - inline std::size_t size() const - { - return size_; - } + inline std::size_t size() const { return size_; } inline data_type data() const { diff --git a/include/mapnik/util/geometry_to_ds_type.hpp b/include/mapnik/util/geometry_to_ds_type.hpp index 164b1d6f3..088af8206 100644 --- a/include/mapnik/util/geometry_to_ds_type.hpp +++ b/include/mapnik/util/geometry_to_ds_type.hpp @@ -32,7 +32,6 @@ #include MAPNIK_DISABLE_WARNING_PUSH #include -#include #include #include MAPNIK_DISABLE_WARNING_POP diff --git a/include/mapnik/util/singleton.hpp b/include/mapnik/util/singleton.hpp index 897fcee69..bfc86913f 100644 --- a/include/mapnik/util/singleton.hpp +++ b/include/mapnik/util/singleton.hpp @@ -77,10 +77,7 @@ class singleton singleton(const singleton& rhs); singleton& operator=(const singleton&); - static void onDeadReference() - { - throw std::runtime_error("dead reference!"); - } + static void onDeadReference() { throw std::runtime_error("dead reference!"); } static void DestroySingleton() { diff --git a/include/mapnik/version.hpp b/include/mapnik/version.hpp index e0d3085ab..2cb80493a 100644 --- a/include/mapnik/version.hpp +++ b/include/mapnik/version.hpp @@ -37,6 +37,6 @@ #define MAPNIK_VERSION_AT_LEAST(major, minor, patch) (MAPNIK_VERSION >= MAPNIK_VERSION_ENCODE(major, minor, patch)) -#define MAPNIK_VERSION_ENCODE(major, minor, patch) ((major)*100000 + (minor)*100 + (patch)) +#define MAPNIK_VERSION_ENCODE(major, minor, patch) ((major) * 100000 + (minor) * 100 + (patch)) #endif // MAPNIK_VERSION_HPP diff --git a/include/mapnik/warp.hpp b/include/mapnik/warp.hpp index f033c0976..4002d014a 100644 --- a/include/mapnik/warp.hpp +++ b/include/mapnik/warp.hpp @@ -40,7 +40,7 @@ MAPNIK_DECL void reproject_and_scale_raster(raster& target, double offset_y, unsigned mesh_size, scaling_method_e scaling_method, - boost::optional const& nodata_value); + std::optional const& nodata_value); MAPNIK_DECL void reproject_and_scale_raster(raster& target, raster const& source, @@ -61,7 +61,7 @@ MAPNIK_DECL void warp_image(T& target, unsigned mesh_size, scaling_method_e scaling_method, double filter_factor, - boost::optional const& nodata_value); + std::optional const& nodata_value); } // namespace mapnik #endif // MAPNIK_WARP_HPP diff --git a/include/mapnik/well_known_srs.hpp b/include/mapnik/well_known_srs.hpp index fe5a1772c..39bf8c4de 100644 --- a/include/mapnik/well_known_srs.hpp +++ b/include/mapnik/well_known_srs.hpp @@ -28,13 +28,8 @@ #include #include -#include -MAPNIK_DISABLE_WARNING_PUSH -#include -#include -MAPNIK_DISABLE_WARNING_POP - // stl +#include #include namespace mapnik { @@ -51,8 +46,8 @@ constexpr double MERC_MAX_LATITUDE = 85.0511287798065923778; extern MAPNIK_DECL std::string const MAPNIK_GEOGRAPHIC_PROJ; extern MAPNIK_DECL std::string const MAPNIK_WEBMERCATOR_PROJ; -MAPNIK_DECL boost::optional is_known_geographic(std::string const& srs); -MAPNIK_DECL boost::optional is_well_known_srs(std::string const& srs); +MAPNIK_DECL std::optional is_known_geographic(std::string const& srs); +MAPNIK_DECL std::optional is_well_known_srs(std::string const& srs); MAPNIK_DECL bool lonlat2merc(double& x, double& y); MAPNIK_DECL bool lonlat2merc(double* x, double* y, std::size_t point_count, std::size_t stride = 1); diff --git a/include/mapnik/xml_attribute_cast.hpp b/include/mapnik/xml_attribute_cast.hpp index a39938e75..25358c8d2 100644 --- a/include/mapnik/xml_attribute_cast.hpp +++ b/include/mapnik/xml_attribute_cast.hpp @@ -36,17 +36,12 @@ #include #include -#include -MAPNIK_DISABLE_WARNING_PUSH -#include -#include -MAPNIK_DISABLE_WARNING_POP - // stl #include #include #include #include +#include #include namespace mapnik { @@ -55,7 +50,7 @@ namespace detail { template struct do_xml_attribute_cast { - static inline boost::optional xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& /*source*/) + static inline std::optional xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& /*source*/) { std::string err_msg("No conversion from std::string to "); err_msg += std::string(typeid(T).name()); @@ -67,13 +62,13 @@ struct do_xml_attribute_cast template<> struct do_xml_attribute_cast { - static inline boost::optional xml_attribute_cast_impl(xml_tree const& /*tree*/, - std::string const& source) + static inline std::optional xml_attribute_cast_impl(xml_tree const& /*tree*/, + std::string const& source) { bool result; if (mapnik::util::string2bool(source, result)) - return boost::optional(result); - return boost::optional(); + return result; + return std::nullopt; } }; @@ -81,13 +76,13 @@ struct do_xml_attribute_cast template<> struct do_xml_attribute_cast { - static inline boost::optional xml_attribute_cast_impl(xml_tree const& /*tree*/, - std::string const& source) + static inline std::optional xml_attribute_cast_impl(xml_tree const& /*tree*/, + std::string const& source) { bool result; if (mapnik::util::string2bool(source, result)) - return boost::optional(result); - return boost::optional(); + return result; + return std::nullopt; } }; @@ -95,12 +90,12 @@ struct do_xml_attribute_cast template<> struct do_xml_attribute_cast { - static inline boost::optional xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source) + static inline std::optional xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source) { int result; if (mapnik::util::string2int(source, result)) - return boost::optional(result); - return boost::optional(); + return result; + return std::nullopt; } }; @@ -109,13 +104,13 @@ struct do_xml_attribute_cast template<> struct do_xml_attribute_cast { - static inline boost::optional xml_attribute_cast_impl(xml_tree const& /*tree*/, - std::string const& source) + static inline std::optional xml_attribute_cast_impl(xml_tree const& /*tree*/, + std::string const& source) { int result; if (mapnik::util::string2int(source, result)) - return boost::optional(result); - return boost::optional(); + return result; + return std::nullopt; } }; @@ -126,12 +121,12 @@ struct do_xml_attribute_cast template<> struct do_xml_attribute_cast { - static inline boost::optional xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source) + static inline std::optional xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source) { int result; if (mapnik::util::string2int(source, result) && result >= 0) - return boost::optional(static_cast(result)); - return boost::optional(); + return static_cast(result); + return std::nullopt; } }; @@ -139,12 +134,12 @@ struct do_xml_attribute_cast template<> struct do_xml_attribute_cast { - static inline boost::optional xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source) + static inline std::optional xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source) { float result; if (mapnik::util::string2float(source, result)) - return boost::optional(result); - return boost::optional(); + return result; + return std::nullopt; } }; @@ -152,12 +147,12 @@ struct do_xml_attribute_cast template<> struct do_xml_attribute_cast { - static inline boost::optional xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source) + static inline std::optional xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source) { double result; if (mapnik::util::string2double(source, result)) - return boost::optional(result); - return boost::optional(); + return result; + return std::nullopt; } }; @@ -169,19 +164,19 @@ template> { using Enum = mapnik::enumeration; - static inline boost::optional xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source) + static inline std::optional xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source) { - using result_type = typename boost::optional; try { Enum e; e.from_string(source); - return result_type(e); + return e; } catch (illegal_enum_value const& ex) { MAPNIK_LOG_ERROR(do_xml_attribute_cast) << ex.what(); - return result_type(); + return std::nullopt; + ; } } }; @@ -190,7 +185,7 @@ struct do_xml_attribute_cast struct do_xml_attribute_cast { - static inline boost::optional xml_attribute_cast_impl(xml_tree const&, std::string const& source) + static inline std::optional xml_attribute_cast_impl(xml_tree const&, std::string const& source) { return parse_color(source); } @@ -200,9 +195,9 @@ struct do_xml_attribute_cast template<> struct do_xml_attribute_cast { - static inline boost::optional xml_attribute_cast_impl(xml_tree const&, std::string const& source) + static inline std::optional xml_attribute_cast_impl(xml_tree const&, std::string const& source) { - return boost::optional(source); + return source; } }; @@ -210,8 +205,8 @@ struct do_xml_attribute_cast template<> struct do_xml_attribute_cast { - static inline boost::optional xml_attribute_cast_impl(xml_tree const& tree, - std::string const& source) + static inline std::optional xml_attribute_cast_impl(xml_tree const& tree, + std::string const& source) { std::map::const_iterator itr = tree.expr_cache_.find(source); if (itr != tree.expr_cache_.end()) @@ -231,8 +226,8 @@ struct do_xml_attribute_cast template<> struct do_xml_attribute_cast { - static inline boost::optional xml_attribute_cast_impl(xml_tree const&, - std::string const& source) + static inline std::optional xml_attribute_cast_impl(xml_tree const&, + std::string const& source) { return mapnik::font_feature_settings(source); } @@ -241,7 +236,7 @@ struct do_xml_attribute_cast } // end namespace detail template -boost::optional xml_attribute_cast(xml_tree const& tree, std::string const& source) +std::optional xml_attribute_cast(xml_tree const& tree, std::string const& source) { return detail::do_xml_attribute_cast::xml_attribute_cast_impl(tree, source); } diff --git a/include/mapnik/xml_node.hpp b/include/mapnik/xml_node.hpp index 734f58d3e..6d9d52931 100644 --- a/include/mapnik/xml_node.hpp +++ b/include/mapnik/xml_node.hpp @@ -26,17 +26,12 @@ // mapnik #include // for MAPNIK_DECL -#include -MAPNIK_DISABLE_WARNING_PUSH -#include -#include -MAPNIK_DISABLE_WARNING_POP - // stl #include #include #include #include +#include namespace mapnik { class MAPNIK_DECL xml_tree; @@ -129,7 +124,7 @@ class MAPNIK_DECL xml_node bool has_attribute(std::string const& name) const; template - boost::optional get_opt_attr(std::string const& name) const; + std::optional get_opt_attr(std::string const& name) const; template T get_attr(std::string const& name, T const& default_opt_value) const; diff --git a/plugins/input/csv/csv_datasource.cpp b/plugins/input/csv/csv_datasource.cpp index 7068882db..55c63c637 100644 --- a/plugins/input/csv/csv_datasource.cpp +++ b/plugins/input/csv/csv_datasource.cpp @@ -96,23 +96,23 @@ csv_datasource::csv_datasource(parameters const& params) separator_ = val.front(); } - boost::optional ext = params.get("extent"); + const auto ext = params.get("extent"); if (ext && !ext->empty()) { extent_initialized_ = extent_.from_string(*ext); } - boost::optional inline_string = params.get("inline"); + const auto inline_string = params.get("inline"); if (inline_string) { inline_string_ = *inline_string; } else { - boost::optional file = params.get("file"); + const auto file = params.get("file"); if (!file) throw mapnik::datasource_exception("CSV Plugin: missing parameter"); - boost::optional base = params.get("base"); + const auto base = params.get("base"); if (base) filename_ = *base + "/" + *file; else @@ -254,9 +254,9 @@ mapnik::layer_descriptor csv_datasource::get_descriptor() const return desc_; } -boost::optional csv_datasource::get_geometry_type_impl(std::istream& stream) const +std::optional csv_datasource::get_geometry_type_impl(std::istream& stream) const { - boost::optional result; + std::optional result; if (tree_) { int multi_type = 0; @@ -282,7 +282,7 @@ boost::optional csv_datasource::get_geometry_type int type = static_cast(*result); if (multi_type > 0 && multi_type != type) { - result.reset(mapnik::datasource_geometry_t::Collection); + result = mapnik::datasource_geometry_t::Collection; return result; } multi_type = type; @@ -329,7 +329,7 @@ boost::optional csv_datasource::get_geometry_type int type = static_cast(*result); if (multi_type > 0 && multi_type != type) { - result.reset(mapnik::datasource_geometry_t::Collection); + result = mapnik::datasource_geometry_t::Collection; return result; } multi_type = type; @@ -347,7 +347,7 @@ boost::optional csv_datasource::get_geometry_type return result; } -boost::optional csv_datasource::get_geometry_type() const +std::optional csv_datasource::get_geometry_type() const { if (inline_string_.empty()) { diff --git a/plugins/input/csv/csv_datasource.hpp b/plugins/input/csv/csv_datasource.hpp index 9a710f25f..e300386ff 100644 --- a/plugins/input/csv/csv_datasource.hpp +++ b/plugins/input/csv/csv_datasource.hpp @@ -32,12 +32,12 @@ #include #include #include +#include #include "csv_utils.hpp" #include MAPNIK_DISABLE_WARNING_PUSH #include -#include #include #include #include @@ -45,11 +45,8 @@ MAPNIK_DISABLE_WARNING_POP // stl #include -#include #include -#include - template struct csv_linear : boost::geometry::index::linear {}; @@ -93,18 +90,18 @@ class csv_datasource : public mapnik::datasource, csv_datasource(mapnik::parameters const& params); virtual ~csv_datasource(); - mapnik::datasource::datasource_t type() const; + mapnik::datasource::datasource_t type() const override; static const char* name(); - mapnik::featureset_ptr features(mapnik::query const& q) const; - mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const; - mapnik::box2d envelope() const; - mapnik::layer_descriptor get_descriptor() const; - boost::optional get_geometry_type() const; + mapnik::featureset_ptr features(mapnik::query const& q) const override; + mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const override; + mapnik::box2d envelope() const override; + mapnik::layer_descriptor get_descriptor() const override; + std::optional get_geometry_type() const override; private: void parse_csv(std::istream&); - virtual void add_feature(mapnik::value_integer index, mapnik::csv_line const& values); - boost::optional get_geometry_type_impl(std::istream&) const; + virtual void add_feature(mapnik::value_integer index, mapnik::csv_line const& values) override; + std::optional get_geometry_type_impl(std::istream&) const; mapnik::layer_descriptor desc_; std::string filename_; diff --git a/plugins/input/csv/csv_featureset.cpp b/plugins/input/csv/csv_featureset.cpp index 272970236..b32553ccb 100644 --- a/plugins/input/csv/csv_featureset.cpp +++ b/plugins/input/csv/csv_featureset.cpp @@ -59,8 +59,8 @@ csv_featureset::csv_featureset(std::string const& filename, , tr_("utf8") { #if defined(MAPNIK_MEMORY_MAPPED_FILE) - boost::optional memory = mapnik::mapped_memory_cache::instance().find(filename, true); - if (memory) + const auto memory = mapnik::mapped_memory_cache::instance().find(filename, true); + if (memory.has_value()) { mapped_region_ = *memory; } diff --git a/plugins/input/csv/csv_index_featureset.cpp b/plugins/input/csv/csv_index_featureset.cpp index cbcbb9cfa..3d5a37bce 100644 --- a/plugins/input/csv/csv_index_featureset.cpp +++ b/plugins/input/csv/csv_index_featureset.cpp @@ -57,8 +57,8 @@ csv_index_featureset::csv_index_featureset(std::string const& filename, { #if defined(MAPNIK_MEMORY_MAPPED_FILE) - boost::optional memory = mapnik::mapped_memory_cache::instance().find(filename, true); - if (memory) + const auto memory = mapnik::mapped_memory_cache::instance().find(filename, true); + if (memory.has_value()) { mapped_region_ = *memory; } diff --git a/plugins/input/gdal/gdal_datasource.cpp b/plugins/input/gdal/gdal_datasource.cpp index f86e17361..d6d3484ad 100644 --- a/plugins/input/gdal/gdal_datasource.cpp +++ b/plugins/input/gdal/gdal_datasource.cpp @@ -32,8 +32,6 @@ #include -#include - using mapnik::datasource; using mapnik::parameters; @@ -69,12 +67,12 @@ gdal_datasource::gdal_datasource(parameters const& params) mapnik::progress_timer __stats__(std::clog, "gdal_datasource::init"); #endif - boost::optional file = params.get("file"); - if (!file) + auto file = params.get("file"); + if (!file.has_value()) throw datasource_exception("missing parameter"); - boost::optional base = params.get("base"); - if (base) + auto base = params.get("base"); + if (base.has_value()) { dataset_name_ = *base + "/" + *file; } @@ -120,8 +118,8 @@ gdal_datasource::gdal_datasource(parameters const& params) double tr[6]; bool bbox_override = false; - boost::optional bbox_s = params.get("extent"); - if (bbox_s) + const auto bbox_s = params.get("extent"); + if (bbox_s.has_value()) { MAPNIK_LOG_DEBUG(gdal) << "gdal_datasource: BBox Parameter=" << *bbox_s; @@ -212,9 +210,9 @@ box2d gdal_datasource::envelope() const return extent_; } -boost::optional gdal_datasource::get_geometry_type() const +std::optional gdal_datasource::get_geometry_type() const { - return boost::optional(); + return std::nullopt; } layer_descriptor gdal_datasource::get_descriptor() const diff --git a/plugins/input/gdal/gdal_datasource.hpp b/plugins/input/gdal/gdal_datasource.hpp index 2dad23023..269efd1b5 100644 --- a/plugins/input/gdal/gdal_datasource.hpp +++ b/plugins/input/gdal/gdal_datasource.hpp @@ -49,13 +49,13 @@ class gdal_datasource : public mapnik::datasource public: gdal_datasource(mapnik::parameters const& params); virtual ~gdal_datasource(); - mapnik::datasource::datasource_t type() const; + mapnik::datasource::datasource_t type() const override; static const char* name(); - mapnik::featureset_ptr features(mapnik::query const& q) const; - mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const; - mapnik::box2d envelope() const; - boost::optional get_geometry_type() const; - mapnik::layer_descriptor get_descriptor() const; + mapnik::featureset_ptr features(mapnik::query const& q) const override; + mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const override; + mapnik::box2d envelope() const override; + std::optional get_geometry_type() const override; + mapnik::layer_descriptor get_descriptor() const override; private: std::unique_ptr dataset_; @@ -69,7 +69,7 @@ class gdal_datasource : public mapnik::datasource double dy_; int nbands_; bool shared_dataset_; - boost::optional nodata_value_; + std::optional nodata_value_; double nodata_tolerance_; int64_t max_image_area_; }; diff --git a/plugins/input/gdal/gdal_featureset.cpp b/plugins/input/gdal/gdal_featureset.cpp index 0070a7ec3..c96b55f4f 100644 --- a/plugins/input/gdal/gdal_featureset.cpp +++ b/plugins/input/gdal/gdal_featureset.cpp @@ -86,7 +86,7 @@ gdal_featureset::gdal_featureset(GDALDataset& dataset, int nbands, double dx, double dy, - boost::optional const& nodata, + std::optional const& nodata, double nodata_tolerance, int64_t max_image_area) : dataset_(dataset) diff --git a/plugins/input/gdal/gdal_featureset.hpp b/plugins/input/gdal/gdal_featureset.hpp index 471052029..08bb166b8 100644 --- a/plugins/input/gdal/gdal_featureset.hpp +++ b/plugins/input/gdal/gdal_featureset.hpp @@ -24,11 +24,11 @@ #define GDAL_FEATURESET_HPP // mapnik +#include #include #include #include -// boost -#include +#include class GDALDataset; class GDALRasterBand; @@ -60,7 +60,7 @@ class gdal_featureset : public mapnik::Featureset int nbands, double dx, double dy, - boost::optional const& nodata, + std::optional const& nodata, double nodata_tolerance, int64_t max_image_area); virtual ~gdal_featureset(); @@ -85,7 +85,7 @@ class gdal_featureset : public mapnik::Featureset double dx_; double dy_; int nbands_; - boost::optional nodata_value_; + std::optional nodata_value_; double nodata_tolerance_; int64_t max_image_area_; bool first_; diff --git a/plugins/input/geobuf/geobuf.hpp b/plugins/input/geobuf/geobuf.hpp index d11740c3c..d4f4dcb33 100644 --- a/plugins/input/geobuf/geobuf.hpp +++ b/plugins/input/geobuf/geobuf.hpp @@ -32,8 +32,8 @@ #include #include #include +#include -#include #include namespace mapnik { @@ -293,7 +293,7 @@ struct geobuf : util::noncopyable template geometry::geometry - read_coords(T& reader, geometry_type_e type, boost::optional> const& lengths) + read_coords(T& reader, geometry_type_e type, std::optional> const& lengths) { geometry::geometry geom = geometry::geometry_empty(); switch (type) @@ -404,8 +404,8 @@ struct geobuf : util::noncopyable } template - geometry::multi_line_string - read_multi_linestring(T& reader, boost::optional> const& lengths) + geometry::multi_line_string read_multi_linestring(T& reader, + std::optional> const& lengths) { geometry::multi_line_string multi_line; multi_line.reserve(!lengths ? 1 : lengths->size()); @@ -432,7 +432,7 @@ struct geobuf : util::noncopyable } template - geometry::polygon read_polygon(T& reader, boost::optional> const& lengths) + geometry::polygon read_polygon(T& reader, std::optional> const& lengths) { geometry::polygon poly; poly.reserve(!lengths ? 1 : lengths->size()); @@ -460,7 +460,7 @@ struct geobuf : util::noncopyable template geometry::multi_polygon read_multi_polygon(T& reader, - boost::optional> const& lengths) + std::optional> const& lengths) { geometry::multi_polygon multi_poly; if (!lengths) @@ -496,7 +496,7 @@ struct geobuf : util::noncopyable { geometry::geometry geom = geometry::geometry_empty(); geometry_type_e type = Unknown; - boost::optional> lengths; + std::optional> lengths; while (reader.next()) { switch (reader.tag()) diff --git a/plugins/input/geobuf/geobuf_datasource.cpp b/plugins/input/geobuf/geobuf_datasource.cpp index 48eafa299..e5271d93f 100644 --- a/plugins/input/geobuf/geobuf_datasource.cpp +++ b/plugins/input/geobuf/geobuf_datasource.cpp @@ -79,12 +79,12 @@ geobuf_datasource::geobuf_datasource(parameters const& params) , features_() , tree_(nullptr) { - boost::optional file = params.get("file"); - if (!file) + const auto file = params.get("file"); + if (!file.has_value()) throw mapnik::datasource_exception("Geobuf Plugin: missing parameter"); - boost::optional base = params.get("base"); - if (base) + const auto base = params.get("base"); + if (base.has_value()) filename_ = *base + "/" + *file; else filename_ = *file; @@ -159,9 +159,9 @@ const char* geobuf_datasource::name() return "geobuf"; } -boost::optional geobuf_datasource::get_geometry_type() const +std::optional geobuf_datasource::get_geometry_type() const { - boost::optional result; + std::optional result; int multi_type = 0; unsigned num_features = features_.size(); for (unsigned i = 0; i < num_features && i < 5; ++i) @@ -172,7 +172,7 @@ boost::optional geobuf_datasource::get_geometry_t int type = static_cast(*result); if (multi_type > 0 && multi_type != type) { - result.reset(mapnik::datasource_geometry_t::Collection); + result = mapnik::datasource_geometry_t::Collection; return result; } multi_type = type; diff --git a/plugins/input/geobuf/geobuf_datasource.hpp b/plugins/input/geobuf/geobuf_datasource.hpp index 48088ec9b..169a24a94 100644 --- a/plugins/input/geobuf/geobuf_datasource.hpp +++ b/plugins/input/geobuf/geobuf_datasource.hpp @@ -34,11 +34,9 @@ #include #include // boost -#include #include MAPNIK_DISABLE_WARNING_PUSH #include -#include #include #include #include @@ -96,13 +94,13 @@ class geobuf_datasource : public mapnik::datasource // constructor geobuf_datasource(mapnik::parameters const& params); virtual ~geobuf_datasource(); - mapnik::datasource::datasource_t type() const; + mapnik::datasource::datasource_t type() const override; static const char* name(); - mapnik::featureset_ptr features(mapnik::query const& q) const; - mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const; - mapnik::box2d envelope() const; - mapnik::layer_descriptor get_descriptor() const; - boost::optional get_geometry_type() const; + mapnik::featureset_ptr features(mapnik::query const& q) const override; + mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const override; + mapnik::box2d envelope() const override; + mapnik::layer_descriptor get_descriptor() const override; + std::optional get_geometry_type() const override; void parse_geobuf(char const* buffer, std::size_t size); private: diff --git a/plugins/input/geojson/geojson_datasource.cpp b/plugins/input/geojson/geojson_datasource.cpp index f4ecf82ed..c6d78cc6b 100644 --- a/plugins/input/geojson/geojson_datasource.cpp +++ b/plugins/input/geojson/geojson_datasource.cpp @@ -101,14 +101,14 @@ geojson_datasource::geojson_datasource(parameters const& params) , num_features_to_query_( std::max(mapnik::value_integer(1), *params.get("num_features_to_query", 5))) { - boost::optional inline_string = params.get("inline"); + const auto inline_string = params.get("inline"); if (!inline_string) { - boost::optional file = params.get("file"); + const auto file = params.get("file"); if (!file) throw mapnik::datasource_exception("GeoJSON Plugin: missing parameter"); - boost::optional base = params.get("base"); + const auto base = params.get("base"); if (base) filename_ = *base + "/" + *file; else @@ -143,9 +143,8 @@ geojson_datasource::geojson_datasource(parameters const& params) char const* start = file_buffer.c_str(); char const* end = (count == 1) ? start + file_buffer.length() : start; #else - boost::optional mapped_region = - mapnik::mapped_memory_cache::instance().find(filename_, false); - if (!mapped_region) + const auto mapped_region = mapnik::mapped_memory_cache::instance().find(filename_, false); + if (!mapped_region.has_value()) { throw std::runtime_error("could not get file mapping for " + filename_); } @@ -440,9 +439,9 @@ mapnik::layer_descriptor geojson_datasource::get_descriptor() const return desc_; } -boost::optional geojson_datasource::get_geometry_type() const +std::optional geojson_datasource::get_geometry_type() const { - boost::optional result; + std::optional result; int multi_type = 0; if (has_disk_index_) { @@ -489,7 +488,7 @@ boost::optional geojson_datasource::get_geometry_ int type = static_cast(*result); if (multi_type > 0 && multi_type != type) { - result.reset(mapnik::datasource_geometry_t::Collection); + result = mapnik::datasource_geometry_t::Collection; return result; } multi_type = type; @@ -507,7 +506,7 @@ boost::optional geojson_datasource::get_geometry_ int type = static_cast(*result); if (multi_type > 0 && multi_type != type) { - result.reset(mapnik::datasource_geometry_t::Collection); + result = mapnik::datasource_geometry_t::Collection; return result; } multi_type = type; @@ -554,7 +553,7 @@ boost::optional geojson_datasource::get_geometry_ int type = static_cast(*result); if (multi_type > 0 && multi_type != type) { - result.reset(mapnik::datasource_geometry_t::Collection); + result = mapnik::datasource_geometry_t::Collection; return result; } multi_type = type; diff --git a/plugins/input/geojson/geojson_datasource.hpp b/plugins/input/geojson/geojson_datasource.hpp index 57584717e..6cee73719 100644 --- a/plugins/input/geojson/geojson_datasource.hpp +++ b/plugins/input/geojson/geojson_datasource.hpp @@ -37,7 +37,6 @@ #include MAPNIK_DISABLE_WARNING_PUSH #include -#include #include #include #include @@ -50,6 +49,7 @@ MAPNIK_DISABLE_WARNING_POP #include #include #include +#include template struct geojson_linear : boost::geometry::index::linear @@ -94,13 +94,13 @@ class geojson_datasource : public mapnik::datasource // constructor geojson_datasource(mapnik::parameters const& params); virtual ~geojson_datasource(); - mapnik::datasource::datasource_t type() const; + mapnik::datasource::datasource_t type() const override; static const char* name(); - mapnik::featureset_ptr features(mapnik::query const& q) const; - mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const; - mapnik::box2d envelope() const; - mapnik::layer_descriptor get_descriptor() const; - boost::optional get_geometry_type() const; + mapnik::featureset_ptr features(mapnik::query const& q) const override; + mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const override; + mapnik::box2d envelope() const override; + mapnik::layer_descriptor get_descriptor() const override; + std::optional get_geometry_type() const override; template void parse_geojson(Iterator start, Iterator end); template diff --git a/plugins/input/geojson/geojson_index_featureset.cpp b/plugins/input/geojson/geojson_index_featureset.cpp index 0711b9a30..ed215e0ed 100644 --- a/plugins/input/geojson/geojson_index_featureset.cpp +++ b/plugins/input/geojson/geojson_index_featureset.cpp @@ -50,8 +50,8 @@ geojson_index_featureset::geojson_index_featureset(std::string const& filename, ctx_(std::make_shared()) { #if defined(MAPNIK_MEMORY_MAPPED_FILE) - boost::optional memory = mapnik::mapped_memory_cache::instance().find(filename, true); - if (memory) + const auto memory = mapnik::mapped_memory_cache::instance().find(filename, true); + if (memory.has_value()) { mapped_region_ = *memory; } diff --git a/plugins/input/ogr/ogr_datasource.cpp b/plugins/input/ogr/ogr_datasource.cpp index cdb898b2a..83c020927 100644 --- a/plugins/input/ogr/ogr_datasource.cpp +++ b/plugins/input/ogr/ogr_datasource.cpp @@ -45,6 +45,8 @@ MAPNIK_DISABLE_WARNING_POP #include #include +#include "ogr_utils.hpp" + using mapnik::datasource; using mapnik::parameters; @@ -100,8 +102,8 @@ void ogr_datasource::init(mapnik::parameters const& params) mapnik::progress_timer __stats__(std::clog, "ogr_datasource::init"); #endif - boost::optional file = params.get("file"); - boost::optional string = params.get("string"); + const auto file = params.get("file"); + auto string = params.get("string"); if (!string) string = params.get("inline"); if (!file && !string) @@ -115,7 +117,7 @@ void ogr_datasource::init(mapnik::parameters const& params) } else { - boost::optional base = params.get("base"); + const auto base = params.get("base"); if (base) { dataset_name_ = *base + "/" + *file; @@ -164,14 +166,14 @@ void ogr_datasource::init(mapnik::parameters const& params) } // initialize layer - boost::optional layer_by_name = params.get("layer"); - boost::optional layer_by_index = params.get("layer_by_index"); - boost::optional layer_by_sql = params.get("layer_by_sql"); + const auto layer_by_name = params.get("layer"); + const auto layer_by_index = params.get("layer_by_index"); + const auto layer_by_sql = params.get("layer_by_sql"); int passed_parameters = 0; - passed_parameters += layer_by_name ? 1 : 0; - passed_parameters += layer_by_index ? 1 : 0; - passed_parameters += layer_by_sql ? 1 : 0; + passed_parameters += layer_by_name.has_value() ? 1 : 0; + passed_parameters += layer_by_index.has_value() ? 1 : 0; + passed_parameters += layer_by_sql.has_value() ? 1 : 0; if (passed_parameters > 1) { @@ -267,8 +269,8 @@ void ogr_datasource::init(mapnik::parameters const& params) OGRLayer* layer = layer_.layer(); // initialize envelope - boost::optional ext = params.get("extent"); - if (ext && !ext->empty()) + const auto ext = params.get("extent"); + if (ext.has_value() && !ext->empty()) { extent_.from_string(*ext); } @@ -402,9 +404,9 @@ box2d ogr_datasource::envelope() const return extent_; } -boost::optional ogr_datasource::get_geometry_type() const +std::optional ogr_datasource::get_geometry_type() const { - boost::optional result; + std::optional result; if (dataset_ && layer_.is_valid()) { OGRLayer* layer = layer_.layer(); @@ -417,19 +419,19 @@ boost::optional ogr_datasource::get_geometry_type { case wkbPoint: case wkbMultiPoint: - result.reset(mapnik::datasource_geometry_t::Point); + result = mapnik::datasource_geometry_t::Point; break; case wkbLinearRing: case wkbLineString: case wkbMultiLineString: - result.reset(mapnik::datasource_geometry_t::LineString); + result = mapnik::datasource_geometry_t::LineString; break; case wkbPolygon: case wkbMultiPolygon: - result.reset(mapnik::datasource_geometry_t::Polygon); + result = mapnik::datasource_geometry_t::Polygon; break; case wkbGeometryCollection: - result.reset(mapnik::datasource_geometry_t::Collection); + result = mapnik::datasource_geometry_t::Collection; break; case wkbNone: case wkbUnknown: { @@ -451,19 +453,19 @@ boost::optional ogr_datasource::get_geometry_type { case wkbPoint: case wkbMultiPoint: - result.reset(mapnik::datasource_geometry_t::Point); + result = mapnik::datasource_geometry_t::Point; break; case wkbLinearRing: case wkbLineString: case wkbMultiLineString: - result.reset(mapnik::datasource_geometry_t::LineString); + result = mapnik::datasource_geometry_t::LineString; break; case wkbPolygon: case wkbMultiPolygon: - result.reset(mapnik::datasource_geometry_t::Polygon); + result = mapnik::datasource_geometry_t::Polygon; break; case wkbGeometryCollection: - result.reset(mapnik::datasource_geometry_t::Collection); + result = mapnik::datasource_geometry_t::Collection; break; default: break; diff --git a/plugins/input/ogr/ogr_datasource.hpp b/plugins/input/ogr/ogr_datasource.hpp index 819353421..623f6cee0 100644 --- a/plugins/input/ogr/ogr_datasource.hpp +++ b/plugins/input/ogr/ogr_datasource.hpp @@ -33,12 +33,7 @@ #include #include -// boost -#include -#include - // stl -#include #include #include @@ -47,7 +42,6 @@ MAPNIK_DISABLE_WARNING_PUSH #include MAPNIK_DISABLE_WARNING_POP #include "ogr_layer_ptr.hpp" -#include "ogr_utils.hpp" DATASOURCE_PLUGIN_DEF(ogr_datasource_plugin, ogr); @@ -56,13 +50,13 @@ class ogr_datasource : public mapnik::datasource public: ogr_datasource(mapnik::parameters const& params); virtual ~ogr_datasource(); - mapnik::datasource::datasource_t type() const; + mapnik::datasource::datasource_t type() const override; static const char* name(); - mapnik::featureset_ptr features(mapnik::query const& q) const; - mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const; - mapnik::box2d envelope() const; - boost::optional get_geometry_type() const; - mapnik::layer_descriptor get_descriptor() const; + mapnik::featureset_ptr features(mapnik::query const& q) const override; + mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const override; + mapnik::box2d envelope() const override; + std::optional get_geometry_type() const override; + mapnik::layer_descriptor get_descriptor() const override; private: void init(mapnik::parameters const& params); diff --git a/plugins/input/ogr/ogr_index_featureset.cpp b/plugins/input/ogr/ogr_index_featureset.cpp index 50cf22c10..4f59d3b82 100644 --- a/plugins/input/ogr/ogr_index_featureset.cpp +++ b/plugins/input/ogr/ogr_index_featureset.cpp @@ -70,8 +70,8 @@ ogr_index_featureset::ogr_index_featureset(mapnik::context_ptr const& c , feature_envelope_() { #if defined(MAPNIK_MEMORY_MAPPED_FILE) - boost::optional memory = mapnik::mapped_memory_cache::instance().find(index_file, true); - if (memory) + const auto memory = mapnik::mapped_memory_cache::instance().find(index_file, true); + if (memory.has_value()) { boost::interprocess::ibufferstream file(static_cast((*memory)->get_address()), (*memory)->get_size()); ogr_index::query(filter, file, ids_); diff --git a/plugins/input/ogr/ogr_layer_ptr.hpp b/plugins/input/ogr/ogr_layer_ptr.hpp index 950ff7587..15cc94321 100644 --- a/plugins/input/ogr/ogr_layer_ptr.hpp +++ b/plugins/input/ogr/ogr_layer_ptr.hpp @@ -139,20 +139,11 @@ class ogr_layer_ptr #endif } - std::string const& layer_name() const - { - return layer_name_; - } + std::string const& layer_name() const { return layer_name_; } - OGRLayer* layer() const - { - return layer_; - } + OGRLayer* layer() const { return layer_; } - bool is_valid() const - { - return is_valid_; - } + bool is_valid() const { return is_valid_; } private: diff --git a/plugins/input/pgraster/pgraster_datasource.cpp b/plugins/input/pgraster/pgraster_datasource.cpp index fdba3c335..dce098fbc 100644 --- a/plugins/input/pgraster/pgraster_datasource.cpp +++ b/plugins/input/pgraster/pgraster_datasource.cpp @@ -104,8 +104,8 @@ pgraster_datasource::pgraster_datasource(parameters const& params) throw mapnik::datasource_exception("Pgraster Plugin: missing parameter"); } - boost::optional ext = params.get("extent"); - if (ext && !ext->empty()) + const auto ext = params.get("extent"); + if (ext.has_value() && !ext->empty()) { extent_initialized_ = extent_.from_string(*ext); } @@ -124,9 +124,8 @@ pgraster_datasource::pgraster_datasource(parameters const& params) asynchronous_request_ = true; } - boost::optional initial_size = params.get("initial_size", 1); - boost::optional autodetect_key_field = - params.get("autodetect_key_field", false); + const auto initial_size = params.get("initial_size", 1); + const auto autodetect_key_field = params.get("autodetect_key_field", false); ConnectionManager::instance().registerPool(creator_, *initial_size, pool_max_size_); CnxPool_ptr pool = ConnectionManager::instance().getPool(creator_.id()); @@ -298,14 +297,12 @@ pgraster_datasource::pgraster_datasource(parameters const& params) std::ostringstream err; if (parsed_schema_.empty()) { - err << "Pgraster Plugin: unable to lookup available table" - << " overviews due to unknown schema"; + err << "Pgraster Plugin: unable to lookup available table" << " overviews due to unknown schema"; throw mapnik::datasource_exception(err.str()); } if (geometryColumn_.empty()) { - err << "Pgraster Plugin: unable to lookup available table" - << " overviews due to unknown column name"; + err << "Pgraster Plugin: unable to lookup available table" << " overviews due to unknown column name"; throw mapnik::datasource_exception(err.str()); } @@ -415,8 +412,7 @@ pgraster_datasource::pgraster_datasource(parameters const& params) else if (result_rows > 1) { std::ostringstream err; - err << "PostGIS Plugin: Error: '" - << "multi column primary key detected but is not supported"; + err << "PostGIS Plugin: Error: '" << "multi column primary key detected but is not supported"; throw mapnik::datasource_exception(err.str()); } } @@ -489,8 +485,7 @@ pgraster_datasource::pgraster_datasource(parameters const& params) } rs_oid->close(); - error_s << " for key_field '" << fld_name << "' - " - << "must be an integer primary key"; + error_s << " for key_field '" << fld_name << "' - " << "must be an integer primary key"; rs->close(); throw mapnik::datasource_exception(error_s.str()); @@ -1120,8 +1115,8 @@ box2d pgraster_datasource::envelope() const } else { - s << "SELECT ST_XMin(ext),ST_YMin(ext),ST_XMax(ext),ST_YMax(ext)" - << " FROM (SELECT ST_Extent(" << identifier(col) << "::geometry) as ext from "; + s << "SELECT ST_XMin(ext),ST_YMin(ext),ST_XMax(ext),ST_YMax(ext)" << " FROM (SELECT ST_Extent(" + << identifier(col) << "::geometry) as ext from "; if (extent_from_subquery_) { @@ -1167,7 +1162,7 @@ box2d pgraster_datasource::envelope() const return extent_; } -boost::optional pgraster_datasource::get_geometry_type() const +std::optional pgraster_datasource::get_geometry_type() const { - return boost::optional(); + return std::nullopt; } diff --git a/plugins/input/pgraster/pgraster_datasource.hpp b/plugins/input/pgraster/pgraster_datasource.hpp index 136bd50e0..9a6d6d40a 100644 --- a/plugins/input/pgraster/pgraster_datasource.hpp +++ b/plugins/input/pgraster/pgraster_datasource.hpp @@ -80,15 +80,15 @@ class pgraster_datasource : public datasource public: pgraster_datasource(const parameters& params); ~pgraster_datasource(); - mapnik::datasource::datasource_t type() const; + mapnik::datasource::datasource_t type() const override; static const char* name(); - processor_context_ptr get_context(feature_style_context_map&) const; - featureset_ptr features_with_context(query const& q, processor_context_ptr ctx) const; - featureset_ptr features(query const& q) const; - featureset_ptr features_at_point(coord2d const& pt, double tol = 0) const; - mapnik::box2d envelope() const; - boost::optional get_geometry_type() const; - layer_descriptor get_descriptor() const; + processor_context_ptr get_context(feature_style_context_map&) const override; + featureset_ptr features_with_context(query const& q, processor_context_ptr ctx) const override; + featureset_ptr features(query const& q) const override; + featureset_ptr features_at_point(coord2d const& pt, double tol = 0) const override; + mapnik::box2d envelope() const override; + std::optional get_geometry_type() const override; + layer_descriptor get_descriptor() const override; private: std::string sql_bbox(box2d const& env) const; diff --git a/plugins/input/pgraster/pgraster_wkb_reader.cpp b/plugins/input/pgraster/pgraster_wkb_reader.cpp index 6ef103b7b..490c1a61d 100644 --- a/plugins/input/pgraster/pgraster_wkb_reader.cpp +++ b/plugins/input/pgraster/pgraster_wkb_reader.cpp @@ -160,10 +160,10 @@ typedef enum { #define BANDTYPE_FLAG_RESERVED3 (1 << 4) #define BANDTYPE_PIXTYPE_MASK 0x0F -#define BANDTYPE_PIXTYPE(x) ((x)&BANDTYPE_PIXTYPE_MASK) -#define BANDTYPE_IS_OFFDB(x) ((x)&BANDTYPE_FLAG_OFFDB) -#define BANDTYPE_HAS_NODATA(x) ((x)&BANDTYPE_FLAG_HASNODATA) -#define BANDTYPE_IS_NODATA(x) ((x)&BANDTYPE_FLAG_ISNODATA) +#define BANDTYPE_PIXTYPE(x) ((x) & BANDTYPE_PIXTYPE_MASK) +#define BANDTYPE_IS_OFFDB(x) ((x) & BANDTYPE_FLAG_OFFDB) +#define BANDTYPE_HAS_NODATA(x) ((x) & BANDTYPE_FLAG_HASNODATA) +#define BANDTYPE_IS_NODATA(x) ((x) & BANDTYPE_FLAG_ISNODATA) } // namespace diff --git a/plugins/input/postgis/connection.hpp b/plugins/input/postgis/connection.hpp index 3f7187476..53df192f4 100644 --- a/plugins/input/postgis/connection.hpp +++ b/plugins/input/postgis/connection.hpp @@ -42,7 +42,7 @@ extern "C" { class Connection { public: - Connection(std::string const& connection_str, boost::optional const& password) + Connection(std::string const& connection_str, std::optional const& password) : cursorId(0) , closed_(false) , pending_(false) @@ -236,20 +236,11 @@ class Connection return std::make_shared(result); } - std::string client_encoding() const - { - return PQparameterStatus(conn_, "client_encoding"); - } + std::string client_encoding() const { return PQparameterStatus(conn_, "client_encoding"); } - bool isOK() const - { - return (!closed_) && (PQstatus(conn_) != CONNECTION_BAD); - } + bool isOK() const { return (!closed_) && (PQstatus(conn_) != CONNECTION_BAD); } - bool isPending() const - { - return pending_; - } + bool isPending() const { return pending_; } void close() { diff --git a/plugins/input/postgis/connection_manager.hpp b/plugins/input/postgis/connection_manager.hpp index d8014d0bf..c5fc6c31e 100644 --- a/plugins/input/postgis/connection_manager.hpp +++ b/plugins/input/postgis/connection_manager.hpp @@ -30,12 +30,10 @@ #include #include -// boost -#include - // stl #include #include +#include using mapnik::CreateStatic; using mapnik::Pool; @@ -78,7 +76,7 @@ class ConnectionCreator { // only set fallback_application_name, so that application_name // can still be overriden with PGAPPNAME environment variable - append_param(connect_str, "fallback_application_name=", "mapnik"); + append_param(connect_str, "fallback_application_name=", std::string{"mapnik"}); } return connect_str; } @@ -96,18 +94,18 @@ class ConnectionCreator return true; } - static bool append_param(std::string& dest, char const* key, boost::optional const& opt) + static bool append_param(std::string& dest, char const* key, std::optional const& opt) { return opt && append_param(dest, key, *opt); } - boost::optional host_; - boost::optional port_; - boost::optional dbname_; - boost::optional user_; - boost::optional password_; - boost::optional connect_timeout_; - boost::optional application_name_; + std::optional host_; + std::optional port_; + std::optional dbname_; + std::optional user_; + std::optional password_; + std::optional connect_timeout_; + std::optional application_name_; }; class ConnectionManager : public singleton diff --git a/plugins/input/postgis/postgis_datasource.cpp b/plugins/input/postgis/postgis_datasource.cpp index 88a03a680..3b8757892 100644 --- a/plugins/input/postgis/postgis_datasource.cpp +++ b/plugins/input/postgis/postgis_datasource.cpp @@ -107,8 +107,8 @@ postgis_datasource::postgis_datasource(parameters const& params) throw mapnik::datasource_exception("Postgis Plugin: missing
parameter"); } - boost::optional ext = params.get("extent"); - if (ext && !ext->empty()) + const auto ext = params.get("extent"); + if (ext.has_value() && !ext->empty()) { extent_initialized_ = extent_.from_string(*ext); } @@ -127,19 +127,17 @@ postgis_datasource::postgis_datasource(parameters const& params) asynchronous_request_ = true; } - boost::optional initial_size = params.get("initial_size", 1); - boost::optional autodetect_key_field = - params.get("autodetect_key_field", false); - boost::optional estimate_extent = params.get("estimate_extent", false); + const auto initial_size = params.get("initial_size", 1); + const auto autodetect_key_field = params.get("autodetect_key_field", false); + const auto estimate_extent = params.get("estimate_extent", false); estimate_extent_ = estimate_extent && *estimate_extent; - boost::optional simplify_opt = params.get("simplify_geometries", false); + const auto simplify_opt = params.get("simplify_geometries", false); simplify_geometries_ = simplify_opt && *simplify_opt; - boost::optional twkb_opt = params.get("twkb_encoding", false); + const auto twkb_opt = params.get("twkb_encoding", false); twkb_encoding_ = twkb_opt && *twkb_opt; - boost::optional simplify_preserve_opt = - params.get("simplify_dp_preserve", false); + const auto simplify_preserve_opt = params.get("simplify_dp_preserve", false); simplify_dp_preserve_ = simplify_preserve_opt && *simplify_preserve_opt; ConnectionManager::instance().registerPool(creator_, *initial_size, pool_max_size_); @@ -310,8 +308,7 @@ postgis_datasource::postgis_datasource(parameters const& params) else if (result_rows > 1) { std::ostringstream err; - err << "PostGIS Plugin: Error: '" - << "multi column primary key detected but is not supported"; + err << "PostGIS Plugin: Error: '" << "multi column primary key detected but is not supported"; throw mapnik::datasource_exception(err.str()); } } @@ -387,8 +384,7 @@ postgis_datasource::postgis_datasource(parameters const& params) } rs_oid->close(); - error_s << " for key_field '" << fld_name << "' - " - << "must be an integer primary key"; + error_s << " for key_field '" << fld_name << "' - " << "must be an integer primary key"; rs->close(); throw mapnik::datasource_exception(error_s.str()); @@ -1024,8 +1020,8 @@ box2d postgis_datasource::envelope() const } else { - s << "SELECT ST_XMin(ext),ST_YMin(ext),ST_XMax(ext),ST_YMax(ext)" - << " FROM (SELECT ST_Extent(" << identifier(geometryColumn_) << ") as ext from "; + s << "SELECT ST_XMin(ext),ST_YMin(ext),ST_XMax(ext),ST_YMax(ext)" << " FROM (SELECT ST_Extent(" + << identifier(geometryColumn_) << ") as ext from "; if (extent_from_subquery_) { @@ -1067,9 +1063,9 @@ box2d postgis_datasource::envelope() const return extent_; } -boost::optional postgis_datasource::get_geometry_type() const +std::optional postgis_datasource::get_geometry_type() const { - boost::optional result; + std::optional result; CnxPool_ptr pool = ConnectionManager::instance().getPool(creator_.id()); if (pool) @@ -1099,17 +1095,17 @@ boost::optional postgis_datasource::get_geometry_ g_type = rs->getValue("type"); if (boost::algorithm::contains(g_type, "line")) { - result.reset(mapnik::datasource_geometry_t::LineString); + result = mapnik::datasource_geometry_t::LineString; return result; } else if (boost::algorithm::contains(g_type, "point")) { - result.reset(mapnik::datasource_geometry_t::Point); + result = mapnik::datasource_geometry_t::Point; return result; } else if (boost::algorithm::contains(g_type, "polygon")) { - result.reset(mapnik::datasource_geometry_t::Polygon); + result = mapnik::datasource_geometry_t::Polygon; return result; } else // geometry @@ -1131,8 +1127,8 @@ boost::optional postgis_datasource::get_geometry_ std::string prev_type(""); - s << "SELECT ST_GeometryType(" << identifier(geometryColumn_) << ") AS geom" - << " FROM " << populate_tokens(table_); + s << "SELECT ST_GeometryType(" << identifier(geometryColumn_) << ") AS geom" << " FROM " + << populate_tokens(table_); if (row_limit_ > 0 && row_limit_ < 5) { @@ -1150,26 +1146,26 @@ boost::optional postgis_datasource::get_geometry_ if (boost::algorithm::icontains(data, "line")) { g_type = "linestring"; - result.reset(mapnik::datasource_geometry_t::LineString); + result = mapnik::datasource_geometry_t::LineString; } else if (boost::algorithm::icontains(data, "point")) { g_type = "point"; - result.reset(mapnik::datasource_geometry_t::Point); + result = mapnik::datasource_geometry_t::Point; } else if (boost::algorithm::icontains(data, "polygon")) { g_type = "polygon"; - result.reset(mapnik::datasource_geometry_t::Polygon); + result = mapnik::datasource_geometry_t::Polygon; } else // geometry { - result.reset(mapnik::datasource_geometry_t::Collection); + result = mapnik::datasource_geometry_t::Collection; return result; } if (!prev_type.empty() && g_type != prev_type) { - result.reset(mapnik::datasource_geometry_t::Collection); + result = mapnik::datasource_geometry_t::Collection; return result; } prev_type = g_type; diff --git a/plugins/input/postgis/postgis_datasource.hpp b/plugins/input/postgis/postgis_datasource.hpp index 377da93b3..96cfb0b7d 100644 --- a/plugins/input/postgis/postgis_datasource.hpp +++ b/plugins/input/postgis/postgis_datasource.hpp @@ -69,15 +69,15 @@ class postgis_datasource : public datasource public: postgis_datasource(const parameters& params); ~postgis_datasource(); - mapnik::datasource::datasource_t type() const; + mapnik::datasource::datasource_t type() const override; static const char* name(); - processor_context_ptr get_context(feature_style_context_map&) const; - featureset_ptr features_with_context(query const& q, processor_context_ptr ctx) const; - featureset_ptr features(query const& q) const; - featureset_ptr features_at_point(coord2d const& pt, double tol = 0) const; - mapnik::box2d envelope() const; - boost::optional get_geometry_type() const; - layer_descriptor get_descriptor() const; + processor_context_ptr get_context(feature_style_context_map&) const override; + featureset_ptr features_with_context(query const& q, processor_context_ptr ctx) const override; + featureset_ptr features(query const& q) const override; + featureset_ptr features_at_point(coord2d const& pt, double tol = 0) const override; + mapnik::box2d envelope() const override; + std::optional get_geometry_type() const override; + layer_descriptor get_descriptor() const override; private: std::string sql_bbox(box2d const& env) const; diff --git a/plugins/input/raster/raster_datasource.cpp b/plugins/input/raster/raster_datasource.cpp index 5e04ebf4f..65bfde15a 100644 --- a/plugins/input/raster/raster_datasource.cpp +++ b/plugins/input/raster/raster_datasource.cpp @@ -55,11 +55,11 @@ raster_datasource::raster_datasource(parameters const& params) { MAPNIK_LOG_DEBUG(raster) << "raster_datasource: Initializing..."; - boost::optional file = params.get("file"); + const auto file = params.get("file"); if (!file) throw datasource_exception("Raster Plugin: missing parameter "); - boost::optional base = params.get("base"); + const auto base = params.get("base"); if (base) filename_ = *base + "/" + *file; else @@ -69,15 +69,15 @@ raster_datasource::raster_datasource(parameters const& params) tile_size_ = *params.get("tile_size", 1024); tile_stride_ = *params.get("tile_stride", 1); - boost::optional format_from_filename = mapnik::type_from_filename(*file); + const auto format_from_filename = mapnik::type_from_filename(*file); format_ = *params.get("format", format_from_filename ? (*format_from_filename) : "tiff"); - boost::optional lox = params.get("lox"); - boost::optional loy = params.get("loy"); - boost::optional hix = params.get("hix"); - boost::optional hiy = params.get("hiy"); + const auto lox = params.get("lox"); + const auto loy = params.get("loy"); + const auto hix = params.get("hix"); + const auto hiy = params.get("hiy"); - boost::optional ext = params.get("extent"); + const auto ext = params.get("extent"); if (lox && loy && hix && hiy) { @@ -108,8 +108,8 @@ raster_datasource::raster_datasource(parameters const& params) if (multi_tiles_) { - boost::optional x_width = params.get("x_width"); - boost::optional y_width = params.get("y_width"); + const auto x_width = params.get("x_width"); + const auto y_width = params.get("y_width"); if (!x_width) { @@ -121,8 +121,8 @@ raster_datasource::raster_datasource(parameters const& params) throw datasource_exception("Raster Plugin: y-width parameter not supplied for multi-tiled data source."); } - width_ = x_width.get() * tile_size_; - height_ = y_width.get() * tile_size_; + width_ = x_width.value() * tile_size_; + height_ = y_width.value() * tile_size_; } else { @@ -174,9 +174,9 @@ mapnik::box2d raster_datasource::envelope() const return extent_; } -boost::optional raster_datasource::get_geometry_type() const +std::optional raster_datasource::get_geometry_type() const { - return boost::optional(); + return std::nullopt; } layer_descriptor raster_datasource::get_descriptor() const diff --git a/plugins/input/raster/raster_datasource.hpp b/plugins/input/raster/raster_datasource.hpp index f1b78dfe9..75809cff8 100644 --- a/plugins/input/raster/raster_datasource.hpp +++ b/plugins/input/raster/raster_datasource.hpp @@ -33,14 +33,6 @@ #include #include -// boost -#include -#include - -// stl -#include -#include - DATASOURCE_PLUGIN_DEF(raster_datasource_plugin, raster); class raster_datasource : public mapnik::datasource @@ -48,13 +40,13 @@ class raster_datasource : public mapnik::datasource public: raster_datasource(const mapnik::parameters& params); virtual ~raster_datasource(); - datasource::datasource_t type() const; + datasource::datasource_t type() const override; static const char* name(); - mapnik::featureset_ptr features(const mapnik::query& q) const; - mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const; - mapnik::box2d envelope() const; - boost::optional get_geometry_type() const; - mapnik::layer_descriptor get_descriptor() const; + mapnik::featureset_ptr features(const mapnik::query& q) const override; + mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const override; + mapnik::box2d envelope() const override; + std::optional get_geometry_type() const override; + mapnik::layer_descriptor get_descriptor() const override; bool log_enabled() const; private: diff --git a/plugins/input/shape/shape_datasource.cpp b/plugins/input/shape/shape_datasource.cpp index 38f3dbf08..655196582 100644 --- a/plugins/input/shape/shape_datasource.cpp +++ b/plugins/input/shape/shape_datasource.cpp @@ -72,12 +72,12 @@ shape_datasource::shape_datasource(parameters const& params) #ifdef MAPNIK_STATS mapnik::progress_timer __stats__(std::clog, "shape_datasource::init"); #endif - boost::optional file = params.get("file"); - if (!file) + const auto file = params.get("file"); + if (!file.has_value()) throw datasource_exception("Shape Plugin: missing parameter"); - boost::optional base = params.get("base"); - if (base) + const auto base = params.get("base"); + if (base.has_value()) shape_name_ = *base + "/" + *file; else shape_name_ = *file; @@ -307,13 +307,13 @@ box2d shape_datasource::envelope() const return extent_; } -boost::optional shape_datasource::get_geometry_type() const +std::optional shape_datasource::get_geometry_type() const { #ifdef MAPNIK_STATS mapnik::progress_timer __stats__(std::clog, "shape_datasource::get_geometry_type"); #endif - boost::optional result; + std::optional result; switch (shape_type_) { case shape_io::shape_point: @@ -322,19 +322,19 @@ boost::optional shape_datasource::get_geometry_ty case shape_io::shape_multipoint: case shape_io::shape_multipointm: case shape_io::shape_multipointz: { - result.reset(mapnik::datasource_geometry_t::Point); + result = mapnik::datasource_geometry_t::Point; break; } case shape_io::shape_polyline: case shape_io::shape_polylinem: case shape_io::shape_polylinez: { - result.reset(mapnik::datasource_geometry_t::LineString); + result = mapnik::datasource_geometry_t::LineString; break; } case shape_io::shape_polygon: case shape_io::shape_polygonm: case shape_io::shape_polygonz: { - result.reset(mapnik::datasource_geometry_t::Polygon); + result = mapnik::datasource_geometry_t::Polygon; break; } default: diff --git a/plugins/input/shape/shape_datasource.hpp b/plugins/input/shape/shape_datasource.hpp index bc98b9c3b..41887818e 100644 --- a/plugins/input/shape/shape_datasource.hpp +++ b/plugins/input/shape/shape_datasource.hpp @@ -34,12 +34,7 @@ #include #include -// boost -#include -#include - // stl -#include #include #include "shape_io.hpp" @@ -58,13 +53,13 @@ class shape_datasource : public datasource public: shape_datasource(parameters const& params); virtual ~shape_datasource(); - datasource::datasource_t type() const; + datasource::datasource_t type() const override; static const char* name(); - featureset_ptr features(query const& q) const; - featureset_ptr features_at_point(coord2d const& pt, double tol = 0) const; - box2d envelope() const; - boost::optional get_geometry_type() const; - layer_descriptor get_descriptor() const; + featureset_ptr features(query const& q) const override; + featureset_ptr features_at_point(coord2d const& pt, double tol = 0) const override; + box2d envelope() const override; + std::optional get_geometry_type() const override; + layer_descriptor get_descriptor() const override; private: void init(shape_io& shape); diff --git a/plugins/input/shape/shapefile.hpp b/plugins/input/shape/shapefile.hpp index 2eac16d92..5798f22ef 100644 --- a/plugins/input/shape/shapefile.hpp +++ b/plugins/input/shape/shapefile.hpp @@ -171,30 +171,15 @@ class shape_file : public mapnik::util::mapped_memory_file file_.read(reinterpret_cast(&envelope), sizeof(envelope)); } - inline void rewind() - { - seek(100); - } + inline void rewind() { seek(100); } - inline void seek(std::streampos pos) - { - file_.seekg(pos, std::ios::beg); - } + inline void seek(std::streampos pos) { file_.seekg(pos, std::ios::beg); } - inline std::streampos pos() - { - return file_.tellg(); - } + inline std::streampos pos() { return file_.tellg(); } - inline bool is_eof() - { - return file_.eof(); - } + inline bool is_eof() { return file_.eof(); } - inline bool is_good() - { - return file_.good(); - } + inline bool is_good() { return file_.good(); } }; #endif // SHAPEFILE_HPP diff --git a/plugins/input/sqlite/sqlite_connection.hpp b/plugins/input/sqlite/sqlite_connection.hpp index 44767a799..107a31b57 100644 --- a/plugins/input/sqlite/sqlite_connection.hpp +++ b/plugins/input/sqlite/sqlite_connection.hpp @@ -115,8 +115,7 @@ class sqlite_connection s << "'" << sqlite3_errmsg(db_) << "'"; else s << "unknown error, lost connection"; - s << " (" << file_ << ")" - << "\nFull sql was: '" << sql << "'"; + s << " (" << file_ << ")" << "\nFull sql was: '" << sql << "'"; throw mapnik::datasource_exception(s.str()); } @@ -160,10 +159,7 @@ class sqlite_connection return rc; } - sqlite3* operator*() - { - return db_; - } + sqlite3* operator*() { return db_; } bool load_extension(std::string const& ext_path) { diff --git a/plugins/input/sqlite/sqlite_datasource.cpp b/plugins/input/sqlite/sqlite_datasource.cpp index 71a55a2eb..3295cc1b5 100644 --- a/plugins/input/sqlite/sqlite_datasource.cpp +++ b/plugins/input/sqlite/sqlite_datasource.cpp @@ -86,11 +86,11 @@ sqlite_datasource::sqlite_datasource(parameters const& params) mapnik::progress_timer __stats__(std::clog, "sqlite_datasource::init"); #endif - boost::optional file = params.get("file"); + const auto file = params.get("file"); if (!file) throw datasource_exception("Sqlite Plugin: missing parameter"); - boost::optional base = params.get("base"); + const auto base = params.get("base"); if (base) dataset_name_ = *base + "/" + *file; else @@ -106,12 +106,12 @@ sqlite_datasource::sqlite_datasource(parameters const& params) // TODO - remove this option once all datasources have an indexing api bool auto_index = *params.get("auto_index", true); - boost::optional ext = params.get("extent"); - if (ext) + const auto ext = params.get("extent"); + if (ext.has_value()) extent_initialized_ = extent_.from_string(*ext); - boost::optional wkb = params.get("wkb_format"); - if (wkb) + const auto wkb = params.get("wkb_format"); + if (wkb.has_value()) { if (*wkb == "spatialite") { @@ -139,14 +139,14 @@ sqlite_datasource::sqlite_datasource(parameters const& params) // databases are relative to directory containing dataset_name_. Sqlite // will default to attaching from cwd. Typicaly usage means that the // map loader will produce full paths here. - boost::optional attachdb = params.get("attachdb"); - if (attachdb) + const auto attachdb = params.get("attachdb"); + if (attachdb.has_value()) { parse_attachdb(*attachdb); } - boost::optional initdb = params.get("initdb"); - if (initdb) + const auto initdb = params.get("initdb"); + if (initdb.has_value()) { init_statements_.push_back(*initdb); } @@ -154,11 +154,11 @@ sqlite_datasource::sqlite_datasource(parameters const& params) // now actually create the connection and start executing setup sql dataset_ = std::make_shared(dataset_name_); - boost::optional table_by_index = params.get("table_by_index"); + const auto table_by_index = params.get("table_by_index"); int passed_parameters = 0; passed_parameters += params.get("table") ? 1 : 0; - passed_parameters += table_by_index ? 1 : 0; + passed_parameters += table_by_index.has_value() ? 1 : 0; if (passed_parameters > 1) { @@ -260,9 +260,8 @@ sqlite_datasource::sqlite_datasource(parameters const& params) if (geometry_field_.empty()) { std::ostringstream s; - s << "Sqlite Plugin: unable to detect the column " - << "containing a valid geometry on table '" << geometry_table_ << "'. " - << "Please provide a column name by passing the 'geometry_field' option " + s << "Sqlite Plugin: unable to detect the column " << "containing a valid geometry on table '" + << geometry_table_ << "'. " << "Please provide a column name by passing the 'geometry_field' option " << "or indicate a different spatial table to use by passing the 'geometry_table' option"; throw datasource_exception(s.str()); } @@ -316,12 +315,9 @@ sqlite_datasource::sqlite_datasource(parameters const& params) else { std::ostringstream s; - s << "Sqlite Plugin: could not generate spatial index" - << " for table '" << geometry_table_ << "'" - << " as no primary key can be detected." - << " You should either declare an INTEGER PRIMARY KEY" - << " or set the 'key_field' option to force a" - << " given field to be used as the primary key"; + s << "Sqlite Plugin: could not generate spatial index" << " for table '" << geometry_table_ << "'" + << " as no primary key can be detected." << " You should either declare an INTEGER PRIMARY KEY" + << " or set the 'key_field' option to force a" << " given field to be used as the primary key"; throw datasource_exception(s.str()); } } @@ -426,13 +422,13 @@ box2d sqlite_datasource::envelope() const return extent_; } -boost::optional sqlite_datasource::get_geometry_type() const +std::optional sqlite_datasource::get_geometry_type() const { #ifdef MAPNIK_STATS mapnik::progress_timer __stats__(std::clog, "sqlite_datasource::get_geometry_type"); #endif - boost::optional result; + std::optional result; if (dataset_) { // get geometry type by querying first features @@ -470,7 +466,7 @@ boost::optional sqlite_datasource::get_geometry_t int type = static_cast(*result); if (multi_type > 0 && multi_type != type) { - result.reset(mapnik::datasource_geometry_t::Collection); + result = mapnik::datasource_geometry_t::Collection; return result; } multi_type = type; diff --git a/plugins/input/sqlite/sqlite_datasource.hpp b/plugins/input/sqlite/sqlite_datasource.hpp index 49d588f23..cbeb08b09 100644 --- a/plugins/input/sqlite/sqlite_datasource.hpp +++ b/plugins/input/sqlite/sqlite_datasource.hpp @@ -35,13 +35,10 @@ #include #include -// boost -#include -#include - // stl #include #include +#include // sqlite #include "sqlite_connection.hpp" @@ -53,13 +50,13 @@ class sqlite_datasource : public mapnik::datasource public: sqlite_datasource(mapnik::parameters const& params); virtual ~sqlite_datasource(); - datasource::datasource_t type() const; + datasource::datasource_t type() const override; static const char* name(); - mapnik::featureset_ptr features(mapnik::query const& q) const; - mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const; - mapnik::box2d envelope() const; - boost::optional get_geometry_type() const; - mapnik::layer_descriptor get_descriptor() const; + mapnik::featureset_ptr features(mapnik::query const& q) const override; + mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const override; + mapnik::box2d envelope() const override; + std::optional get_geometry_type() const override; + mapnik::layer_descriptor get_descriptor() const override; private: // Fill init_statements with any statements diff --git a/plugins/input/sqlite/sqlite_utils.hpp b/plugins/input/sqlite/sqlite_utils.hpp index 0a2f942dd..be471e786 100644 --- a/plugins/input/sqlite/sqlite_utils.hpp +++ b/plugins/input/sqlite/sqlite_utils.hpp @@ -144,6 +144,7 @@ class sqlite_utils static void get_tables(std::shared_ptr ds, std::vector& tables) { std::ostringstream sql; + // clang-format off // todo handle finding tables from attached db's sql << " SELECT name FROM sqlite_master" << " WHERE type IN ('table','view')" @@ -155,6 +156,7 @@ class sqlite_utils << " SELECT name FROM sqlite_temp_master" << " WHERE type IN ('table','view')" << " ORDER BY 1"; + // clang-format on sqlite3_stmt* stmt = 0; const int rc = sqlite3_prepare_v2(*(*ds), sql.str().c_str(), -1, &stmt, 0); if (rc == SQLITE_OK) @@ -352,8 +354,7 @@ class sqlite_utils { std::ostringstream error_msg; error_msg << "Sqlite Plugin: invalid type for key field '" << rs->column_name(1) - << "' when creating index " - << "type was: " << type_oid << ""; + << "' when creating index " << "type was: " << type_oid << ""; throw mapnik::datasource_exception(error_msg.str()); } const sqlite_int64 pkid = rs->column_integer64(1); diff --git a/plugins/input/topojson/topojson_datasource.cpp b/plugins/input/topojson/topojson_datasource.cpp index 2981ed65d..eefb609c8 100644 --- a/plugins/input/topojson/topojson_datasource.cpp +++ b/plugins/input/topojson/topojson_datasource.cpp @@ -23,9 +23,6 @@ #include "topojson_datasource.hpp" #include "topojson_featureset.hpp" -#include -#include - // boost #include @@ -132,18 +129,18 @@ topojson_datasource::topojson_datasource(parameters const& params) , tr_(new mapnik::transcoder(*params.get("encoding", "utf-8"))) , tree_(nullptr) { - boost::optional inline_string = params.get("inline"); + const auto inline_string = params.get("inline"); if (inline_string) { inline_string_ = *inline_string; } else { - boost::optional file = params.get("file"); + const auto file = params.get("file"); if (!file) throw mapnik::datasource_exception("TopoJSON Plugin: missing parameter"); - boost::optional base = params.get("base"); + const auto base = params.get("base"); if (base) filename_ = *base + "/" + *file; else @@ -225,9 +222,9 @@ const char* topojson_datasource::name() return "topojson"; } -boost::optional topojson_datasource::get_geometry_type() const +std::optional topojson_datasource::get_geometry_type() const { - boost::optional result; + std::optional result; int multi_type = 0; std::size_t num_features = topo_.geometries.size(); for (std::size_t i = 0; i < num_features && i < 5; ++i) @@ -238,12 +235,12 @@ boost::optional topojson_datasource::get_geometry { if (multi_type > 0 && multi_type != type) { - result.reset(mapnik::datasource_geometry_t::Collection); + result = mapnik::datasource_geometry_t::Collection; return result; } else { - result.reset(static_cast(type)); + result = static_cast(type); } multi_type = type; } diff --git a/plugins/input/topojson/topojson_datasource.hpp b/plugins/input/topojson/topojson_datasource.hpp index 88aff1c0f..4cdc572b8 100644 --- a/plugins/input/topojson/topojson_datasource.hpp +++ b/plugins/input/topojson/topojson_datasource.hpp @@ -38,7 +38,6 @@ #include MAPNIK_DISABLE_WARNING_PUSH #include -#include #include #include #include @@ -47,11 +46,10 @@ MAPNIK_DISABLE_WARNING_PUSH MAPNIK_DISABLE_WARNING_POP // stl -#include #include #include -#include #include +#include DATASOURCE_PLUGIN_DEF(topojson_datasource_plugin, topojson); @@ -66,13 +64,13 @@ class topojson_datasource : public mapnik::datasource // constructor topojson_datasource(mapnik::parameters const& params); virtual ~topojson_datasource(); - mapnik::datasource::datasource_t type() const; + mapnik::datasource::datasource_t type() const override; static const char* name(); - mapnik::featureset_ptr features(mapnik::query const& q) const; - mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const; - mapnik::box2d envelope() const; - mapnik::layer_descriptor get_descriptor() const; - boost::optional get_geometry_type() const; + mapnik::featureset_ptr features(mapnik::query const& q) const override; + mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const override; + mapnik::box2d envelope() const override; + mapnik::layer_descriptor get_descriptor() const override; + std::optional get_geometry_type() const override; template void parse_topojson(T const& buffer); diff --git a/src/agg/agg_renderer.cpp b/src/agg/agg_renderer.cpp index 1d171713f..4e60e81b5 100644 --- a/src/agg/agg_renderer.cpp +++ b/src/agg/agg_renderer.cpp @@ -56,12 +56,6 @@ MAPNIK_DISABLE_WARNING_PUSH #include "agg_span_image_filter_rgba.h" MAPNIK_DISABLE_WARNING_POP -#include -MAPNIK_DISABLE_WARNING_PUSH -#include -#include -MAPNIK_DISABLE_WARNING_POP - // stl #include @@ -167,7 +161,7 @@ void agg_renderer::setup(Map const& m, buffer_type& pixmap) buffers_.emplace(pixmap); mapnik::set_premultiplied_alpha(pixmap, true); - boost::optional const& bg = m.background(); + auto&& bg = m.background(); if (bg) { if (bg->alpha() < 255) @@ -184,7 +178,7 @@ void agg_renderer::setup(Map const& m, buffer_type& pixmap) } } - boost::optional const& image_filename = m.background_image(); + auto&& image_filename = m.background_image(); if (image_filename) { // NOTE: marker_cache returns premultiplied image, if needed @@ -229,7 +223,7 @@ void agg_renderer::start_layer_processing(layer const& lay, box2d> const& maximum_extent = lay.maximum_extent(); + auto&& maximum_extent = lay.maximum_extent(); if (maximum_extent) { common_.query_extent_.clip(*maximum_extent); diff --git a/src/cairo/cairo_renderer.cpp b/src/cairo/cairo_renderer.cpp index 310c0eed3..f5cb500be 100644 --- a/src/cairo/cairo_renderer.cpp +++ b/src/cairo/cairo_renderer.cpp @@ -118,13 +118,13 @@ struct setup_marker_visitor void operator()(marker_rgba8 const& marker) const { mapnik::image_rgba8 const& bg_image = marker.get_data(); - std::size_t w = bg_image.width(); - std::size_t h = bg_image.height(); + const std::size_t w = bg_image.width(); + const std::size_t h = bg_image.height(); if (w > 0 && h > 0) { // repeat background-image both vertically and horizontally - std::size_t x_steps = std::size_t(std::ceil(common_.width_ / double(w))); - std::size_t y_steps = std::size_t(std::ceil(common_.height_ / double(h))); + const std::size_t x_steps = std::size_t(std::ceil(common_.width_ / double(w))); + const std::size_t y_steps = std::size_t(std::ceil(common_.height_ / double(h))); for (std::size_t x = 0; x < x_steps; ++x) { for (std::size_t y = 0; y < y_steps; ++y) @@ -144,16 +144,16 @@ struct setup_marker_visitor template void cairo_renderer::setup(Map const& map) { - boost::optional bg = m_.background(); - if (bg) + const auto bg = m_.background(); + if (bg.has_value()) { cairo_save_restore guard(context_); context_.set_color(*bg); context_.set_operator(composite_mode_e::src); context_.paint(); } - boost::optional const& image_filename = map.background_image(); - if (image_filename) + auto&& image_filename = map.background_image(); + if (image_filename.has_value()) { // NOTE: marker_cache returns premultiplied image, if needed std::shared_ptr bg_marker = mapnik::marker_cache::instance().find(*image_filename, true); @@ -166,7 +166,7 @@ template void cairo_renderer::start_map_processing(Map const& map) { MAPNIK_LOG_DEBUG(cairo_renderer) << "cairo_renderer: Start map processing bbox=" << map.get_current_extent(); - box2d bounds = common_.t_.forward(common_.t_.extent()); + const box2d bounds = common_.t_.forward(common_.t_.extent()); context_.rectangle(bounds.minx(), bounds.miny(), bounds.maxx(), bounds.maxy()); context_.clip(); } diff --git a/src/cairo_io.cpp b/src/cairo_io.cpp index e38fc2c5a..f7f17160a 100644 --- a/src/cairo_io.cpp +++ b/src/cairo_io.cpp @@ -53,8 +53,8 @@ void save_to_cairo_file(mapnik::Map const& map, double scale_factor, double scale_denominator) { - boost::optional type = type_from_filename(filename); - if (type) + const auto type = type_from_filename(filename); + if (type.has_value()) { save_to_cairo_file(map, filename, *type, scale_factor, scale_denominator); } diff --git a/src/datasource_cache.cpp b/src/datasource_cache.cpp index 5539e3fc6..934a38071 100644 --- a/src/datasource_cache.cpp +++ b/src/datasource_cache.cpp @@ -59,8 +59,8 @@ datasource_cache::~datasource_cache() {} datasource_ptr datasource_cache::create(parameters const& params) { - boost::optional type = params.get("type"); - if (!type) + const auto type = params.get("type"); + if (!type.has_value()) { throw config_error(std::string("Could not create datasource. Required ") + "parameter 'type' is missing"); } diff --git a/src/datasource_cache_static.cpp b/src/datasource_cache_static.cpp index 97e67aad4..22de1ef20 100644 --- a/src/datasource_cache_static.cpp +++ b/src/datasource_cache_static.cpp @@ -154,7 +154,7 @@ void init_datasource_cache_static() datasource_ptr create_static_datasource(parameters const& params) { - boost::optional type = params.get("type"); + const auto type = params.get("type"); datasource_map::iterator it = ds_map.find(*type); if (it != ds_map.end()) { diff --git a/src/debug.cpp b/src/debug.cpp index 09287508f..a808f6d4a 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -61,13 +61,12 @@ std::atomic logger::severity_level_ bool logger::severity_env_check_{true}; bool logger::format_env_check_{true}; -logger::severity_type logger::severity_level_ -{ +logger::severity_type logger::severity_level_{ #endif #if MAPNIK_DEFAULT_LOG_SEVERITY == 0 logger::debug #elif MAPNIK_DEFAULT_LOG_SEVERITY == 1 - logger::warn + logger::warn #elif MAPNIK_DEFAULT_LOG_SEVERITY == 2 logger::error #elif MAPNIK_DEFAULT_LOG_SEVERITY == 3 diff --git a/src/feature_kv_iterator.cpp b/src/feature_kv_iterator.cpp index 696d8cdf7..8eb10cd0d 100644 --- a/src/feature_kv_iterator.cpp +++ b/src/feature_kv_iterator.cpp @@ -23,12 +23,6 @@ #include #include -#include -MAPNIK_DISABLE_WARNING_PUSH -#include -#include -MAPNIK_DISABLE_WARNING_POP - namespace mapnik { feature_kv_iterator::feature_kv_iterator(feature_impl const& f, bool begin) diff --git a/src/feature_type_style.cpp b/src/feature_type_style.cpp index 092b1bfa6..71eea8a5c 100644 --- a/src/feature_type_style.cpp +++ b/src/feature_type_style.cpp @@ -21,8 +21,6 @@ *****************************************************************************/ #include -#include -#include #include #include #include @@ -150,7 +148,7 @@ void feature_type_style::set_comp_op(composite_mode_e _comp_op) comp_op_ = _comp_op; } -boost::optional feature_type_style::comp_op() const +std::optional feature_type_style::comp_op() const { return comp_op_; } diff --git a/src/font_engine_freetype.cpp b/src/font_engine_freetype.cpp index c905aaedd..1b6a2f2c3 100644 --- a/src/font_engine_freetype.cpp +++ b/src/font_engine_freetype.cpp @@ -32,7 +32,6 @@ MAPNIK_DISABLE_WARNING_PUSH #include #include -#include // freetype2 extern "C" { @@ -45,7 +44,6 @@ MAPNIK_DISABLE_WARNING_POP // stl #include -#include namespace mapnik { template class MAPNIK_DECL singleton; @@ -481,7 +479,7 @@ face_set_ptr face_manager::get_face_set(font_set const& fset) return face_set; } -face_set_ptr face_manager::get_face_set(std::string const& name, boost::optional fset) +face_set_ptr face_manager::get_face_set(std::string const& name, std::optional fset) { if (fset && fset->size() > 0) { diff --git a/src/geometry/interior.cpp b/src/geometry/interior.cpp index 2491cf26f..64766a97d 100644 --- a/src/geometry/interior.cpp +++ b/src/geometry/interior.cpp @@ -28,15 +28,8 @@ #include #include -#include #include -#include -MAPNIK_DISABLE_WARNING_PUSH -#include -#include -MAPNIK_DISABLE_WARNING_POP - namespace mapnik { namespace geometry { diff --git a/src/grid/grid_renderer.cpp b/src/grid/grid_renderer.cpp index 0c16f297e..4d7983adc 100644 --- a/src/grid/grid_renderer.cpp +++ b/src/grid/grid_renderer.cpp @@ -123,8 +123,8 @@ void grid_renderer::start_layer_processing(layer const& lay, box2d co common_.detector_->clear(); } common_.query_extent_ = query_extent; - boost::optional> const& maximum_extent = lay.maximum_extent(); - if (maximum_extent) + auto&& maximum_extent = lay.maximum_extent(); + if (maximum_extent.has_value()) { common_.query_extent_.clip(*maximum_extent); } @@ -207,7 +207,6 @@ struct grid_render_marker_visitor else { image_rgba8 target(data.width(), data.height()); - boost::optional nodata; mapnik::scale_image_agg(target, data, SCALING_NEAR, @@ -216,8 +215,8 @@ struct grid_render_marker_visitor 0.0, 0.0, 1.0, - nodata); // TODO: is 1.0 a valid default here, and do we even care in grid_renderer - // what the image looks like? + std::nullopt); // TODO: is 1.0 a valid default here, and do we even care in + // grid_renderer what the image looks like? pixmap_.set_rectangle(feature_.id(), target, boost::math::iround(pos_.x - cx), diff --git a/src/image_compositing.cpp b/src/image_compositing.cpp index a5bba373f..949831cfc 100644 --- a/src/image_compositing.cpp +++ b/src/image_compositing.cpp @@ -64,24 +64,24 @@ static const comp_op_lookup_type comp_lookup = _color, "color")(_value, "value")(linear_dodge, "linear-dodge")(linear_burn, "linear-burn")(divide, "divide"); -boost::optional comp_op_from_string(std::string const& name) +std::optional comp_op_from_string(std::string const& name) { - boost::optional mode; + std::optional mode; comp_op_lookup_type::right_const_iterator right_iter = comp_lookup.right.find(name); if (right_iter != comp_lookup.right.end()) { - mode.reset(right_iter->second); + mode = right_iter->second; } return mode; } -boost::optional comp_op_to_string(composite_mode_e comp_op) +std::optional comp_op_to_string(composite_mode_e comp_op) { - boost::optional mode; + std::optional mode; comp_op_lookup_type::left_const_iterator left_iter = comp_lookup.left.find(comp_op); if (left_iter != comp_lookup.left.end()) { - mode.reset(left_iter->second); + mode = left_iter->second; } return mode; } diff --git a/src/image_options.cpp b/src/image_options.cpp index 6cea2e300..e7e4c80bf 100644 --- a/src/image_options.cpp +++ b/src/image_options.cpp @@ -42,7 +42,7 @@ namespace x3 = boost::spirit::x3; using x3::lit; using x3::ascii::char_; -using pair_type = std::pair>; +using pair_type = std::pair>; x3::rule const image_options("image options"); x3::rule const key_value("key_value"); diff --git a/src/image_reader.cpp b/src/image_reader.cpp index 29217e104..c97ecaeb1 100644 --- a/src/image_reader.cpp +++ b/src/image_reader.cpp @@ -27,20 +27,19 @@ namespace mapnik { -inline boost::optional type_from_bytes(char const* data, size_t size) +inline std::optional type_from_bytes(char const* data, size_t size) { - using result_type = boost::optional; unsigned char const* header = reinterpret_cast(data); if (size >= 4) { unsigned int magic = (header[0] << 24) | (header[1] << 16) | (header[2] << 8) | header[3]; if (magic == 0x89504E47U) { - return result_type("png"); + return "png"; } else if (magic == 0x49492A00U || magic == 0x4D4D002AU) { - return result_type("tiff"); + return "tiff"; } } if (size >= 2) @@ -48,7 +47,7 @@ inline boost::optional type_from_bytes(char const* data, size_t siz unsigned int magic = ((header[0] << 8) | header[1]) & 0xffff; if (magic == 0xffd8) { - return result_type("jpeg"); + return "jpeg"; } } @@ -57,16 +56,16 @@ inline boost::optional type_from_bytes(char const* data, size_t siz if (header[0] == 'R' && header[1] == 'I' && header[2] == 'F' && header[3] == 'F' && header[8] == 'W' && header[9] == 'E' && header[10] == 'B' && header[11] == 'P') { - return result_type("webp"); + return "webp"; } } - return result_type(); + return std::nullopt; } image_reader* get_image_reader(char const* data, size_t size) { - boost::optional type = type_from_bytes(data, size); - if (type) + const auto type = type_from_bytes(data, size); + if (type.has_value()) return factory::instance().create_object(*type, data, size); else throw image_reader_exception("image_reader: can't determine type from input data"); @@ -79,8 +78,8 @@ image_reader* get_image_reader(std::string const& filename, std::string const& t image_reader* get_image_reader(std::string const& filename) { - boost::optional type = type_from_filename(filename); - if (type) + const auto type = type_from_filename(filename); + if (type.has_value()) { return factory::instance().create_object(*type, filename); } diff --git a/src/image_scaling.cpp b/src/image_scaling.cpp index 986d98c66..a696789a3 100644 --- a/src/image_scaling.cpp +++ b/src/image_scaling.cpp @@ -66,26 +66,24 @@ static const scaling_method_lookup_type scaling_lookup = SCALING_SINC, "sinc")(SCALING_LANCZOS, "lanczos")(SCALING_BLACKMAN, "blackman"); -boost::optional scaling_method_from_string(std::string const& name) +std::optional scaling_method_from_string(std::string const& name) { - boost::optional mode; scaling_method_lookup_type::right_const_iterator right_iter = scaling_lookup.right.find(name); if (right_iter != scaling_lookup.right.end()) { - mode.reset(right_iter->second); + return right_iter->second; } - return mode; + return std::nullopt; } -boost::optional scaling_method_to_string(scaling_method_e scaling_method) +std::optional scaling_method_to_string(scaling_method_e scaling_method) { - boost::optional mode; scaling_method_lookup_type::left_const_iterator left_iter = scaling_lookup.left.find(scaling_method); if (left_iter != scaling_lookup.left.end()) { - mode.reset(left_iter->second); + return left_iter->second; } - return mode; + return std::nullopt; } template @@ -97,7 +95,7 @@ void scale_image_agg(T& target, double x_off_f, double y_off_f, double filter_factor, - boost::optional const& nodata_value) + std::optional const& nodata_value) { // "the image filters should work namely in the premultiplied color space" // http://old.nabble.com/Re:--AGG--Basic-image-transformations-p1110665.html @@ -157,8 +155,8 @@ void scale_image_agg(T& target, using span_gen_type = typename detail::agg_scaling_traits::span_image_resample_affine; agg::image_filter_lut filter; detail::set_scaling_method(filter, scaling_method, filter_factor); - boost::optional nodata; - if (nodata_value) + std::optional nodata; + if (nodata_value.has_value()) { nodata.emplace(safe_cast(*nodata_value)); } @@ -175,7 +173,7 @@ template MAPNIK_DECL void scale_image_agg(image_rgba8&, double, double, double, - boost::optional const&); + std::optional const&); template MAPNIK_DECL void scale_image_agg(image_gray8&, image_gray8 const&, @@ -185,7 +183,7 @@ template MAPNIK_DECL void scale_image_agg(image_gray8&, double, double, double, - boost::optional const&); + std::optional const&); template MAPNIK_DECL void scale_image_agg(image_gray8s&, image_gray8s const&, @@ -195,7 +193,7 @@ template MAPNIK_DECL void scale_image_agg(image_gray8s&, double, double, double, - boost::optional const&); + std::optional const&); template MAPNIK_DECL void scale_image_agg(image_gray16&, image_gray16 const&, @@ -205,7 +203,7 @@ template MAPNIK_DECL void scale_image_agg(image_gray16&, double, double, double, - boost::optional const&); + std::optional const&); template MAPNIK_DECL void scale_image_agg(image_gray16s&, image_gray16s const&, @@ -215,7 +213,7 @@ template MAPNIK_DECL void scale_image_agg(image_gray16s&, double, double, double, - boost::optional const&); + std::optional const&); template MAPNIK_DECL void scale_image_agg(image_gray32&, image_gray32 const&, @@ -225,7 +223,7 @@ template MAPNIK_DECL void scale_image_agg(image_gray32&, double, double, double, - boost::optional const&); + std::optional const&); template MAPNIK_DECL void scale_image_agg(image_gray32s&, image_gray32s const&, @@ -235,7 +233,7 @@ template MAPNIK_DECL void scale_image_agg(image_gray32s&, double, double, double, - boost::optional const&); + std::optional const&); template MAPNIK_DECL void scale_image_agg(image_gray32f&, image_gray32f const&, @@ -245,7 +243,7 @@ template MAPNIK_DECL void scale_image_agg(image_gray32f&, double, double, double, - boost::optional const&); + std::optional const&); template MAPNIK_DECL void scale_image_agg(image_gray64&, image_gray64 const&, @@ -255,7 +253,7 @@ template MAPNIK_DECL void scale_image_agg(image_gray64&, double, double, double, - boost::optional const&); + std::optional const&); template MAPNIK_DECL void scale_image_agg(image_gray64s&, image_gray64s const&, @@ -265,7 +263,7 @@ template MAPNIK_DECL void scale_image_agg(image_gray64s&, double, double, double, - boost::optional const&); + std::optional const&); template MAPNIK_DECL void scale_image_agg(image_gray64f&, image_gray64f const&, @@ -275,5 +273,5 @@ template MAPNIK_DECL void scale_image_agg(image_gray64f&, double, double, double, - boost::optional const&); + std::optional const&); } // namespace mapnik diff --git a/src/image_util.cpp b/src/image_util.cpp index 7c77a467f..383811442 100644 --- a/src/image_util.cpp +++ b/src/image_util.cpp @@ -313,8 +313,8 @@ MAPNIK_DECL void template MAPNIK_DECL void save_to_file(T const& image, std::string const& filename) { - boost::optional type = type_from_filename(filename); - if (type) + const auto type = type_from_filename(filename); + if (type.has_value()) { save_to_file(image, filename, *type); } @@ -325,8 +325,8 @@ MAPNIK_DECL void save_to_file(T const& image, std::string const& filename) template MAPNIK_DECL void save_to_file(T const& image, std::string const& filename, rgba_palette const& palette) { - boost::optional type = type_from_filename(filename); - if (type) + const auto type = type_from_filename(filename); + if (type.has_value()) { save_to_file(image, filename, *type, palette); } @@ -425,11 +425,11 @@ struct is_solid_visitor if (image.size() > 0) { pixel_type const first_p = *image.begin(); - auto itr = std::find_if(/*std::execution::par_unseq,*/ // still missing on ubuntu with - // clang++10/libc++ (!) - image.begin(), - image.end(), - [first_p](pixel_type const p) { return first_p != p; }); + const auto itr = std::find_if(/*std::execution::par_unseq,*/ // still missing on ubuntu with + // clang++10/libc++ (!) + image.begin(), + image.end(), + [first_p](auto&& p) { return first_p != p; }); return (itr == image.end()); } return true; diff --git a/src/jpeg_reader.cpp b/src/jpeg_reader.cpp index 1e14acb59..e5142f505 100644 --- a/src/jpeg_reader.cpp +++ b/src/jpeg_reader.cpp @@ -75,7 +75,7 @@ class jpeg_reader : public image_reader ~jpeg_reader(); unsigned width() const final; unsigned height() const final; - boost::optional> bounding_box() const final; + std::optional> bounding_box() const override final; inline bool has_alpha() const final { return false; } void read(unsigned x, unsigned y, image_rgba8& image) final; image_any read(unsigned x, unsigned y, unsigned width, unsigned height) final; @@ -260,9 +260,9 @@ unsigned jpeg_reader::height() const } template -boost::optional> jpeg_reader::bounding_box() const +std::optional> jpeg_reader::bounding_box() const { - return boost::optional>(); + return std::nullopt; } template @@ -289,8 +289,8 @@ void jpeg_reader::read(unsigned x0, unsigned y0, image_rgba8& image) row_stride = cinfo.output_width * cinfo.output_components; buffer = (*cinfo.mem->alloc_sarray)((j_common_ptr)&cinfo, JPOOL_IMAGE, row_stride, 1); - unsigned w = std::min(unsigned(image.width()), width_ - x0); - unsigned h = std::min(unsigned(image.height()), height_ - y0); + const unsigned w = std::min(unsigned(image.width()), width_ - x0); + const unsigned h = std::min(unsigned(image.height()), height_ - y0); const std::unique_ptr out_row(new unsigned int[w]); unsigned row = 0; diff --git a/src/layer.cpp b/src/layer.cpp index 5829ccf45..645cb7e78 100644 --- a/src/layer.cpp +++ b/src/layer.cpp @@ -227,10 +227,10 @@ void layer::set_datasource(datasource_ptr const& ds) void layer::set_maximum_extent(box2d const& box) { - maximum_extent_.reset(box); + maximum_extent_ = box; } -boost::optional> const& layer::maximum_extent() const +std::optional> const& layer::maximum_extent() const { return maximum_extent_; } @@ -242,10 +242,10 @@ void layer::reset_maximum_extent() void layer::set_buffer_size(int size) { - buffer_size_.reset(size); + buffer_size_ = size; } -boost::optional const& layer::buffer_size() const +std::optional const& layer::buffer_size() const { return buffer_size_; } @@ -297,7 +297,7 @@ void layer::set_comp_op(composite_mode_e comp_op) comp_op_ = comp_op; } -boost::optional layer::comp_op() const +std::optional layer::comp_op() const { return comp_op_; } diff --git a/src/load_map.cpp b/src/load_map.cpp index 5265d5a39..43d62332e 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -63,7 +63,6 @@ #include MAPNIK_DISABLE_WARNING_PUSH #include -#include #include #include #include @@ -82,7 +81,7 @@ MAPNIK_DISABLE_WARNING_POP using boost::tokenizer; namespace mapnik { -using boost::optional; +using std::optional; using util::name_to_int; using util::operator"" _case; @@ -135,10 +134,10 @@ class map_parser : util::noncopyable void ensure_font_face(std::string const& face_name); void find_unused_nodes(xml_node const& root); void find_unused_nodes_recursive(xml_node const& node, std::string& error_text); - std::string ensure_relative_to_xml(boost::optional const& opt_path); + std::string ensure_relative_to_xml(std::optional const& opt_path); void ensure_exists(std::string const& file_path); void check_styles(Map const& map); - boost::optional get_opt_color_attr(boost::property_tree::ptree const& node, std::string const& name); + std::optional get_opt_color_attr(boost::property_tree::ptree const& node, std::string const& name); bool strict_; std::string filename_; @@ -849,15 +848,15 @@ void map_parser::parse_layer(Parent& parent, xml_node const& node) } } - boost::optional base_param = params.get("base"); - boost::optional file_param = params.get("file"); + const auto base_param = params.get("base"); + const auto file_param = params.get("file"); - if (base_param) + if (base_param.has_value()) { params["base"] = ensure_relative_to_xml(base_param); } - else if (file_param) + else if (file_param.has_value()) { params["file"] = ensure_relative_to_xml(file_param); } @@ -1461,8 +1460,8 @@ void map_parser::parse_raster_symbolizer(rule& rule, xml_node const& node) } else { - boost::optional method = scaling_method_from_string(scaling_method); - if (method) + const auto method = scaling_method_from_string(scaling_method); + if (method.has_value()) { put(raster_sym, keys::scaling, *method); } @@ -1753,7 +1752,7 @@ void map_parser::ensure_font_face(std::string const& face_name) } } -std::string map_parser::ensure_relative_to_xml(boost::optional const& opt_path) +std::string map_parser::ensure_relative_to_xml(std::optional const& opt_path) { if (marker_cache::instance().is_uri(*opt_path)) return *opt_path; diff --git a/src/map.cpp b/src/map.cpp index e10b10478..ce80bd7ab 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -427,7 +427,7 @@ int Map::buffer_size() const return buffer_size_; } -boost::optional const& Map::background() const +std::optional const& Map::background() const { return background_; } @@ -437,7 +437,7 @@ void Map::set_background(color const& c) background_ = c; } -boost::optional const& Map::background_image() const +std::optional const& Map::background_image() const { return background_image_; } @@ -469,10 +469,10 @@ void Map::set_background_image_opacity(float opacity) void Map::set_maximum_extent(box2d const& box) { - maximum_extent_.reset(box); + maximum_extent_ = box; } -boost::optional> const& Map::maximum_extent() const +std::optional> const& Map::maximum_extent() const { return maximum_extent_; } @@ -555,8 +555,7 @@ void Map::zoom_all() else { std::ostringstream s; - s << "could not zoom to combined layer extents " - << "using zoom_all because proj4 could not " + s << "could not zoom to combined layer extents " << "using zoom_all because proj4 could not " << "back project any layer extents into the map srs " << "(set map 'maximum-extent' to override layer extents)"; throw std::runtime_error(s.str()); diff --git a/src/mapped_memory_cache.cpp b/src/mapped_memory_cache.cpp index 8da68a1c5..3d435ddf2 100644 --- a/src/mapped_memory_cache.cpp +++ b/src/mapped_memory_cache.cpp @@ -63,19 +63,17 @@ bool mapped_memory_cache::remove(std::string const& key) return cache_.erase(key) > 0; } -boost::optional mapped_memory_cache::find(std::string const& uri, bool update_cache) +std::optional mapped_memory_cache::find(std::string const& uri, bool update_cache) { #ifdef MAPNIK_THREADSAFE std::lock_guard lock(mutex_); #endif using iterator_type = std::unordered_map::const_iterator; - boost::optional result; iterator_type itr = cache_.find(uri); if (itr != cache_.end()) { - result.reset(itr->second); - return result; + return itr->second; } if (mapnik::util::exists(uri)) @@ -85,12 +83,11 @@ boost::optional mapped_memory_cache::find(std::string const& boost::interprocess::file_mapping mapping(uri.c_str(), boost::interprocess::read_only); mapped_region_ptr region( std::make_shared(mapping, boost::interprocess::read_only)); - result.reset(region); if (update_cache) { - cache_.emplace(uri, *result); + cache_.emplace(uri, region); } - return result; + return region; } catch (std::exception const& ex) { @@ -104,7 +101,7 @@ boost::optional mapped_memory_cache::find(std::string const& MAPNIK_LOG_WARN(mapped_memory_cache) << "Memory region does not exist file: " << uri; } */ - return result; + return std::nullopt; } } // namespace mapnik diff --git a/src/marker_helpers.cpp b/src/marker_helpers.cpp index ccfb08237..f48937366 100644 --- a/src/marker_helpers.cpp +++ b/src/marker_helpers.cpp @@ -83,11 +83,11 @@ namespace detail { struct push_explicit_style { push_explicit_style(svg::group& dst, - boost::optional const& fill_color, - boost::optional const& fill_opacity, - boost::optional const& stroke_color, - boost::optional const& stroke_width, - boost::optional const& stroke_opacity) + std::optional const& fill_color, + std::optional const& fill_opacity, + std::optional const& stroke_color, + std::optional const& stroke_width, + std::optional const& stroke_opacity) : current_group_(&dst) , fill_color_(fill_color) , fill_opacity_(fill_opacity) @@ -168,11 +168,11 @@ struct push_explicit_style return true; } mutable svg::group* current_group_; - boost::optional const& fill_color_; - boost::optional const& fill_opacity_; - boost::optional const& stroke_color_; - boost::optional const& stroke_width_; - boost::optional const& stroke_opacity_; + std::optional const& fill_color_; + std::optional const& fill_opacity_; + std::optional const& stroke_color_; + std::optional const& stroke_width_; + std::optional const& stroke_opacity_; }; } // namespace detail diff --git a/src/memory_datasource.cpp b/src/memory_datasource.cpp index 60019011a..2fa6fe51c 100644 --- a/src/memory_datasource.cpp +++ b/src/memory_datasource.cpp @@ -159,7 +159,7 @@ box2d memory_datasource::envelope() const return extent_; } -boost::optional memory_datasource::get_geometry_type() const +std::optional memory_datasource::get_geometry_type() const { // TODO - detect this? return datasource_geometry_t::Collection; diff --git a/src/params.cpp b/src/params.cpp index dbca2b4ce..0e357fff8 100644 --- a/src/params.cpp +++ b/src/params.cpp @@ -28,26 +28,25 @@ namespace mapnik { -template boost::optional parameters::get(std::string const& key) const; -template boost::optional parameters::get(std::string const& key, - std::string const& default_opt_value) const; +template std::optional parameters::get(std::string const& key) const; +template std::optional parameters::get(std::string const& key, std::string const& default_opt_value) const; -template boost::optional parameters::get(std::string const& key) const; -template boost::optional parameters::get(std::string const& key, - value_double const& default_opt_value) const; +template std::optional parameters::get(std::string const& key) const; +template std::optional parameters::get(std::string const& key, + value_double const& default_opt_value) const; -template boost::optional parameters::get(std::string const& key) const; -template boost::optional parameters::get(std::string const& key, value_bool const& default_opt_value) const; +template std::optional parameters::get(std::string const& key) const; +template std::optional parameters::get(std::string const& key, value_bool const& default_opt_value) const; -template boost::optional parameters::get(std::string const& key) const; -template boost::optional parameters::get(std::string const& key, - boolean_type const& default_opt_value) const; +template std::optional parameters::get(std::string const& key) const; +template std::optional parameters::get(std::string const& key, + boolean_type const& default_opt_value) const; -template boost::optional parameters::get(std::string const& key) const; -template boost::optional parameters::get(std::string const& key, value_null const& default_opt_value) const; +template std::optional parameters::get(std::string const& key) const; +template std::optional parameters::get(std::string const& key, value_null const& default_opt_value) const; -template boost::optional parameters::get(std::string const& key) const; -template boost::optional parameters::get(std::string const& key, - value_integer const& default_opt_value) const; +template std::optional parameters::get(std::string const& key) const; +template std::optional parameters::get(std::string const& key, + value_integer const& default_opt_value) const; } // namespace mapnik diff --git a/src/png_reader.cpp b/src/png_reader.cpp index 799cdeda5..208abc4d1 100644 --- a/src/png_reader.cpp +++ b/src/png_reader.cpp @@ -70,7 +70,7 @@ class png_reader : public image_reader ~png_reader(); unsigned width() const final; unsigned height() const final; - boost::optional> bounding_box() const final; + std::optional> bounding_box() const final; inline bool has_alpha() const final { return has_alpha_; } void read(unsigned x, unsigned y, image_rgba8& image) final; image_any read(unsigned x, unsigned y, unsigned width, unsigned height) final; @@ -211,9 +211,9 @@ unsigned png_reader::height() const } template -boost::optional> png_reader::bounding_box() const +std::optional> png_reader::bounding_box() const { - return boost::optional>(); + return std::nullopt; } template diff --git a/src/proj_transform.cpp b/src/proj_transform.cpp index 33e6847f0..ca42e881a 100644 --- a/src/proj_transform.cpp +++ b/src/proj_transform.cpp @@ -104,8 +104,8 @@ proj_transform::proj_transform(projection const& source, projection const& dest) { is_source_longlat_ = source.is_geographic(); is_dest_longlat_ = dest.is_geographic(); - boost::optional src_k = source.well_known(); - boost::optional dest_k = dest.well_known(); + const auto src_k = source.well_known(); + const auto dest_k = dest.well_known(); bool known_trans = false; if (src_k && dest_k) { diff --git a/src/proj_transform_cache.cpp b/src/proj_transform_cache.cpp index 1913da29c..54ffac4d8 100644 --- a/src/proj_transform_cache.cpp +++ b/src/proj_transform_cache.cpp @@ -26,14 +26,14 @@ MAPNIK_DISABLE_WARNING_PUSH #include #include #include -#include MAPNIK_DISABLE_WARNING_POP +#include namespace mapnik { namespace proj_transform_cache { namespace { using key_type = std::pair; -using compatible_key_type = std::pair; +using compatible_key_type = std::pair; struct compatible_hash { @@ -59,7 +59,7 @@ thread_local static cache_type cache_ = {}; void init(std::string const& source, std::string const& dest) { - compatible_key_type key = std::make_pair(source, dest); + compatible_key_type key = std::make_pair(source, dest); auto itr = cache_.find(key, compatible_hash{}, compatible_predicate{}); if (itr == cache_.end()) { @@ -71,7 +71,7 @@ void init(std::string const& source, std::string const& dest) proj_transform const* get(std::string const& source, std::string const& dest) { - compatible_key_type key = std::make_pair(source, dest); + compatible_key_type key = std::make_pair(source, dest); auto itr = cache_.find(key, compatible_hash{}, compatible_predicate{}); if (itr == cache_.end()) { diff --git a/src/projection.cpp b/src/projection.cpp index 319d19698..798f1376c 100644 --- a/src/projection.cpp +++ b/src/projection.cpp @@ -44,8 +44,8 @@ projection::projection(std::string const& params, bool defer_proj_init) , proj_(nullptr) , proj_ctx_(nullptr) { - boost::optional is_known = is_known_geographic(params_); - if (is_known) + const auto is_known = is_known_geographic(params_); + if (is_known.has_value()) { is_geographic_ = *is_known; } @@ -131,7 +131,7 @@ bool projection::is_geographic() const return is_geographic_; } -boost::optional projection::well_known() const +std::optional projection::well_known() const { return is_well_known_srs(params_); } diff --git a/src/raster_colorizer.cpp b/src/raster_colorizer.cpp index befa1606e..d21efe5e3 100644 --- a/src/raster_colorizer.cpp +++ b/src/raster_colorizer.cpp @@ -120,7 +120,7 @@ float get_nodata_color() template void raster_colorizer::colorize(image_rgba8& out, T const& in, - boost::optional const& nodata, + std::optional const& nodata, feature_impl const& f) const { using image_type = T; @@ -313,43 +313,43 @@ unsigned raster_colorizer::get_color(float val) const template void raster_colorizer::colorize(image_rgba8& out, image_gray8 const& in, - boost::optional const& nodata, + std::optional const& nodata, feature_impl const& f) const; template void raster_colorizer::colorize(image_rgba8& out, image_gray8s const& in, - boost::optional const& nodata, + std::optional const& nodata, feature_impl const& f) const; template void raster_colorizer::colorize(image_rgba8& out, image_gray16 const& in, - boost::optional const& nodata, + std::optional const& nodata, feature_impl const& f) const; template void raster_colorizer::colorize(image_rgba8& out, image_gray16s const& in, - boost::optional const& nodata, + std::optional const& nodata, feature_impl const& f) const; template void raster_colorizer::colorize(image_rgba8& out, image_gray32 const& in, - boost::optional const& nodata, + std::optional const& nodata, feature_impl const& f) const; template void raster_colorizer::colorize(image_rgba8& out, image_gray32s const& in, - boost::optional const& nodata, + std::optional const& nodata, feature_impl const& f) const; template void raster_colorizer::colorize(image_rgba8& out, image_gray32f const& in, - boost::optional const& nodata, + std::optional const& nodata, feature_impl const& f) const; template void raster_colorizer::colorize(image_rgba8& out, image_gray64 const& in, - boost::optional const& nodata, + std::optional const& nodata, feature_impl const& f) const; template void raster_colorizer::colorize(image_rgba8& out, image_gray64s const& in, - boost::optional const& nodata, + std::optional const& nodata, feature_impl const& f) const; template void raster_colorizer::colorize(image_rgba8& out, image_gray64f const& in, - boost::optional const& nodata, + std::optional const& nodata, feature_impl const& f) const; } // namespace mapnik diff --git a/src/save_map.cpp b/src/save_map.cpp index 88278456b..144ade302 100644 --- a/src/save_map.cpp +++ b/src/save_map.cpp @@ -53,16 +53,16 @@ MAPNIK_DISABLE_WARNING_PUSH #include #include #include -#include #include MAPNIK_DISABLE_WARNING_POP // stl #include +#include namespace mapnik { -using boost::optional; using boost::property_tree::ptree; +using std::optional; void serialize_text_placements(ptree& node, text_placements_ptr const& p, bool explicit_defaults) { @@ -405,7 +405,7 @@ void serialize_style(ptree& map_node, std::string const& name, feature_type_styl set_attr(style_node, "image-filters-inflate", image_filters_inflate); } - boost::optional comp_op = style.comp_op(); + auto&& comp_op = style.comp_op(); if (comp_op) { set_attr(style_node, "comp-op", *comp_op_to_string(*comp_op)); @@ -547,7 +547,7 @@ void serialize_layer(ptree& map_node, layer const& lyr, bool explicit_defaults) set_attr(layer_node, "group-by", lyr.group_by()); } - boost::optional const& buffer_size = lyr.buffer_size(); + auto&& buffer_size = lyr.buffer_size(); if (buffer_size || explicit_defaults) { set_attr(layer_node, "buffer-size", *buffer_size); diff --git a/src/simplify.cpp b/src/simplify.cpp index 212f5e41c..586f11709 100644 --- a/src/simplify.cpp +++ b/src/simplify.cpp @@ -16,26 +16,24 @@ static const simplify_algorithm_lookup_type simplify_lookup = douglas_peucker, "douglas-peucker")(visvalingam_whyatt, "visvalingam-whyatt")(zhao_saalfeld, "zhao-saalfeld"); -boost::optional simplify_algorithm_from_string(std::string const& name) +std::optional simplify_algorithm_from_string(std::string const& name) { - boost::optional algo; simplify_algorithm_lookup_type::right_const_iterator right_iter = simplify_lookup.right.find(name); if (right_iter != simplify_lookup.right.end()) { - algo.reset(right_iter->second); + return right_iter->second; } - return algo; + return std::nullopt; } -boost::optional simplify_algorithm_to_string(simplify_algorithm_e value) +std::optional simplify_algorithm_to_string(simplify_algorithm_e value) { - boost::optional algo; simplify_algorithm_lookup_type::left_const_iterator left_iter = simplify_lookup.left.find(value); if (left_iter != simplify_lookup.left.end()) { - algo.reset(left_iter->second); + return left_iter->second; } - return algo; + return std::nullopt; } } // namespace mapnik diff --git a/src/svg/output/svg_renderer.cpp b/src/svg/output/svg_renderer.cpp index a2c122bd0..64808779f 100644 --- a/src/svg/output/svg_renderer.cpp +++ b/src/svg/output/svg_renderer.cpp @@ -30,9 +30,6 @@ #include #include -// stl -#include - namespace mapnik { template @@ -81,8 +78,8 @@ void svg_renderer::start_map_processing(Map const& map) svg::root_output_attributes root_attributes(common_.width_, common_.height_); generator_.generate_opening_root(root_attributes); - boost::optional const& bgcolor = map.background(); - if (bgcolor) + auto&& bgcolor = map.background(); + if (bgcolor.has_value()) { // generate background color as a rectangle that spans the whole image. svg::rect_output_attributes bg_attributes(0, 0, common_.width_, common_.height_, *bgcolor); diff --git a/src/text/formatting/format.cpp b/src/text/formatting/format.cpp index b51843bd4..e72273e24 100644 --- a/src/text/formatting/format.cpp +++ b/src/text/formatting/format.cpp @@ -33,7 +33,6 @@ #include MAPNIK_DISABLE_WARNING_PUSH #include -#include #include MAPNIK_DISABLE_WARNING_POP @@ -95,13 +94,13 @@ node_ptr format_node::from_xml(xml_node const& xml, fontset_map const& fontsets) set_property_from_xml(n->text_transform, "text-transform", xml); set_property_from_xml(n->ff_settings, "font-feature-settings", xml); - boost::optional face_name = xml.get_opt_attr("face-name"); - if (face_name) + const auto face_name = xml.get_opt_attr("face-name"); + if (face_name.has_value()) { n->face_name = *face_name; } - boost::optional fontset_name = xml.get_opt_attr("fontset-name"); - if (fontset_name) + const auto fontset_name = xml.get_opt_attr("fontset-name"); + if (fontset_name.has_value()) { std::map::const_iterator itr = fontsets.find(*fontset_name); if (itr != fontsets.end()) diff --git a/src/text/placements/registry.cpp b/src/text/placements/registry.cpp index 08a3058ce..5cad5b104 100644 --- a/src/text/placements/registry.cpp +++ b/src/text/placements/registry.cpp @@ -51,7 +51,7 @@ void registry::register_name(std::string name, from_xml_function_ptr ptr, bool o text_placements_ptr registry::from_xml(std::string name, xml_node const& xml, fontset_map const& fontsets, bool is_shield) { - std::map::const_iterator itr = map_.find(name); + const auto itr = map_.find(name); if (itr == map_.end()) throw config_error("Unknown placement-type '" + name + "'", xml); return itr->second(xml, fontsets, is_shield); diff --git a/src/text/placements/simple.cpp b/src/text/placements/simple.cpp index cf3610328..de66875f1 100644 --- a/src/text/placements/simple.cpp +++ b/src/text/placements/simple.cpp @@ -203,8 +203,8 @@ text_placements_ptr text_placements_simple::from_xml(xml_node const& xml, fontse { // we don't use parse_expression(placements_string) directly here to benefit from the cache in the // xml_node - boost::optional val = xml.get_opt_attr("placements"); - if (val) + const auto val = xml.get_opt_attr("placements"); + if (val.has_value()) { text_placements_ptr ptr = std::make_shared(*val); ptr->defaults.from_xml(xml, fontsets, is_shield); diff --git a/src/text/symbolizer_helpers.cpp b/src/text/symbolizer_helpers.cpp index 6348dc763..9aceb86d4 100644 --- a/src/text/symbolizer_helpers.cpp +++ b/src/text/symbolizer_helpers.cpp @@ -399,11 +399,11 @@ text_symbolizer_helper::text_symbolizer_helper(text_symbolizer const& sym, void text_symbolizer_helper::init_converters() { // setup vertex converter - value_bool clip = mapnik::get(sym_, feature_, vars_); - value_double simplify_tolerance = mapnik::get(sym_, feature_, vars_); - value_double smooth = mapnik::get(sym_, feature_, vars_); - value_double extend = mapnik::get(sym_, feature_, vars_); - boost::optional offset = get_optional(sym_, keys::offset, feature_, vars_); + const value_bool clip = mapnik::get(sym_, feature_, vars_); + const value_double simplify_tolerance = mapnik::get(sym_, feature_, vars_); + const value_double smooth = mapnik::get(sym_, feature_, vars_); + const value_double extend = mapnik::get(sym_, feature_, vars_); + const auto offset = get_optional(sym_, keys::offset, feature_, vars_); if (clip) { @@ -426,7 +426,7 @@ void text_symbolizer_helper::init_converters() converter_.template set(); // optional simplify converter if (smooth > 0.0) converter_.template set(); // optional smooth converter - if (offset) + if (offset.has_value()) converter_.template set(); // optional offset converter } diff --git a/src/text/text_properties.cpp b/src/text/text_properties.cpp index bccd76b29..d8b18943d 100644 --- a/src/text/text_properties.cpp +++ b/src/text/text_properties.cpp @@ -43,7 +43,6 @@ MAPNIK_DISABLE_WARNING_POP #include namespace mapnik { -using boost::optional; evaluated_text_properties_ptr evaluate_text_properties(text_symbolizer_properties const& text_prop, feature_impl const& feature, @@ -368,11 +367,11 @@ void format_properties::from_xml(xml_node const& node, fontset_map const& fontse set_property_from_xml(text_transform, "text-transform", node); set_property_from_xml(ff_settings, "font-feature-settings", node); - optional face_name_ = node.get_opt_attr("face-name"); - if (face_name_) + const auto face_name_ = node.get_opt_attr("face-name"); + if (face_name_.has_value()) face_name = *face_name_; - optional fontset_name_ = node.get_opt_attr("fontset-name"); - if (fontset_name_) + const auto fontset_name_ = node.get_opt_attr("fontset-name"); + if (fontset_name_.has_value()) { std::map::const_iterator itr = fontsets.find(*fontset_name_); if (itr != fontsets.end()) diff --git a/src/tiff_reader.hpp b/src/tiff_reader.hpp index 38e4be507..0e305edeb 100644 --- a/src/tiff_reader.hpp +++ b/src/tiff_reader.hpp @@ -16,7 +16,6 @@ MAPNIK_DISABLE_WARNING_PUSH MAPNIK_DISABLE_WARNING_POP #include #endif -#include "tiff_reader.hpp" // stl #include @@ -78,7 +77,7 @@ class tiff_reader : public image_reader int tile_height_; std::size_t width_; std::size_t height_; - boost::optional> bbox_; + std::optional> bbox_; unsigned bps_; unsigned sample_format_; unsigned photometric_; @@ -95,50 +94,20 @@ class tiff_reader : public image_reader virtual ~tiff_reader(); unsigned width() const final; unsigned height() const final; - boost::optional> bounding_box() const final; - inline bool has_alpha() const final - { - return has_alpha_; - } + std::optional> bounding_box() const final; + inline bool has_alpha() const final { return has_alpha_; } void read(unsigned x, unsigned y, image_rgba8& image) final; image_any read(unsigned x, unsigned y, unsigned width, unsigned height) final; // methods specific to tiff reader - unsigned bits_per_sample() const - { - return bps_; - } - unsigned sample_format() const - { - return sample_format_; - } - unsigned photometric() const - { - return photometric_; - } - bool is_tiled() const - { - return is_tiled_; - } - unsigned tile_width() const - { - return tile_width_; - } - unsigned tile_height() const - { - return tile_height_; - } - unsigned rows_per_strip() const - { - return rows_per_strip_; - } - unsigned planar_config() const - { - return planar_config_; - } - unsigned compression() const - { - return compression_; - } + unsigned bits_per_sample() const { return bps_; } + unsigned sample_format() const { return sample_format_; } + unsigned photometric() const { return photometric_; } + bool is_tiled() const { return is_tiled_; } + unsigned tile_width() const { return tile_width_; } + unsigned tile_height() const { return tile_height_; } + unsigned rows_per_strip() const { return rows_per_strip_; } + unsigned planar_config() const { return planar_config_; } + unsigned compression() const { return compression_; } private: tiff_reader(const tiff_reader&); @@ -189,9 +158,9 @@ tiff_reader::tiff_reader(std::string const& filename) , is_tiled_(false) { #if defined(MAPNIK_MEMORY_MAPPED_FILE) - boost::optional memory = mapnik::mapped_memory_cache::instance().find(filename, true); + const auto memory = mapnik::mapped_memory_cache::instance().find(filename, true); - if (memory) + if (memory.has_value()) { mapped_region_ = *memory; stream_.buffer(static_cast(mapped_region_->get_address()), mapped_region_->get_size()); @@ -311,7 +280,7 @@ void tiff_reader::init() double loy = tilepoint[4]; double hix = lox + pixelscale[0] * width_; double hiy = loy - pixelscale[1] * height_; - bbox_.reset(box2d(lox, loy, hix, hiy)); + bbox_ = box2d{lox, loy, hix, hiy}; MAPNIK_LOG_DEBUG(tiff_reader) << "Bounding Box:" << *bbox_; } } @@ -319,11 +288,11 @@ void tiff_reader::init() { if (height_ > 128 * 1024 * 1024) { - std::size_t line_size = (bands_ * width_ * bps_ + 7) / 8; + const std::size_t line_size = (bands_ * width_ * bps_ + 7) / 8; std::size_t default_strip_height = 8192 / line_size; if (default_strip_height == 0) default_strip_height = 1; - std::size_t num_strips = height_ / default_strip_height; + const std::size_t num_strips = height_ / default_strip_height; if (num_strips > 128 * 1024 * 1024) { throw image_reader_exception("Can't allocate tiff"); @@ -349,7 +318,7 @@ unsigned tiff_reader::height() const } template -boost::optional> tiff_reader::bounding_box() const +std::optional> tiff_reader::bounding_box() const { return bbox_; } @@ -395,14 +364,14 @@ image_any tiff_reader::read_any_gray(std::size_t x0, std::size_t y0, std::siz if (tif) { image_type data(width, height); - std::size_t block_size = rows_per_strip_ > 0 ? rows_per_strip_ : tile_height_; - std::size_t start_y = y0 - y0 % block_size; - std::size_t end_y = std::min(y0 + height, height_); - std::size_t start_x = x0; - std::size_t end_x = std::min(x0 + width, width_); - std::size_t element_size = sizeof(pixel_type); + const std::size_t block_size = rows_per_strip_ > 0 ? rows_per_strip_ : tile_height_; + const std::size_t start_y = y0 - y0 % block_size; + const std::size_t end_y = std::min(y0 + height, height_); + const std::size_t start_x = x0; + const std::size_t end_x = std::min(x0 + width, width_); + constexpr std::size_t element_size = sizeof(pixel_type); MAPNIK_LOG_DEBUG(tiff_reader) << "SCANLINE SIZE=" << TIFFScanlineSize(tif); - std::size_t size_to_allocate = (TIFFScanlineSize(tif) + element_size - 1) / element_size; + const std::size_t size_to_allocate = (TIFFScanlineSize(tif) + element_size - 1) / element_size; std::unique_ptr const scanline(new pixel_type[size_to_allocate]); if (planar_config_ == PLANARCONFIG_CONTIG) { @@ -469,8 +438,8 @@ image_any tiff_reader::read(unsigned x, unsigned y, unsigned width, unsigned { throw image_reader_exception("Can't allocate tiff > 10000x10000"); } - std::size_t x0 = static_cast(x); - std::size_t y0 = static_cast(y); + const std::size_t x0 = static_cast(x); + const std::size_t y0 = static_cast(y); switch (photometric_) { case PHOTOMETRIC_MINISBLACK: @@ -591,7 +560,7 @@ struct tiff_reader_traits std::size_t tile_width, std::size_t tile_height) { - std::uint32_t tile_size = TIFFTileSize(tif); + const std::uint32_t tile_size = TIFFTileSize(tif); return (TIFFReadEncodedTile(tif, TIFFComputeTile(tif, x, y, 0, 0), buf, tile_size) != -1); } @@ -644,22 +613,20 @@ void tiff_reader::read_tiled(std::size_t x0, std::size_t y0, ImageData& image TIFF* tif = open(stream_); if (tif) { - std::uint32_t tile_size = TIFFTileSize(tif); + const std::uint32_t tile_size = TIFFTileSize(tif); std::unique_ptr tile(new pixel_type[tile_size]); - std::size_t width = image.width(); - std::size_t height = image.height(); - std::size_t start_y = (y0 / tile_height_) * tile_height_; - std::size_t end_y = ((y0 + height) / tile_height_ + 1) * tile_height_; - std::size_t start_x = (x0 / tile_width_) * tile_width_; - std::size_t end_x = ((x0 + width) / tile_width_ + 1) * tile_width_; - end_y = std::min(end_y, height_); - end_x = std::min(end_x, width_); - bool pick_first_band = + const std::size_t width = image.width(); + const std::size_t height = image.height(); + const std::size_t start_y = (y0 / tile_height_) * tile_height_; + const std::size_t end_y = std::min(((y0 + height) / tile_height_ + 1) * tile_height_, height_); + const std::size_t start_x = (x0 / tile_width_) * tile_width_; + const std::size_t end_x = std::min(((x0 + width) / tile_width_ + 1) * tile_width_, width_); + const bool pick_first_band = (bands_ > 1) && (tile_size / (tile_width_ * tile_height_ * sizeof(pixel_type)) == bands_); for (std::size_t y = start_y; y < end_y; y += tile_height_) { - std::size_t ty0 = std::max(y0, y) - y; - std::size_t ty1 = std::min(height + y0, y + tile_height_) - y; + const std::size_t ty0 = std::max(y0, y) - y; + const std::size_t ty1 = std::min(height + y0, y + tile_height_) - y; for (std::size_t x = start_x; x < end_x; x += tile_width_) { @@ -677,8 +644,8 @@ void tiff_reader::read_tiled(std::size_t x0, std::size_t y0, ImageData& image tile[n] = tile[n * bands_]; } } - std::size_t tx0 = std::max(x0, x); - std::size_t tx1 = std::min(width + x0, x + tile_width_); + const std::size_t tx0 = std::max(x0, x); + const std::size_t tx1 = std::min(width + x0, x + tile_width_); std::size_t row_index = y + ty0 - y0; if (detail::tiff_reader_traits::reverse) @@ -712,22 +679,23 @@ void tiff_reader::read_stripped(std::size_t x0, std::size_t y0, ImageData& im TIFF* tif = open(stream_); if (tif) { - std::uint32_t strip_size = TIFFStripSize(tif); + const std::uint32_t strip_size = TIFFStripSize(tif); std::unique_ptr strip(new pixel_type[strip_size]); - std::size_t width = image.width(); - std::size_t height = image.height(); + const std::size_t width = image.width(); + const std::size_t height = image.height(); + + const std::size_t start_y = (y0 / rows_per_strip_) * rows_per_strip_; + const std::size_t end_y = std::min(y0 + height, height_); + const std::size_t tx0{x0}; + const std::size_t tx1{std::min(width + x0, width_)}; - std::size_t start_y = (y0 / rows_per_strip_) * rows_per_strip_; - std::size_t end_y = std::min(y0 + height, height_); - std::size_t tx0, tx1, ty0, ty1; - tx0 = x0; - tx1 = std::min(width + x0, width_); std::size_t row = 0; - bool pick_first_band = (bands_ > 1) && (strip_size / (width_ * rows_per_strip_ * sizeof(pixel_type)) == bands_); + const bool pick_first_band = + (bands_ > 1) && (strip_size / (width_ * rows_per_strip_ * sizeof(pixel_type)) == bands_); for (std::size_t y = start_y; y < end_y; y += rows_per_strip_) { - ty0 = std::max(y0, y) - y; - ty1 = std::min(end_y, y + rows_per_strip_) - y; + const std::size_t ty0 = std::max(y0, y) - y; + const std::size_t ty1 = std::min(end_y, y + rows_per_strip_) - y; if (!detail::tiff_reader_traits::read_strip(tif, y, rows_per_strip_, width_, strip.get())) { diff --git a/src/util/mapped_memory_file.cpp b/src/util/mapped_memory_file.cpp index 3080eb330..f575c5e6d 100644 --- a/src/util/mapped_memory_file.cpp +++ b/src/util/mapped_memory_file.cpp @@ -21,9 +21,9 @@ mapped_memory_file::mapped_memory_file(std::string const& file_name) #endif { #if defined(MAPNIK_MEMORY_MAPPED_FILE) - boost::optional memory = mapnik::mapped_memory_cache::instance().find(file_name, true); + const auto memory = mapnik::mapped_memory_cache::instance().find(file_name, true); - if (memory) + if (memory.has_value()) { mapped_region_ = *memory; file_.buffer(static_cast(mapped_region_->get_address()), mapped_region_->get_size()); diff --git a/src/warp.cpp b/src/warp.cpp index 2f995a339..e48847f80 100644 --- a/src/warp.cpp +++ b/src/warp.cpp @@ -89,7 +89,7 @@ MAPNIK_DECL void warp_image(T& target, unsigned mesh_size, scaling_method_e scaling_method, double filter_factor, - boost::optional const& nodata_value) + std::optional const& nodata_value) { using image_type = T; using pixel_type = typename image_type::pixel_type; @@ -163,13 +163,11 @@ MAPNIK_DECL void warp_image(T& target, rasterizer.line_to_d(std::floor(polygon[4]), std::floor(polygon[5])); rasterizer.line_to_d(std::floor(polygon[6]), std::floor(polygon[7])); - std::size_t x0 = i * mesh_size; - std::size_t y0 = j * mesh_size; - std::size_t x1 = (i + 1) * mesh_size; - std::size_t y1 = (j + 1) * mesh_size; - x1 = std::min(x1, source.width()); - y1 = std::min(y1, source.height()); - agg::trans_affine tr(polygon, x0, y0, x1, y1); + const std::size_t x0 = i * mesh_size; + const std::size_t y0 = j * mesh_size; + const std::size_t x1 = std::min((i + 1) * mesh_size, source.width()); + const std::size_t y1 = std::min((j + 1) * mesh_size, source.height()); + const agg::trans_affine tr(polygon, x0, y0, x1, y1); if (tr.is_valid()) { interpolator_type interpolator(tr); @@ -184,7 +182,7 @@ MAPNIK_DECL void warp_image(T& target, using span_gen_type = typename detail::agg_scaling_traits::span_image_resample_affine; agg::image_filter_lut filter; detail::set_scaling_method(filter, scaling_method, filter_factor); - boost::optional nodata; + std::optional nodata; if (nodata_value) { nodata = safe_cast(*nodata_value); @@ -209,7 +207,7 @@ struct warp_image_visitor unsigned mesh_size, scaling_method_e scaling_method, double filter_factor, - boost::optional const& nodata_value) + std::optional const& nodata_value) : target_raster_(target_raster) , prj_trans_(prj_trans) , source_ext_(source_ext) @@ -253,7 +251,7 @@ struct warp_image_visitor unsigned mesh_size_; scaling_method_e scaling_method_; double filter_factor_; - boost::optional const& nodata_value_; + std::optional const& nodata_value_; }; } // namespace detail @@ -265,7 +263,7 @@ void reproject_and_scale_raster(raster& target, double offset_y, unsigned mesh_size, scaling_method_e scaling_method, - boost::optional const& nodata_value) + std::optional const& nodata_value) { detail::warp_image_visitor warper(target, prj_trans, @@ -287,14 +285,7 @@ void reproject_and_scale_raster(raster& target, unsigned mesh_size, scaling_method_e scaling_method) { - reproject_and_scale_raster(target, - source, - prj_trans, - offset_x, - offset_y, - mesh_size, - scaling_method, - boost::optional()); + reproject_and_scale_raster(target, source, prj_trans, offset_x, offset_y, mesh_size, scaling_method, std::nullopt); } template MAPNIK_DECL void warp_image(image_rgba8&, @@ -307,7 +298,7 @@ template MAPNIK_DECL void warp_image(image_rgba8&, unsigned, scaling_method_e, double, - boost::optional const&); + std::optional const&); template MAPNIK_DECL void warp_image(image_gray8&, image_gray8 const&, @@ -319,7 +310,7 @@ template MAPNIK_DECL void warp_image(image_gray8&, unsigned, scaling_method_e, double, - boost::optional const&); + std::optional const&); template MAPNIK_DECL void warp_image(image_gray16&, image_gray16 const&, @@ -331,7 +322,7 @@ template MAPNIK_DECL void warp_image(image_gray16&, unsigned, scaling_method_e, double, - boost::optional const&); + std::optional const&); template MAPNIK_DECL void warp_image(image_gray32f&, image_gray32f const&, @@ -343,6 +334,6 @@ template MAPNIK_DECL void warp_image(image_gray32f&, unsigned, scaling_method_e, double, - boost::optional const&); + std::optional const&); } // namespace mapnik diff --git a/src/webp_reader.cpp b/src/webp_reader.cpp index 24b942525..5ba37e64e 100644 --- a/src/webp_reader.cpp +++ b/src/webp_reader.cpp @@ -101,7 +101,7 @@ class webp_reader : public image_reader ~webp_reader(); unsigned width() const final; unsigned height() const final; - boost::optional> bounding_box() const final; + std::optional> bounding_box() const final override; inline bool has_alpha() const final { return has_alpha_; } void read(unsigned x, unsigned y, image_rgba8& image) final; image_any read(unsigned x, unsigned y, unsigned width, unsigned height) final; @@ -208,9 +208,9 @@ unsigned webp_reader::height() const } template -boost::optional> webp_reader::bounding_box() const +std::optional> webp_reader::bounding_box() const { - return boost::optional>(); + return std::nullopt; } template diff --git a/src/well_known_srs.cpp b/src/well_known_srs.cpp index 2efb7a5d0..e7b7c656f 100644 --- a/src/well_known_srs.cpp +++ b/src/well_known_srs.cpp @@ -25,14 +25,9 @@ #include #include -#include -MAPNIK_DISABLE_WARNING_PUSH -#include -#include -MAPNIK_DISABLE_WARNING_POP - // stl #include +#include namespace mapnik { constexpr const char MAPNIK_GEOGRAPHIC_PROJ_STR[10]{"epsg:4326"}; @@ -43,36 +38,36 @@ extern std::string const MAPNIK_WEBMERCATOR_PROJ = MAPNIK_WEBMERCATOR_PROJ_STR; static const char* well_known_srs_strings[] = {MAPNIK_GEOGRAPHIC_PROJ.c_str(), MAPNIK_WEBMERCATOR_PROJ.c_str(), ""}; -boost::optional is_well_known_srs(std::string const& srs) +std::optional is_well_known_srs(std::string const& srs) { if (srs == MAPNIK_GEOGRAPHIC_PROJ) { - return boost::optional(mapnik::well_known_srs_enum::WGS_84); + return mapnik::well_known_srs_enum::WGS_84; } else if (srs == MAPNIK_WEBMERCATOR_PROJ) { - return boost::optional(mapnik::well_known_srs_enum::WEB_MERC); + return mapnik::well_known_srs_enum::WEB_MERC; } - return boost::optional(); + return std::nullopt; } -boost::optional is_known_geographic(std::string const& srs) +std::optional is_known_geographic(std::string const& srs) { std::string trimmed = util::trim_copy(srs); if (trimmed == MAPNIK_GEOGRAPHIC_PROJ) { - return boost::optional(true); + return true; } else if (trimmed == MAPNIK_WEBMERCATOR_PROJ) { - return boost::optional(false); + return false; } - return boost::optional(); + return std::nullopt; } using well_known_srs_e_str = mapnik::detail::EnumStringT; constexpr detail::EnumMapT well_known_srs_e_map{{ - well_known_srs_e_str{well_known_srs_enum::WGS_84, detail::mapnik_string_view{MAPNIK_GEOGRAPHIC_PROJ_STR}}, + well_known_srs_e_str{well_known_srs_enum::WGS_84, MAPNIK_GEOGRAPHIC_PROJ_STR}, well_known_srs_e_str{well_known_srs_enum::WEB_MERC, MAPNIK_WEBMERCATOR_PROJ_STR}, well_known_srs_e_str{well_known_srs_enum::well_known_srs_enum_MAX, ""}, }}; diff --git a/src/xml_tree.cpp b/src/xml_tree.cpp index 2cc8d58f5..6989efaf0 100644 --- a/src/xml_tree.cpp +++ b/src/xml_tree.cpp @@ -58,7 +58,10 @@ struct name_trait template<> \ struct name_trait \ { \ - static std::string name() { return std::string("type ") + type_name; } \ + static std::string name() \ + { \ + return std::string("type ") + type_name; \ + } \ }; DEFINE_NAME_TRAIT(double, "double") @@ -331,15 +334,15 @@ bool xml_node::has_attribute(std::string const& name) const } template -boost::optional xml_node::get_opt_attr(std::string const& name) const +std::optional xml_node::get_opt_attr(std::string const& name) const { if (attributes_.empty()) - return boost::optional(); + return std::nullopt; std::map::const_iterator itr = attributes_.find(name); if (itr == attributes_.end()) - return boost::optional(); + return std::nullopt; itr->second.processed = true; - boost::optional result = xml_attribute_cast(tree_, std::string(itr->second.value)); + std::optional result = xml_attribute_cast(tree_, std::string(itr->second.value)); if (!result) { throw config_error(std::string("Failed to parse attribute '") + name + "'. Expected " + name_trait::name() + @@ -352,7 +355,7 @@ boost::optional xml_node::get_opt_attr(std::string const& name) const template T xml_node::get_attr(std::string const& name, T const& default_opt_value) const { - boost::optional val = get_opt_attr(name); + auto val = get_opt_attr(name); if (val) return *val; return default_opt_value; @@ -361,7 +364,7 @@ T xml_node::get_attr(std::string const& name, T const& default_opt_value) const template T xml_node::get_attr(std::string const& name) const { - boost::optional val = get_opt_attr(name); + const auto val = get_opt_attr(name); if (val) return *val; throw attribute_not_found(name_, name); @@ -392,7 +395,7 @@ std::string const& xml_node::get_text() const template T xml_node::get_value() const { - boost::optional result = xml_attribute_cast(tree_, get_text()); + std::optional result = xml_attribute_cast(tree_, get_text()); if (!result) { throw config_error(std::string("Failed to parse value. Expected ") + name_trait::name() + " but got '" + @@ -414,7 +417,7 @@ std::string xml_node::line_to_string() const return number; } -#define compile_get_opt_attr(T) template boost::optional xml_node::get_opt_attr(std::string const&) const +#define compile_get_opt_attr(T) template std::optional xml_node::get_opt_attr(std::string const&) const #define compile_get_attr(T) \ template T xml_node::get_attr(std::string const&) const; \ template T xml_node::get_attr(std::string const&, T const&) const diff --git a/test/catch.hpp b/test/catch.hpp index 2fbb4a76b..b865fd077 100644 --- a/test/catch.hpp +++ b/test/catch.hpp @@ -809,7 +809,7 @@ constexpr auto operator"" _catch_sr(char const* rawChars, std::size_t size) noex struct TypeList \ {}; \ template \ - constexpr auto get_wrapper() noexcept->TypeList \ + constexpr auto get_wrapper() noexcept -> TypeList \ { \ return {}; \ } \ @@ -817,7 +817,7 @@ constexpr auto operator"" _catch_sr(char const* rawChars, std::size_t size) noex struct TemplateTypeList \ {}; \ template class... Cs> \ - constexpr auto get_wrapper() noexcept->TemplateTypeList \ + constexpr auto get_wrapper() noexcept -> TemplateTypeList \ { \ return {}; \ } \ @@ -883,7 +883,7 @@ constexpr auto operator"" _catch_sr(char const* rawChars, std::size_t size) noex struct Nttp \ {}; \ template \ - constexpr auto get_wrapper() noexcept->Nttp<__VA_ARGS__> \ + constexpr auto get_wrapper() noexcept -> Nttp<__VA_ARGS__> \ { \ return {}; \ } \ @@ -891,7 +891,7 @@ constexpr auto operator"" _catch_sr(char const* rawChars, std::size_t size) noex struct NttpTemplateTypeList \ {}; \ template class... Cs> \ - constexpr auto get_wrapper() noexcept->NttpTemplateTypeList \ + constexpr auto get_wrapper() noexcept -> NttpTemplateTypeList \ { \ return {}; \ } \ @@ -1351,9 +1351,8 @@ struct AutoReg : NonCopyable Signature, \ ...) \ namespace { \ - namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) \ - { \ - INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD(TestName, ClassName, INTERNAL_CATCH_REMOVE_PARENS(Signature)); \ + namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \ + INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD(TestName, ClassName, INTERNAL_CATCH_REMOVE_PARENS(Signature)); \ } \ } \ INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD(TestName, INTERNAL_CATCH_REMOVE_PARENS(Signature)) @@ -1508,29 +1507,27 @@ struct AutoReg : NonCopyable CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ INTERNAL_CATCH_DECLARE_SIG_TEST(TestFunc, INTERNAL_CATCH_REMOVE_PARENS(Signature)); \ namespace { \ - namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) \ + namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \ + INTERNAL_CATCH_TYPE_GEN \ + INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ + INTERNAL_CATCH_NTTP_REG_GEN(TestFunc, INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ + template \ + struct TestName \ { \ - INTERNAL_CATCH_TYPE_GEN \ - INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ - INTERNAL_CATCH_NTTP_REG_GEN(TestFunc, INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ - template \ - struct TestName \ + TestName() \ { \ - TestName() \ - { \ - int index = 0; \ - constexpr char const* tmpl_types[] = { \ - CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, __VA_ARGS__)}; \ - using expander = int[]; \ - (void)expander{ \ - (reg_test(Types{}, Catch::NameAndTags{Name " - " + std::string(tmpl_types[index]), Tags}), \ - index++)...}; /* NOLINT */ \ - } \ - }; \ - static int INTERNAL_CATCH_UNIQUE_NAME(globalRegistrar) = []() { \ - TestName(); \ - return 0; \ - }(); \ + int index = 0; \ + constexpr char const* tmpl_types[] = { \ + CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, __VA_ARGS__)}; \ + using expander = int[]; \ + (void)expander{(reg_test(Types{}, Catch::NameAndTags{Name " - " + std::string(tmpl_types[index]), Tags}), \ + index++)...}; /* NOLINT */ \ + } \ + }; \ + static int INTERNAL_CATCH_UNIQUE_NAME(globalRegistrar) = []() { \ + TestName(); \ + return 0; \ + }(); \ } \ } \ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ @@ -1590,41 +1587,40 @@ struct AutoReg : NonCopyable template \ static void TestFuncName(); \ namespace { \ - namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) \ + namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \ + INTERNAL_CATCH_TYPE_GEN \ + INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ + template \ + struct TestName \ { \ - INTERNAL_CATCH_TYPE_GEN \ - INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ - template \ - struct TestName \ + void reg_tests() \ { \ - void reg_tests() \ - { \ - int index = 0; \ - using expander = int[]; \ - constexpr char const* tmpl_types[] = { \ - CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TmplTypes))}; \ - constexpr char const* types_list[] = { \ - CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TypesList))}; \ - constexpr auto num_types = sizeof(types_list) / sizeof(types_list[0]); \ - (void)expander{ \ - (Catch::AutoReg(Catch::makeTestInvoker(&TestFuncName), \ - CATCH_INTERNAL_LINEINFO, \ - Catch::StringRef(), \ - Catch::NameAndTags{Name " - " + std::string(tmpl_types[index / num_types]) + "<" + \ - std::string(types_list[index % num_types]) + ">", \ - Tags}), \ - index++)...}; /* NOLINT */ \ - } \ - }; \ - static int INTERNAL_CATCH_UNIQUE_NAME(globalRegistrar) = []() { \ - using TestInit = typename create< \ - TestName, \ - decltype(get_wrapper()), \ - TypeList>::type; \ - TestInit t; \ - t.reg_tests(); \ - return 0; \ - }(); \ + int index = 0; \ + using expander = int[]; \ + constexpr char const* tmpl_types[] = { \ + CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TmplTypes))}; \ + constexpr char const* types_list[] = { \ + CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TypesList))}; \ + constexpr auto num_types = sizeof(types_list) / sizeof(types_list[0]); \ + (void)expander{ \ + (Catch::AutoReg(Catch::makeTestInvoker(&TestFuncName), \ + CATCH_INTERNAL_LINEINFO, \ + Catch::StringRef(), \ + Catch::NameAndTags{Name " - " + std::string(tmpl_types[index / num_types]) + "<" + \ + std::string(types_list[index % num_types]) + ">", \ + Tags}), \ + index++)...}; /* NOLINT */ \ + } \ + }; \ + static int INTERNAL_CATCH_UNIQUE_NAME(globalRegistrar) = []() { \ + using TestInit = typename create< \ + TestName, \ + decltype(get_wrapper()), \ + TypeList>::type; \ + TestInit t; \ + t.reg_tests(); \ + return 0; \ + }(); \ } \ } \ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ @@ -1678,32 +1674,31 @@ struct AutoReg : NonCopyable template \ static void TestFunc(); \ namespace { \ - namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) \ + namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \ + INTERNAL_CATCH_TYPE_GEN \ + template \ + struct TestName \ { \ - INTERNAL_CATCH_TYPE_GEN \ - template \ - struct TestName \ + void reg_tests() \ { \ - void reg_tests() \ - { \ - int index = 0; \ - using expander = int[]; \ - (void)expander{ \ - (Catch::AutoReg(Catch::makeTestInvoker(&TestFunc), \ - CATCH_INTERNAL_LINEINFO, \ - Catch::StringRef(), \ - Catch::NameAndTags{Name " - " + std::string(INTERNAL_CATCH_STRINGIZE(TmplList)) + \ - " - " + std::to_string(index), \ - Tags}), \ - index++)...}; /* NOLINT */ \ - } \ - }; \ - static int INTERNAL_CATCH_UNIQUE_NAME(globalRegistrar) = []() { \ - using TestInit = typename convert::type; \ - TestInit t; \ - t.reg_tests(); \ - return 0; \ - }(); \ + int index = 0; \ + using expander = int[]; \ + (void)expander{ \ + (Catch::AutoReg(Catch::makeTestInvoker(&TestFunc), \ + CATCH_INTERNAL_LINEINFO, \ + Catch::StringRef(), \ + Catch::NameAndTags{Name " - " + std::string(INTERNAL_CATCH_STRINGIZE(TmplList)) + \ + " - " + std::to_string(index), \ + Tags}), \ + index++)...}; /* NOLINT */ \ + } \ + }; \ + static int INTERNAL_CATCH_UNIQUE_NAME(globalRegistrar) = []() { \ + using TestInit = typename convert::type; \ + TestInit t; \ + t.reg_tests(); \ + return 0; \ + }(); \ } \ } \ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ @@ -1724,31 +1719,29 @@ struct AutoReg : NonCopyable CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ namespace { \ - namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) \ + namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \ + INTERNAL_CATCH_TYPE_GEN \ + INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ + INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD(TestName, ClassName, INTERNAL_CATCH_REMOVE_PARENS(Signature)); \ + INTERNAL_CATCH_NTTP_REG_METHOD_GEN(TestName, INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ + template \ + struct TestNameClass \ { \ - INTERNAL_CATCH_TYPE_GEN \ - INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ - INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD(TestName, ClassName, INTERNAL_CATCH_REMOVE_PARENS(Signature)); \ - INTERNAL_CATCH_NTTP_REG_METHOD_GEN(TestName, INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ - template \ - struct TestNameClass \ + TestNameClass() \ { \ - TestNameClass() \ - { \ - int index = 0; \ - constexpr char const* tmpl_types[] = { \ - CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, __VA_ARGS__)}; \ - using expander = int[]; \ - (void)expander{(reg_test(Types{}, \ - #ClassName, \ - Catch::NameAndTags{Name " - " + std::string(tmpl_types[index]), Tags}), \ - index++)...}; /* NOLINT */ \ - } \ - }; \ - static int INTERNAL_CATCH_UNIQUE_NAME(globalRegistrar) = []() { \ - TestNameClass(); \ - return 0; \ - }(); \ + int index = 0; \ + constexpr char const* tmpl_types[] = { \ + CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, __VA_ARGS__)}; \ + using expander = int[]; \ + (void)expander{ \ + (reg_test(Types{}, #ClassName, Catch::NameAndTags{Name " - " + std::string(tmpl_types[index]), Tags}), \ + index++)...}; /* NOLINT */ \ + } \ + }; \ + static int INTERNAL_CATCH_UNIQUE_NAME(globalRegistrar) = []() { \ + TestNameClass(); \ + return 0; \ + }(); \ } \ } \ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ @@ -1816,41 +1809,40 @@ struct AutoReg : NonCopyable void test(); \ }; \ namespace { \ - namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestNameClass) \ + namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestNameClass) { \ + INTERNAL_CATCH_TYPE_GEN \ + INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ + template \ + struct TestNameClass \ { \ - INTERNAL_CATCH_TYPE_GEN \ - INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ - template \ - struct TestNameClass \ + void reg_tests() \ { \ - void reg_tests() \ - { \ - int index = 0; \ - using expander = int[]; \ - constexpr char const* tmpl_types[] = { \ - CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TmplTypes))}; \ - constexpr char const* types_list[] = { \ - CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TypesList))}; \ - constexpr auto num_types = sizeof(types_list) / sizeof(types_list[0]); \ - (void)expander{ \ - (Catch::AutoReg(Catch::makeTestInvoker(&TestName::test), \ - CATCH_INTERNAL_LINEINFO, \ - #ClassName, \ - Catch::NameAndTags{Name " - " + std::string(tmpl_types[index / num_types]) + "<" + \ - std::string(types_list[index % num_types]) + ">", \ - Tags}), \ - index++)...}; /* NOLINT */ \ - } \ - }; \ - static int INTERNAL_CATCH_UNIQUE_NAME(globalRegistrar) = []() { \ - using TestInit = typename create< \ - TestNameClass, \ - decltype(get_wrapper()), \ - TypeList>::type; \ - TestInit t; \ - t.reg_tests(); \ - return 0; \ - }(); \ + int index = 0; \ + using expander = int[]; \ + constexpr char const* tmpl_types[] = { \ + CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TmplTypes))}; \ + constexpr char const* types_list[] = { \ + CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TypesList))}; \ + constexpr auto num_types = sizeof(types_list) / sizeof(types_list[0]); \ + (void)expander{ \ + (Catch::AutoReg(Catch::makeTestInvoker(&TestName::test), \ + CATCH_INTERNAL_LINEINFO, \ + #ClassName, \ + Catch::NameAndTags{Name " - " + std::string(tmpl_types[index / num_types]) + "<" + \ + std::string(types_list[index % num_types]) + ">", \ + Tags}), \ + index++)...}; /* NOLINT */ \ + } \ + }; \ + static int INTERNAL_CATCH_UNIQUE_NAME(globalRegistrar) = []() { \ + using TestInit = typename create< \ + TestNameClass, \ + decltype(get_wrapper()), \ + TypeList>::type; \ + TestInit t; \ + t.reg_tests(); \ + return 0; \ + }(); \ } \ } \ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ @@ -1911,32 +1903,31 @@ struct AutoReg : NonCopyable void test(); \ }; \ namespace { \ - namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) \ + namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \ + INTERNAL_CATCH_TYPE_GEN \ + template \ + struct TestNameClass \ { \ - INTERNAL_CATCH_TYPE_GEN \ - template \ - struct TestNameClass \ + void reg_tests() \ { \ - void reg_tests() \ - { \ - int index = 0; \ - using expander = int[]; \ - (void)expander{ \ - (Catch::AutoReg(Catch::makeTestInvoker(&TestName::test), \ - CATCH_INTERNAL_LINEINFO, \ - #ClassName, \ - Catch::NameAndTags{Name " - " + std::string(INTERNAL_CATCH_STRINGIZE(TmplList)) + \ - " - " + std::to_string(index), \ - Tags}), \ - index++)...}; /* NOLINT */ \ - } \ - }; \ - static int INTERNAL_CATCH_UNIQUE_NAME(globalRegistrar) = []() { \ - using TestInit = typename convert::type; \ - TestInit t; \ - t.reg_tests(); \ - return 0; \ - }(); \ + int index = 0; \ + using expander = int[]; \ + (void)expander{ \ + (Catch::AutoReg(Catch::makeTestInvoker(&TestName::test), \ + CATCH_INTERNAL_LINEINFO, \ + #ClassName, \ + Catch::NameAndTags{Name " - " + std::string(INTERNAL_CATCH_STRINGIZE(TmplList)) + \ + " - " + std::to_string(index), \ + Tags}), \ + index++)...}; /* NOLINT */ \ + } \ + }; \ + static int INTERNAL_CATCH_UNIQUE_NAME(globalRegistrar) = []() { \ + using TestInit = typename convert::type; \ + TestInit t; \ + t.reg_tests(); \ + return 0; \ + }(); \ } \ } \ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ @@ -3217,8 +3208,8 @@ struct IResultCapture virtual void sectionEnded(SectionEndInfo const& endInfo) = 0; virtual void sectionEndedEarly(SectionEndInfo const& endInfo) = 0; - virtual auto acquireGeneratorTracker(StringRef generatorName, SourceLineInfo const& lineInfo) - -> IGeneratorTracker& = 0; + virtual auto acquireGeneratorTracker(StringRef generatorName, + SourceLineInfo const& lineInfo) -> IGeneratorTracker& = 0; #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) virtual void benchmarkPreparing(std::string const& name) = 0; @@ -4693,8 +4684,9 @@ using StringMatcher = Matchers::Impl::MatcherBase; void handleExceptionMatchExpr(AssertionHandler& handler, StringMatcher const& matcher, StringRef const& matcherString); template -auto makeMatchExpr(ArgT const& arg, MatcherT const& matcher, StringRef const& matcherString) - -> MatchExpr +auto makeMatchExpr(ArgT const& arg, + MatcherT const& matcher, + StringRef const& matcherString) -> MatchExpr { return MatchExpr(arg, matcher, matcherString); } @@ -5010,8 +5002,9 @@ template // Note: The type after -> is weird, because VS2015 cannot parse // the expression used in the typedef inside, when it is in // return type. Yeah. -auto generate(StringRef generatorName, SourceLineInfo const& lineInfo, L const& generatorExpression) - -> decltype(std::declval().get()) +auto generate(StringRef generatorName, + SourceLineInfo const& lineInfo, + L const& generatorExpression) -> decltype(std::declval().get()) { using UnderlyingType = typename decltype(generatorExpression())::type; @@ -5376,10 +5369,10 @@ class Option : nullableValue(nullptr) {} Option(T const& _value) - : nullableValue(new (storage) T(_value)) + : nullableValue(new(storage) T(_value)) {} Option(Option const& _other) - : nullableValue(_other ? new (storage) T(*_other) : nullptr) + : nullableValue(_other ? new(storage) T(*_other) : nullptr) {} ~Option() { reset(); } @@ -9283,8 +9276,8 @@ class RunContext : public IResultCapture, void sectionEnded(SectionEndInfo const& endInfo) override; void sectionEndedEarly(SectionEndInfo const& endInfo) override; - auto acquireGeneratorTracker(StringRef generatorName, SourceLineInfo const& lineInfo) - -> IGeneratorTracker& override; + auto acquireGeneratorTracker(StringRef generatorName, + SourceLineInfo const& lineInfo) -> IGeneratorTracker& override; #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) void benchmarkPreparing(std::string const& name) override; @@ -10840,7 +10833,7 @@ struct Help : Opt return ParserResult::ok(ParseResultType::ShortCircuitAll); }) { - static_cast (*this)("display usage information")["-?"]["-h"]["--help"].optional(); + static_cast(*this)("display usage information")["-?"]["-h"]["--help"].optional(); } }; @@ -12362,8 +12355,7 @@ FatalConditionHandler::FatalConditionHandler() { // We do not want to fully error out, because needing // the stack reserve should be rare enough anyway. - Catch::cerr() << "Failed to reserve piece of stack." - << " Stack overflows will not be reported successfully."; + Catch::cerr() << "Failed to reserve piece of stack." << " Stack overflows will not be reported successfully."; } } @@ -14191,10 +14183,7 @@ class RegistryHub : public IRegistryHub, CATCH_INTERNAL_ERROR("Attempted to register active exception under CATCH_CONFIG_DISABLE_EXCEPTIONS!"); #endif } - IMutableEnumValuesRegistry& getMutableEnumValuesRegistry() override - { - return m_enumValuesRegistry; - } + IMutableEnumValuesRegistry& getMutableEnumValuesRegistry() override { return m_enumValuesRegistry; } private: TestRegistry m_testCaseRegistry; @@ -15241,12 +15230,9 @@ void Session::showHelp() const } void Session::libIdentify() { - Catch::cout() << std::left << std::setw(16) << "description: " - << "A Catch2 test executable\n" - << std::left << std::setw(16) << "category: " - << "testframework\n" - << std::left << std::setw(16) << "framework: " - << "Catch Test\n" + Catch::cout() << std::left << std::setw(16) << "description: " << "A Catch2 test executable\n" + << std::left << std::setw(16) << "category: " << "testframework\n" + << std::left << std::setw(16) << "framework: " << "Catch Test\n" << std::left << std::setw(16) << "version: " << libraryVersion() << std::endl; } @@ -19364,8 +19350,7 @@ void JunitReporter::writeAssertion(AssertionStats const& stats) ReusableStringStream rss; if (stats.totals.assertions.total() > 0) { - rss << "FAILED" - << ":\n"; + rss << "FAILED" << ":\n"; if (result.hasExpression()) { rss << " "; diff --git a/test/standalone/map_xml_test.cpp b/test/standalone/map_xml_test.cpp index 35026d5f1..7f07c837a 100644 --- a/test/standalone/map_xml_test.cpp +++ b/test/standalone/map_xml_test.cpp @@ -68,13 +68,12 @@ class tmp_dir } catch (const std::exception& e) { - std::cerr << "Exception caught while trying to remove " - << "temporary directory " << m_path << ": " << e.what() << "\n"; + std::cerr << "Exception caught while trying to remove " << "temporary directory " << m_path << ": " + << e.what() << "\n"; } catch (...) { - std::cerr << "Unknown exception caught while trying to " - << "remove temporary directory " << m_path << "\n"; + std::cerr << "Unknown exception caught while trying to " << "remove temporary directory " << m_path << "\n"; } } diff --git a/test/unit/color/css_color.cpp b/test/unit/color/css_color.cpp index 7bd3e3ef7..ba9018f36 100644 --- a/test/unit/color/css_color.cpp +++ b/test/unit/color/css_color.cpp @@ -73,7 +73,7 @@ TEST_CASE("CSS color") CHECK(c.green() == 0x00); CHECK(c.blue() == 0xff); // rgba (fractional percent) - std::string s2("rgb(50.5%,0.5%,99.5%)"); //#8101fe80 + std::string s2("rgb(50.5%,0.5%,99.5%)"); // #8101fe80 CHECK(boost::spirit::x3::phrase_parse(s2.cbegin(), s2.cend(), color_grammar, space, c)); CHECK(c.alpha() == 0x80); CHECK(c.red() == 0x81); diff --git a/test/unit/datasource/csv.cpp b/test/unit/datasource/csv.cpp index d9734edca..5040486e1 100644 --- a/test/unit/datasource/csv.cpp +++ b/test/unit/datasource/csv.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include MAPNIK_DISABLE_WARNING_PUSH diff --git a/test/unit/datasource/gdal.cpp b/test/unit/datasource/gdal.cpp index e83cd5a52..2f56381a5 100644 --- a/test/unit/datasource/gdal.cpp +++ b/test/unit/datasource/gdal.cpp @@ -29,7 +29,7 @@ namespace { -mapnik::datasource_ptr get_gdal_ds(std::string const& file_name, boost::optional band) +mapnik::datasource_ptr get_gdal_ds(std::string const& file_name, std::optional band) { const bool have_gdal_plugin = mapnik::datasource_cache::instance().plugin_registered("gdal"); if (!have_gdal_plugin) diff --git a/test/unit/datasource/geobuf.cpp b/test/unit/datasource/geobuf.cpp index 4d371ced6..ce2e3f215 100644 --- a/test/unit/datasource/geobuf.cpp +++ b/test/unit/datasource/geobuf.cpp @@ -33,7 +33,6 @@ #include #include #include -#include TEST_CASE("Geobuf") { diff --git a/test/unit/datasource/geojson.cpp b/test/unit/datasource/geojson.cpp index 30522d12b..105e1993e 100644 --- a/test/unit/datasource/geojson.cpp +++ b/test/unit/datasource/geojson.cpp @@ -36,7 +36,8 @@ #include #include #include -#include +#include +#include /* @@ -152,17 +153,19 @@ TEST_CASE("geojson") REQUIRE(json == json_out); } - auto invalid_empty_geometries = {"{ \"type\": \"Point\", \"coordinates\": [] }", - "{ \"type\": \"LineString\", \"coordinates\": [[]] }" - "{ \"type\": \"Polygon\", \"coordinates\": [[[]]] }", - "{ \"type\": \"MultiPoint\", \"coordinates\": [[]] }", - "{ \"type\": \"MultiLineString\", \"coordinates\": [[[]]] }", - "{ \"type\": \"MultiPolygon\", \"coordinates\": [[[[]]]] }"}; + constexpr std::array invalid_empty_geometries{ + "{ \"type\": \"Point\", \"coordinates\": [] }", + "{ \"type\": \"LineString\", \"coordinates\": [[]] }", + "{ \"type\": \"Polygon\", \"coordinates\": [[[]]] }", + "{ \"type\": \"MultiPoint\", \"coordinates\": [[]] }", + "{ \"type\": \"MultiLineString\", \"coordinates\": [[[]]] }", + "{ \"type\": \"MultiPolygon\", \"coordinates\": [[[[]]]] }", + }; - for (auto const& json : invalid_empty_geometries) + for (auto&& json : invalid_empty_geometries) { mapnik::geometry::geometry geom; - CHECK(!mapnik::json::from_geojson(json, geom)); + CHECK(!mapnik::json::from_geojson(std::string{json}, geom)); } } diff --git a/test/unit/datasource/postgis.cpp b/test/unit/datasource/postgis.cpp index cc1512896..2f92991c6 100644 --- a/test/unit/datasource/postgis.cpp +++ b/test/unit/datasource/postgis.cpp @@ -36,8 +36,6 @@ ./test-postgis -d yes */ -#include - namespace { bool run(std::string const& command, bool okay_to_fail = false) diff --git a/test/unit/imaging/image_io_test.cpp b/test/unit/imaging/image_io_test.cpp index 9ce008d80..60e117936 100644 --- a/test/unit/imaging/image_io_test.cpp +++ b/test/unit/imaging/image_io_test.cpp @@ -58,7 +58,7 @@ TEST_CASE("image io") SECTION("readers") { std::string should_throw; - boost::optional type; + std::optional type; try { mapnik::image_rgba8 im_og; diff --git a/test/unit/svg/svg_parser_test.cpp b/test/unit/svg/svg_parser_test.cpp index 2ff448067..7d6d05779 100644 --- a/test/unit/svg/svg_parser_test.cpp +++ b/test/unit/svg/svg_parser_test.cpp @@ -55,8 +55,8 @@ std::ostream& operator<<(std::ostream& os, mapnik::gradient const& gr) double cx, cy, fx, fy, r; gr.get_control_points(fx, fy, cx, cy, r); - os << "\n"; + os << "\n"; for (auto const& stop : gr.get_stop_array()) { os << " (stop) << "\" color=\"" << std::get<1>(stop) << "\"/>\n"; diff --git a/test/unit/vertex_adapter/simplify_converters_test.cpp b/test/unit/vertex_adapter/simplify_converters_test.cpp index b13e3aa69..018ea9a55 100644 --- a/test/unit/vertex_adapter/simplify_converters_test.cpp +++ b/test/unit/vertex_adapter/simplify_converters_test.cpp @@ -26,7 +26,7 @@ void simplify(std::string const& wkt_in, double tolerance, std::string const& me mapnik::geometry::line_string line = input.get>(); mapnik::geometry::line_string_vertex_adapter va(line); mapnik::simplify_converter> generalizer(va); - generalizer.set_simplify_algorithm(mapnik::simplify_algorithm_from_string(method).get()); + generalizer.set_simplify_algorithm(mapnik::simplify_algorithm_from_string(method).value()); generalizer.set_simplify_tolerance(tolerance); mapnik::geometry::line_string output; mapnik::CommandType cmd; diff --git a/test/visual/runner.cpp b/test/visual/runner.cpp index 9394d1b47..3c6ab5c87 100644 --- a/test/visual/runner.cpp +++ b/test/visual/runner.cpp @@ -260,7 +260,7 @@ void runner::parse_params(mapnik::parameters const& params, config& cfg) const { cfg.status = *params.get("status", cfg.status); - boost::optional sizes = params.get("sizes"); + std::optional sizes = params.get("sizes"); if (sizes) { @@ -268,7 +268,7 @@ void runner::parse_params(mapnik::parameters const& params, config& cfg) const parse_map_sizes(*sizes, cfg.sizes); } - boost::optional tiles = params.get("tiles"); + std::optional tiles = params.get("tiles"); if (tiles) { @@ -276,7 +276,7 @@ void runner::parse_params(mapnik::parameters const& params, config& cfg) const parse_map_sizes(*tiles, cfg.tiles); } - boost::optional bbox_string = params.get("bbox"); + std::optional bbox_string = params.get("bbox"); if (bbox_string) { @@ -286,7 +286,7 @@ void runner::parse_params(mapnik::parameters const& params, config& cfg) const for (auto const& renderer : renderers_) { std::string renderer_name = mapnik::util::apply_visitor(renderer_name_visitor(), renderer); - boost::optional enabled = params.get(renderer_name); + std::optional enabled = params.get(renderer_name); if (enabled && !*enabled) { cfg.ignored_renderers.insert(renderer_name); diff --git a/utils/mapnik-index/process_geojson_file_x3.cpp b/utils/mapnik-index/process_geojson_file_x3.cpp index 93545fb11..2fe004892 100644 --- a/utils/mapnik-index/process_geojson_file_x3.cpp +++ b/utils/mapnik-index/process_geojson_file_x3.cpp @@ -251,8 +251,8 @@ std::pair box_type extent; #if defined(MAPNIK_MEMORY_MAPPED_FILE) mapnik::mapped_region_ptr mapped_region; - boost::optional memory = mapnik::mapped_memory_cache::instance().find(filename, true); - if (!memory) + const auto memory = mapnik::mapped_memory_cache::instance().find(filename, true); + if (!memory.has_value()) { std::clog << "Error : cannot memory map " << filename << std::endl; return std::make_pair(false, extent); diff --git a/utils/ogrindex/ogrindex.cpp b/utils/ogrindex/ogrindex.cpp index 5c955837f..f2c03777a 100644 --- a/utils/ogrindex/ogrindex.cpp +++ b/utils/ogrindex/ogrindex.cpp @@ -212,8 +212,7 @@ int main(int argc, char** argv) catch (...) { - std::clog << "unknown exception..." - << "\n"; + std::clog << "unknown exception..." << "\n"; return -1; } } diff --git a/utils/pgsql2sqlite/main.cpp b/utils/pgsql2sqlite/main.cpp index 9ab101485..f3777bb46 100644 --- a/utils/pgsql2sqlite/main.cpp +++ b/utils/pgsql2sqlite/main.cpp @@ -30,7 +30,6 @@ #include MAPNIK_DISABLE_WARNING_PUSH #include -#include #include MAPNIK_DISABLE_WARNING_POP diff --git a/utils/shapeindex/shapeindex.cpp b/utils/shapeindex/shapeindex.cpp index 6602257e1..394e27881 100644 --- a/utils/shapeindex/shapeindex.cpp +++ b/utils/shapeindex/shapeindex.cpp @@ -27,7 +27,7 @@ #include #include #include -//#include +// #include #include #include "shapefile.hpp" #include "shape_io.hpp" diff --git a/vcpkg.json b/vcpkg.json index 75f7197dc..d2700e792 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -6,7 +6,6 @@ "dependencies": [ "boost-assign", "boost-bimap", - "boost-filesystem", "boost-format", "boost-geometry", "boost-gil",