Skip to content

Commit

Permalink
Use make_unique
Browse files Browse the repository at this point in the history
  • Loading branch information
joto committed Dec 17, 2024
1 parent 113b5b2 commit 8407a62
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion include/osmium/area/problem_reporter_ogr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ namespace osmium {
}

void write_line(const char* problem_type, osmium::object_id_type id1, osmium::object_id_type id2, osmium::Location loc1, osmium::Location loc2) {
auto ogr_linestring = std::unique_ptr<OGRLineString>{new OGRLineString{}};
auto ogr_linestring = std::make_unique<OGRLineString>();
ogr_linestring->addPoint(loc1.lon(), loc1.lat());
ogr_linestring->addPoint(loc2.lon(), loc2.lat());

Expand Down
16 changes: 8 additions & 8 deletions include/osmium/geom/ogr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ namespace osmium {
/* Point */

static point_type make_point(const osmium::geom::Coordinates& xy) {
return point_type{new OGRPoint{xy.x, xy.y}};
return std::make_unique<OGRPoint>(xy.x, xy.y);
}

/* LineString */

void linestring_start() {
m_linestring.reset(new OGRLineString{});
m_linestring = std::make_unique<OGRLineString>();
}

void linestring_add_location(const osmium::geom::Coordinates& xy) {
Expand All @@ -105,7 +105,7 @@ namespace osmium {
/* Polygon */

void polygon_start() {
m_ring.reset(new OGRLinearRing{});
m_ring = std::make_unique<OGRLinearRing>();
}

void polygon_add_location(const osmium::geom::Coordinates& xy) {
Expand All @@ -114,19 +114,19 @@ namespace osmium {
}

polygon_type polygon_finish(size_t /* num_points */) {
auto polygon = std::unique_ptr<OGRPolygon>{new OGRPolygon{}};
auto polygon = std::make_unique<OGRPolygon>();
polygon->addRingDirectly(m_ring.release());
return polygon;
}

/* MultiPolygon */

void multipolygon_start() {
m_multipolygon.reset(new OGRMultiPolygon{});
m_multipolygon = std::make_unique<OGRMultiPolygon>();
}

void multipolygon_polygon_start() {
m_polygon.reset(new OGRPolygon{});
m_polygon = std::make_unique<OGRPolygon>();
}

void multipolygon_polygon_finish() {
Expand All @@ -136,7 +136,7 @@ namespace osmium {
}

void multipolygon_outer_ring_start() {
m_ring.reset(new OGRLinearRing{});
m_ring = std::make_unique<OGRLinearRing>();
}

void multipolygon_outer_ring_finish() {
Expand All @@ -146,7 +146,7 @@ namespace osmium {
}

void multipolygon_inner_ring_start() {
m_ring.reset(new OGRLinearRing{});
m_ring = std::make_unique<OGRLinearRing>();
}

void multipolygon_inner_ring_finish() {
Expand Down
2 changes: 1 addition & 1 deletion include/osmium/io/detail/pbf_output_format.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ namespace osmium {

void add_dense_node(const osmium::Node& node) {
if (!m_dense_nodes) {
m_dense_nodes.reset(new DenseNodes{&m_stringtable, &m_options});
m_dense_nodes = std::make_unique<DenseNodes>(&m_stringtable, &m_options);
}
m_dense_nodes->add_node(node);
++m_count;
Expand Down
16 changes: 8 additions & 8 deletions include/osmium/io/detail/xml_input_format.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ namespace osmium {
});

if (!m_tl_builder) {
m_tl_builder.reset(new osmium::builder::TagListBuilder{builder});
m_tl_builder = std::make_unique<osmium::builder::TagListBuilder>(builder);
}
m_tl_builder->add_tag(k, v);
}
Expand Down Expand Up @@ -391,7 +391,7 @@ namespace osmium {
mark_header_as_done();
if (read_types() & osmium::osm_entity_bits::node) {
maybe_new_buffer(osmium::item_type::node);
m_node_builder.reset(new osmium::builder::NodeBuilder{buffer()});
m_node_builder = std::make_unique<osmium::builder::NodeBuilder>(buffer());
m_node_builder->set_user(init_object(m_node_builder->object(), attrs));
}
return;
Expand All @@ -402,7 +402,7 @@ namespace osmium {
mark_header_as_done();
if (read_types() & osmium::osm_entity_bits::way) {
maybe_new_buffer(osmium::item_type::way);
m_way_builder.reset(new osmium::builder::WayBuilder{buffer()});
m_way_builder = std::make_unique<osmium::builder::WayBuilder>(buffer());
m_way_builder->set_user(init_object(m_way_builder->object(), attrs));
}
return;
Expand All @@ -413,7 +413,7 @@ namespace osmium {
mark_header_as_done();
if (read_types() & osmium::osm_entity_bits::relation) {
maybe_new_buffer(osmium::item_type::relation);
m_relation_builder.reset(new osmium::builder::RelationBuilder{buffer()});
m_relation_builder = std::make_unique<osmium::builder::RelationBuilder>(buffer());
m_relation_builder->set_user(init_object(m_relation_builder->object(), attrs));
}
return;
Expand All @@ -428,7 +428,7 @@ namespace osmium {
mark_header_as_done();
if (read_types() & osmium::osm_entity_bits::changeset) {
maybe_new_buffer(osmium::item_type::changeset);
m_changeset_builder.reset(new osmium::builder::ChangesetBuilder{buffer()});
m_changeset_builder = std::make_unique<osmium::builder::ChangesetBuilder>(buffer());
init_changeset(*m_changeset_builder, attrs);
}
} else if (!std::strcmp(element, "create")) {
Expand Down Expand Up @@ -508,7 +508,7 @@ namespace osmium {
m_tl_builder.reset();

if (!m_wnl_builder) {
m_wnl_builder.reset(new osmium::builder::WayNodeListBuilder{*m_way_builder});
m_wnl_builder = std::make_unique<osmium::builder::WayNodeListBuilder>(*m_way_builder);
}

NodeRef nr;
Expand Down Expand Up @@ -542,7 +542,7 @@ namespace osmium {
m_tl_builder.reset();

if (!m_rml_builder) {
m_rml_builder.reset(new osmium::builder::RelationMemberListBuilder{*m_relation_builder});
m_rml_builder = std::make_unique<osmium::builder::RelationMemberListBuilder>(*m_relation_builder);
}

item_type type = item_type::undefined;
Expand Down Expand Up @@ -591,7 +591,7 @@ namespace osmium {
if (read_types() & osmium::osm_entity_bits::changeset) {
m_tl_builder.reset();
if (!m_changeset_discussion_builder) {
m_changeset_discussion_builder.reset(new osmium::builder::ChangesetDiscussionBuilder{*m_changeset_builder});
m_changeset_discussion_builder = std::make_unique<osmium::builder::ChangesetDiscussionBuilder>(*m_changeset_builder);
}
}
} else if (!std::strcmp(element, "tag")) {
Expand Down

0 comments on commit 8407a62

Please sign in to comment.