From 686c741314232481b91e4e15f5b49efd36cc8c1a Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Thu, 21 Aug 2025 16:15:57 +0200 Subject: [PATCH 1/2] Rename enum ColumType to column_type_t --- src/table.cpp | 8 ++++---- src/table.hpp | 2 +- src/taginfo-impl.hpp | 8 ++++---- src/taginfo.hpp | 6 +++--- tests/test-output-pgsql-style-file.cpp | 28 +++++++++++++------------- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/table.cpp b/src/table.cpp index a3dddfb69..06a3bb676 100644 --- a/src/table.cpp +++ b/src/table.cpp @@ -359,10 +359,10 @@ void table_t::task_wait() // This is legacy code which will be removed anyway. /* Escape data appropriate to the type */ -void table_t::escape_type(std::string const &value, ColumnType flags) +void table_t::escape_type(std::string const &value, column_type_t flags) { switch (flags) { - case ColumnType::INT: { + case column_type_t::INT: { // For integers we take the first number, or the average if it's a-b long long from = 0; long long to = 0; @@ -387,7 +387,7 @@ void table_t::escape_type(std::string const &value, ColumnType flags) } break; } - case ColumnType::REAL: + case column_type_t::REAL: /* try to "repair" real values as follows: * assume "," to be a decimal mark which need to be replaced by "." * like int4 take the first number, or the average if it's a-b @@ -421,7 +421,7 @@ void table_t::escape_type(std::string const &value, ColumnType flags) } break; } - case ColumnType::TEXT: + case column_type_t::TEXT: m_copy.add_column(value); break; } diff --git a/src/table.hpp b/src/table.hpp index 1dcfe1fbf..fbc06290b 100644 --- a/src/table.hpp +++ b/src/table.hpp @@ -66,7 +66,7 @@ class table_t std::vector const &used); void write_hstore_columns(taglist_t const &tags); - void escape_type(std::string const &value, ColumnType flags); + void escape_type(std::string const &value, column_type_t flags); void generate_copy_column_list(); diff --git a/src/taginfo-impl.hpp b/src/taginfo-impl.hpp index 8534e9086..484e5df8a 100644 --- a/src/taginfo-impl.hpp +++ b/src/taginfo-impl.hpp @@ -36,15 +36,15 @@ enum column_flags : unsigned int // NOLINT(performance-enum-size) /* Table columns, representing key= tags */ struct taginfo { - ColumnType column_type() const + column_type_t column_type() const { if (flags & FLAG_INT_TYPE) { - return ColumnType::INT; + return column_type_t::INT; } if (flags & FLAG_REAL_TYPE) { - return ColumnType::REAL; + return column_type_t::REAL; } - return ColumnType::TEXT; + return column_type_t::TEXT; } std::string name; diff --git a/src/taginfo.hpp b/src/taginfo.hpp index 75977541e..2b9b693d6 100644 --- a/src/taginfo.hpp +++ b/src/taginfo.hpp @@ -14,7 +14,7 @@ #include #include -enum class ColumnType : std::uint8_t +enum class column_type_t : std::uint8_t { INT, REAL, @@ -23,13 +23,13 @@ enum class ColumnType : std::uint8_t struct Column { - Column(std::string n, std::string tn, ColumnType t) + Column(std::string n, std::string tn, column_type_t t) : name(std::move(n)), type_name(std::move(tn)), type(t) {} std::string name; std::string type_name; - ColumnType type; + column_type_t type; }; using columns_t = std::vector; diff --git a/tests/test-output-pgsql-style-file.cpp b/tests/test-output-pgsql-style-file.cpp index 268354d89..38eec63d8 100644 --- a/tests/test-output-pgsql-style-file.cpp +++ b/tests/test-output-pgsql-style-file.cpp @@ -66,7 +66,7 @@ TEST_CASE("Parse style file with single node entry") REQUIRE(ex.name == "access"); REQUIRE(ex.type == "text"); REQUIRE(ex.flags == column_flags::FLAG_LINEAR); - REQUIRE(ex.column_type() == ColumnType::TEXT); + REQUIRE(ex.column_type() == column_type_t::TEXT); } TEST_CASE("Parse style file with a few valid entries") @@ -85,12 +85,12 @@ TEST_CASE("Parse style file with a few valid entries") for (auto const &node : nodes) { REQUIRE(node.type == "text"); - REQUIRE(node.column_type() == ColumnType::TEXT); + REQUIRE(node.column_type() == column_type_t::TEXT); } for (auto const &way : ways) { REQUIRE(way.type == "text"); - REQUIRE(way.column_type() == ColumnType::TEXT); + REQUIRE(way.column_type() == column_type_t::TEXT); } REQUIRE(nodes[0].flags == column_flags::FLAG_LINEAR); @@ -123,14 +123,14 @@ TEST_CASE("Parse style file with missing fields") for (auto const &node : nodes) { REQUIRE(node.type == "text"); - REQUIRE(node.column_type() == ColumnType::TEXT); + REQUIRE(node.column_type() == column_type_t::TEXT); } REQUIRE(nodes[0].flags == column_flags::FLAG_LINEAR); REQUIRE(nodes[1].flags == 0); for (auto const &way : ways) { REQUIRE(way.type == "text"); - REQUIRE(way.column_type() == ColumnType::TEXT); + REQUIRE(way.column_type() == column_type_t::TEXT); } REQUIRE(ways[0].flags == column_flags::FLAG_POLYGON); REQUIRE(ways[1].flags == 0); @@ -153,17 +153,17 @@ TEST_CASE("Parse style file with way_area") REQUIRE(nodes[0].type == "text"); REQUIRE(nodes[0].flags == (column_flags::FLAG_POLYGON | column_flags::FLAG_NOCOLUMN)); - REQUIRE(nodes[0].column_type() == ColumnType::TEXT); + REQUIRE(nodes[0].column_type() == column_type_t::TEXT); REQUIRE(ways[0].type == "text"); REQUIRE(ways[0].flags == (column_flags::FLAG_POLYGON | column_flags::FLAG_NOCOLUMN)); - REQUIRE(ways[0].column_type() == ColumnType::TEXT); + REQUIRE(ways[0].column_type() == column_type_t::TEXT); REQUIRE(ways[1].type == "real"); REQUIRE(ways[1].flags == 0); REQUIRE(ways[1].column_type() == - ColumnType::TEXT); // Special case for way_area! + column_type_t::TEXT); // Special case for way_area! } TEST_CASE("Parse style file with different data types") @@ -183,30 +183,30 @@ TEST_CASE("Parse style file with different data types") REQUIRE(nodes[0].name == "name"); REQUIRE(nodes[0].type == "text"); REQUIRE(nodes[0].flags == column_flags::FLAG_LINEAR); - REQUIRE(nodes[0].column_type() == ColumnType::TEXT); + REQUIRE(nodes[0].column_type() == column_type_t::TEXT); REQUIRE(nodes[1].name == "population"); REQUIRE(nodes[1].type == "integer"); REQUIRE(nodes[1].flags == (column_flags::FLAG_POLYGON | column_flags::FLAG_INT_TYPE)); - REQUIRE(nodes[1].column_type() == ColumnType::INT); + REQUIRE(nodes[1].column_type() == column_type_t::INT); REQUIRE(ways[0].name == "name"); REQUIRE(ways[0].type == "text"); REQUIRE(ways[0].flags == column_flags::FLAG_LINEAR); - REQUIRE(ways[0].column_type() == ColumnType::TEXT); + REQUIRE(ways[0].column_type() == column_type_t::TEXT); REQUIRE(ways[1].name == "width"); REQUIRE(ways[1].type == "real"); REQUIRE(ways[1].flags == (column_flags::FLAG_LINEAR | column_flags::FLAG_REAL_TYPE)); - REQUIRE(ways[1].column_type() == ColumnType::REAL); + REQUIRE(ways[1].column_type() == column_type_t::REAL); REQUIRE(ways[2].name == "population"); REQUIRE(ways[2].type == "integer"); REQUIRE(ways[2].flags == (column_flags::FLAG_POLYGON | column_flags::FLAG_INT_TYPE)); - REQUIRE(ways[2].column_type() == ColumnType::INT); + REQUIRE(ways[2].column_type() == column_type_t::INT); } TEST_CASE("Parse style file with invalid data types") @@ -225,5 +225,5 @@ TEST_CASE("Parse style file with invalid data types") REQUIRE(ways[0].name == "highway"); REQUIRE(ways[0].type == "foo"); REQUIRE(ways[0].flags == column_flags::FLAG_LINEAR); - REQUIRE(ways[0].column_type() == ColumnType::TEXT); + REQUIRE(ways[0].column_type() == column_type_t::TEXT); } From b8d1de8057713620ac1cc2e90a5947f33442d0cb Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Thu, 21 Aug 2025 16:42:52 +0200 Subject: [PATCH 2/2] Rename struct Column to column_t --- src/taginfo.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/taginfo.hpp b/src/taginfo.hpp index 2b9b693d6..69d080a6c 100644 --- a/src/taginfo.hpp +++ b/src/taginfo.hpp @@ -21,9 +21,9 @@ enum class column_type_t : std::uint8_t TEXT }; -struct Column +struct column_t { - Column(std::string n, std::string tn, column_type_t t) + column_t(std::string n, std::string tn, column_type_t t) : name(std::move(n)), type_name(std::move(tn)), type(t) {} @@ -32,6 +32,6 @@ struct Column column_type_t type; }; -using columns_t = std::vector; +using columns_t = std::vector; #endif // OSM2PGSQL_TAGINFO_HPP