From 7225a667da9eddbdf3944db627d902dbf4ea1c5d Mon Sep 17 00:00:00 2001 From: Paul Norman Date: Sat, 18 Jul 2015 17:17:29 -0700 Subject: [PATCH 1/2] Replace boost::scoped_ptr with std::unique_ptr within osm2pgsql itself --- expire-tiles.cpp | 2 +- id-tracker.hpp | 4 ++-- output-multi.hpp | 7 +++---- output-pgsql.hpp | 4 ++-- table.cpp | 4 ++-- table.hpp | 2 +- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/expire-tiles.cpp b/expire-tiles.cpp index 886267182..38ec7c3ef 100644 --- a/expire-tiles.cpp +++ b/expire-tiles.cpp @@ -496,7 +496,7 @@ int expire_tiles::from_db(table_t* table, osmid_t osm_id) { return -1; //grab the geom for this id - std::shared_ptr wkts = table->get_wkt_reader(osm_id); + std::unique_ptr wkts = table->get_wkt_reader(osm_id); //dirty the stuff const char* wkt = nullptr; diff --git a/id-tracker.hpp b/id-tracker.hpp index 023bbb74d..e5707d4b9 100644 --- a/id-tracker.hpp +++ b/id-tracker.hpp @@ -3,7 +3,7 @@ #include "osmtypes.hpp" #include -#include +#include struct id_tracker : public boost::noncopyable { id_tracker(); @@ -20,7 +20,7 @@ struct id_tracker : public boost::noncopyable { private: struct pimpl; - boost::scoped_ptr impl; + std::unique_ptr impl; }; #endif /* ID_TRACKER_HPP */ diff --git a/output-multi.hpp b/output-multi.hpp index 4f6f0e2d8..aa5c49a3c 100644 --- a/output-multi.hpp +++ b/output-multi.hpp @@ -14,7 +14,6 @@ #include #include #include -#include class table_t; class tagtransform; @@ -73,11 +72,11 @@ class output_multi_t : public output_t { int process_relation(osmid_t id, const memberlist_t &members, const taglist_t &tags, bool exists, bool pending=false); void copy_to_table(osmid_t id, const char *wkt, const taglist_t &tags); - boost::scoped_ptr m_tagtransform; - boost::scoped_ptr m_export_list; + std::unique_ptr m_tagtransform; + std::unique_ptr m_export_list; std::shared_ptr m_processor; const OsmType m_osm_type; - boost::scoped_ptr m_table; + std::unique_ptr m_table; std::shared_ptr ways_pending_tracker, ways_done_tracker, rels_pending_tracker; std::shared_ptr m_expire; way_helper m_way_helper; diff --git a/output-pgsql.hpp b/output-pgsql.hpp index 85c400f34..8963196b3 100644 --- a/output-pgsql.hpp +++ b/output-pgsql.hpp @@ -70,14 +70,14 @@ class output_pgsql_t : public output_t { int pgsql_delete_way_from_output(osmid_t osm_id); int pgsql_delete_relation_from_output(osmid_t osm_id); - boost::scoped_ptr m_tagtransform; + std::unique_ptr m_tagtransform; //enable output of a generated way_area tag to either hstore or its own column int m_enable_way_area; std::vector > m_tables; - boost::scoped_ptr m_export_list; + std::unique_ptr m_export_list; geometry_builder builder; diff --git a/table.cpp b/table.cpp index 8b1564de4..251646a75 100644 --- a/table.cpp +++ b/table.cpp @@ -516,7 +516,7 @@ void table_t::escape_type(const string &value, const string &type, string& dst) escape(value, dst); } -std::shared_ptr table_t::get_wkt_reader(const osmid_t id) +std::unique_ptr table_t::get_wkt_reader(const osmid_t id) { //cant get wkt using the prepared statement without stopping the copy first stop_copy(); @@ -529,7 +529,7 @@ std::shared_ptr table_t::get_wkt_reader(const osmid_t id) //the prepared statement get_wkt will behave differently depending on the sql_conn //each table has its own sql_connection with the get_way referring to the appropriate table PGresult* res = pgsql_execPrepared(sql_conn, "get_wkt", 1, (const char * const *)paramValues, PGRES_TUPLES_OK); - return std::shared_ptr(new wkt_reader(res)); + return std::unique_ptr(new wkt_reader(res)); } table_t::wkt_reader::wkt_reader(PGresult* result):result(result), current(0) diff --git a/table.hpp b/table.hpp index 59788ef92..fd21bbba5 100644 --- a/table.hpp +++ b/table.hpp @@ -52,7 +52,7 @@ class table_t size_t count; size_t current; }; - std::shared_ptr get_wkt_reader(const osmid_t id); + std::unique_ptr get_wkt_reader(const osmid_t id); protected: void connect(); From 8795dde0148e07c01bb78a586e014125d20d1aba Mon Sep 17 00:00:00 2001 From: Paul Norman Date: Sat, 18 Jul 2015 18:10:00 -0700 Subject: [PATCH 2/2] Replace boost::scoped_ptr within tests --- tests/test-hstore-match-only.cpp | 5 ++--- tests/test-middle-flat.cpp | 4 +--- tests/test-middle-pgsql.cpp | 4 +--- tests/test-output-multi-line-storage.cpp | 3 +-- tests/test-output-multi-line.cpp | 5 ++--- tests/test-output-multi-point-multi-table.cpp | 5 ++--- tests/test-output-multi-point.cpp | 5 ++--- tests/test-output-multi-poly-trivial.cpp | 3 +-- tests/test-output-multi-polygon.cpp | 5 ++--- tests/test-output-multi-tags.cpp | 3 +-- tests/test-output-pgsql-tablespace.cpp | 5 ++--- tests/test-output-pgsql-z_order.cpp | 5 ++--- tests/test-output-pgsql.cpp | 21 +++++++++---------- 13 files changed, 29 insertions(+), 44 deletions(-) diff --git a/tests/test-hstore-match-only.cpp b/tests/test-hstore-match-only.cpp index 520998814..59d9038fd 100644 --- a/tests/test-hstore-match-only.cpp +++ b/tests/test-hstore-match-only.cpp @@ -28,7 +28,6 @@ The tags of inteest are specified in hstore-match-only.style #include #include -#include #include #include "tests/common-pg.hpp" @@ -56,7 +55,7 @@ void check_count(pg::conn_ptr &conn, int expected, const std::string &query) { } int main(int argc, char *argv[]) { - boost::scoped_ptr db; + std::unique_ptr db; try { db.reset(new pg::tempdb); @@ -80,7 +79,7 @@ int main(int argc, char *argv[]) { osmdata_t osmdata(mid_pgsql, out_test); - boost::scoped_ptr parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection, false)); + std::unique_ptr parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection, false)); osmdata.start(); diff --git a/tests/test-middle-flat.cpp b/tests/test-middle-flat.cpp index 5e11a59d7..45006d930 100644 --- a/tests/test-middle-flat.cpp +++ b/tests/test-middle-flat.cpp @@ -16,8 +16,6 @@ #include #include -#include - #include "tests/middle-tests.hpp" #include "tests/common-pg.hpp" @@ -73,7 +71,7 @@ void run_tests(options_t options, const std::string cache_type) { }*/ } int main(int argc, char *argv[]) { - boost::scoped_ptr db; + std::unique_ptr db; try { db.reset(new pg::tempdb); diff --git a/tests/test-middle-pgsql.cpp b/tests/test-middle-pgsql.cpp index aebd22f8c..402f5bddb 100644 --- a/tests/test-middle-pgsql.cpp +++ b/tests/test-middle-pgsql.cpp @@ -16,8 +16,6 @@ #include #include -#include - #include "tests/middle-tests.hpp" #include "tests/common-pg.hpp" @@ -64,7 +62,7 @@ void run_tests(options_t options, const std::string cache_type) { } } int main(int argc, char *argv[]) { - boost::scoped_ptr db; + std::unique_ptr db; try { db.reset(new pg::tempdb); diff --git a/tests/test-output-multi-line-storage.cpp b/tests/test-output-multi-line-storage.cpp index 6b4f2e397..d7b26485f 100644 --- a/tests/test-output-multi-line-storage.cpp +++ b/tests/test-output-multi-line-storage.cpp @@ -19,7 +19,6 @@ #include #include -#include #include #include "tests/middle-tests.hpp" @@ -47,7 +46,7 @@ void check_count(pg::conn_ptr &conn, int expected, const std::string &query) { } int main(int argc, char *argv[]) { - boost::scoped_ptr db; + std::unique_ptr db; try { db.reset(new pg::tempdb); diff --git a/tests/test-output-multi-line.cpp b/tests/test-output-multi-line.cpp index 76f0979f7..cff819d41 100644 --- a/tests/test-output-multi-line.cpp +++ b/tests/test-output-multi-line.cpp @@ -19,7 +19,6 @@ #include #include -#include #include #include "tests/middle-tests.hpp" @@ -47,7 +46,7 @@ void check_count(pg::conn_ptr &conn, int expected, const std::string &query) { } int main(int argc, char *argv[]) { - boost::scoped_ptr db; + std::unique_ptr db; try { db.reset(new pg::tempdb); @@ -73,7 +72,7 @@ int main(int argc, char *argv[]) { osmdata_t osmdata(mid_pgsql, out_test); - boost::scoped_ptr parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection, options.append)); + std::unique_ptr parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection, options.append)); osmdata.start(); diff --git a/tests/test-output-multi-point-multi-table.cpp b/tests/test-output-multi-point-multi-table.cpp index 8a8835d82..250205bb7 100644 --- a/tests/test-output-multi-point-multi-table.cpp +++ b/tests/test-output-multi-point-multi-table.cpp @@ -19,7 +19,6 @@ #include #include -#include #include #include "tests/middle-tests.hpp" @@ -52,7 +51,7 @@ void check_count(pg::conn_ptr &conn, int expected, const std::string &query) { } int main(int argc, char *argv[]) { - boost::scoped_ptr db; + std::unique_ptr db; try { db.reset(new pg::tempdb); @@ -88,7 +87,7 @@ int main(int argc, char *argv[]) { osmdata_t osmdata(mid_pgsql, outputs); - boost::scoped_ptr parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection, options.append)); + std::unique_ptr parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection, options.append)); osmdata.start(); diff --git a/tests/test-output-multi-point.cpp b/tests/test-output-multi-point.cpp index dce57431d..110c34f00 100644 --- a/tests/test-output-multi-point.cpp +++ b/tests/test-output-multi-point.cpp @@ -19,7 +19,6 @@ #include #include -#include #include #include "tests/middle-tests.hpp" @@ -47,7 +46,7 @@ void check_count(pg::conn_ptr &conn, int expected, const std::string &query) { } int main(int argc, char *argv[]) { - boost::scoped_ptr db; + std::unique_ptr db; try { db.reset(new pg::tempdb); @@ -74,7 +73,7 @@ int main(int argc, char *argv[]) { osmdata_t osmdata(mid_pgsql, out_test); - boost::scoped_ptr parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection, options.append)); + std::unique_ptr parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection, options.append)); osmdata.start(); diff --git a/tests/test-output-multi-poly-trivial.cpp b/tests/test-output-multi-poly-trivial.cpp index e3d7132d7..168f28578 100644 --- a/tests/test-output-multi-poly-trivial.cpp +++ b/tests/test-output-multi-poly-trivial.cpp @@ -19,7 +19,6 @@ #include #include -#include #include #include "tests/middle-tests.hpp" @@ -110,7 +109,7 @@ void check_output_poly_trivial(bool enable_multi, std::string conninfo) { } int main(int argc, char *argv[]) { - boost::scoped_ptr db; + std::unique_ptr db; try { db.reset(new pg::tempdb); diff --git a/tests/test-output-multi-polygon.cpp b/tests/test-output-multi-polygon.cpp index 7a7cd0acc..b4bb3b863 100644 --- a/tests/test-output-multi-polygon.cpp +++ b/tests/test-output-multi-polygon.cpp @@ -19,7 +19,6 @@ #include #include -#include #include #include "tests/middle-tests.hpp" @@ -47,7 +46,7 @@ void check_count(pg::conn_ptr &conn, int expected, const std::string &query) { } int main(int argc, char *argv[]) { - boost::scoped_ptr db; + std::unique_ptr db; try { db.reset(new pg::tempdb); @@ -73,7 +72,7 @@ int main(int argc, char *argv[]) { osmdata_t osmdata(mid_pgsql, out_test); - boost::scoped_ptr parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection, options.append)); + std::unique_ptr parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection, options.append)); osmdata.start(); diff --git a/tests/test-output-multi-tags.cpp b/tests/test-output-multi-tags.cpp index 82f90d9c0..fc2226d75 100644 --- a/tests/test-output-multi-tags.cpp +++ b/tests/test-output-multi-tags.cpp @@ -19,7 +19,6 @@ #include #include -#include #include #include "tests/middle-tests.hpp" @@ -47,7 +46,7 @@ void check_count(pg::conn_ptr &conn, int expected, const std::string &query) { } int main(int argc, char *argv[]) { - boost::scoped_ptr db; + std::unique_ptr db; try { db.reset(new pg::tempdb); diff --git a/tests/test-output-pgsql-tablespace.cpp b/tests/test-output-pgsql-tablespace.cpp index 242df8d7d..716f0542b 100644 --- a/tests/test-output-pgsql-tablespace.cpp +++ b/tests/test-output-pgsql-tablespace.cpp @@ -20,7 +20,6 @@ #include #include -#include #include #include "tests/middle-tests.hpp" @@ -83,7 +82,7 @@ void assert_has_table(pg::conn_ptr &test_conn, const std::string &table_name) { // the python script. this is just to check everything is // working as expected before we start the complex stuff. void test_regression_simple() { - boost::scoped_ptr db; + std::unique_ptr db; try { db.reset(new pg::tempdb); @@ -111,7 +110,7 @@ void test_regression_simple() { osmdata_t osmdata(mid_pgsql, out_test); - boost::scoped_ptr parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection, options.append)); + std::unique_ptr parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection, options.append)); osmdata.start(); diff --git a/tests/test-output-pgsql-z_order.cpp b/tests/test-output-pgsql-z_order.cpp index deb6dfb65..1bdf3110c 100644 --- a/tests/test-output-pgsql-z_order.cpp +++ b/tests/test-output-pgsql-z_order.cpp @@ -20,7 +20,6 @@ #include #include -#include #include #include "tests/middle-tests.hpp" @@ -104,7 +103,7 @@ void assert_has_table(pg::conn_ptr &test_conn, const std::string &table_name) { // the python script. this is just to check everything is // working as expected before we start the complex stuff. void test_z_order() { - boost::scoped_ptr db; + std::unique_ptr db; try { db.reset(new pg::tempdb); @@ -127,7 +126,7 @@ void test_z_order() { osmdata_t osmdata(mid_pgsql, out_test); - boost::scoped_ptr parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection, false)); + std::unique_ptr parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection, false)); osmdata.start(); diff --git a/tests/test-output-pgsql.cpp b/tests/test-output-pgsql.cpp index fc35257c0..60559101d 100644 --- a/tests/test-output-pgsql.cpp +++ b/tests/test-output-pgsql.cpp @@ -20,7 +20,6 @@ #include #include -#include #include #include "tests/middle-tests.hpp" @@ -104,7 +103,7 @@ void assert_has_table(pg::conn_ptr &test_conn, const std::string &table_name) { // the python script. this is just to check everything is // working as expected before we start the complex stuff. void test_regression_simple() { - boost::scoped_ptr db; + std::unique_ptr db; try { db.reset(new pg::tempdb); @@ -128,7 +127,7 @@ void test_regression_simple() { osmdata_t osmdata(mid_pgsql, out_test); - boost::scoped_ptr parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection, options.append)); + std::unique_ptr parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection, options.append)); osmdata.start(); @@ -164,7 +163,7 @@ void test_regression_simple() { } void test_latlong() { - boost::scoped_ptr db; + std::unique_ptr db; try { db.reset(new pg::tempdb); @@ -191,7 +190,7 @@ void test_latlong() { osmdata_t osmdata(mid_pgsql, out_test); - boost::scoped_ptr parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection, options.append)); + std::unique_ptr parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection, options.append)); osmdata.start(); @@ -228,7 +227,7 @@ void test_latlong() { void test_area_way_simple() { - boost::scoped_ptr db; + std::unique_ptr db; try { db.reset(new pg::tempdb); @@ -254,7 +253,7 @@ void test_area_way_simple() { osmdata_t osmdata(mid_pgsql, out_test); - boost::scoped_ptr parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection, options.append)); + std::unique_ptr parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection, options.append)); osmdata.start(); @@ -279,7 +278,7 @@ void test_area_way_simple() { } void test_route_rel() { - boost::scoped_ptr db; + std::unique_ptr db; try { db.reset(new pg::tempdb); @@ -303,7 +302,7 @@ void test_route_rel() { osmdata_t osmdata(mid_ram, out_test); - boost::scoped_ptr parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection, options.append)); + std::unique_ptr parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection, options.append)); osmdata.start(); @@ -330,7 +329,7 @@ void test_route_rel() { // test the same, but clone the output. it should // behave the same as the original. void test_clone() { - boost::scoped_ptr db; + std::unique_ptr db; try { db.reset(new pg::tempdb); @@ -358,7 +357,7 @@ void test_clone() { osmdata_t osmdata(mid_pgsql, out_clone); - boost::scoped_ptr parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection, options.append)); + std::unique_ptr parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection, options.append)); osmdata.start();