Skip to content

Commit e8ab902

Browse files
authored
Merge pull request #2394 from joto/rename-column-type
Rename enum ColumnType and struct Column
2 parents ff666c8 + b8d1de8 commit e8ab902

File tree

5 files changed

+28
-28
lines changed

5 files changed

+28
-28
lines changed

src/table.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,10 @@ void table_t::task_wait()
359359
// This is legacy code which will be removed anyway.
360360

361361
/* Escape data appropriate to the type */
362-
void table_t::escape_type(std::string const &value, ColumnType flags)
362+
void table_t::escape_type(std::string const &value, column_type_t flags)
363363
{
364364
switch (flags) {
365-
case ColumnType::INT: {
365+
case column_type_t::INT: {
366366
// For integers we take the first number, or the average if it's a-b
367367
long long from = 0;
368368
long long to = 0;
@@ -387,7 +387,7 @@ void table_t::escape_type(std::string const &value, ColumnType flags)
387387
}
388388
break;
389389
}
390-
case ColumnType::REAL:
390+
case column_type_t::REAL:
391391
/* try to "repair" real values as follows:
392392
* assume "," to be a decimal mark which need to be replaced by "."
393393
* 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)
421421
}
422422
break;
423423
}
424-
case ColumnType::TEXT:
424+
case column_type_t::TEXT:
425425
m_copy.add_column(value);
426426
break;
427427
}

src/table.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class table_t
6666
std::vector<bool> const &used);
6767
void write_hstore_columns(taglist_t const &tags);
6868

69-
void escape_type(std::string const &value, ColumnType flags);
69+
void escape_type(std::string const &value, column_type_t flags);
7070

7171
void generate_copy_column_list();
7272

src/taginfo-impl.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ enum column_flags : unsigned int // NOLINT(performance-enum-size)
3636
/* Table columns, representing key= tags */
3737
struct taginfo
3838
{
39-
ColumnType column_type() const
39+
column_type_t column_type() const
4040
{
4141
if (flags & FLAG_INT_TYPE) {
42-
return ColumnType::INT;
42+
return column_type_t::INT;
4343
}
4444
if (flags & FLAG_REAL_TYPE) {
45-
return ColumnType::REAL;
45+
return column_type_t::REAL;
4646
}
47-
return ColumnType::TEXT;
47+
return column_type_t::TEXT;
4848
}
4949

5050
std::string name;

src/taginfo.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,24 @@
1414
#include <string>
1515
#include <vector>
1616

17-
enum class ColumnType : std::uint8_t
17+
enum class column_type_t : std::uint8_t
1818
{
1919
INT,
2020
REAL,
2121
TEXT
2222
};
2323

24-
struct Column
24+
struct column_t
2525
{
26-
Column(std::string n, std::string tn, ColumnType t)
26+
column_t(std::string n, std::string tn, column_type_t t)
2727
: name(std::move(n)), type_name(std::move(tn)), type(t)
2828
{}
2929

3030
std::string name;
3131
std::string type_name;
32-
ColumnType type;
32+
column_type_t type;
3333
};
3434

35-
using columns_t = std::vector<Column>;
35+
using columns_t = std::vector<column_t>;
3636

3737
#endif // OSM2PGSQL_TAGINFO_HPP

tests/test-output-pgsql-style-file.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ TEST_CASE("Parse style file with single node entry")
6666
REQUIRE(ex.name == "access");
6767
REQUIRE(ex.type == "text");
6868
REQUIRE(ex.flags == column_flags::FLAG_LINEAR);
69-
REQUIRE(ex.column_type() == ColumnType::TEXT);
69+
REQUIRE(ex.column_type() == column_type_t::TEXT);
7070
}
7171

7272
TEST_CASE("Parse style file with a few valid entries")
@@ -85,12 +85,12 @@ TEST_CASE("Parse style file with a few valid entries")
8585

8686
for (auto const &node : nodes) {
8787
REQUIRE(node.type == "text");
88-
REQUIRE(node.column_type() == ColumnType::TEXT);
88+
REQUIRE(node.column_type() == column_type_t::TEXT);
8989
}
9090

9191
for (auto const &way : ways) {
9292
REQUIRE(way.type == "text");
93-
REQUIRE(way.column_type() == ColumnType::TEXT);
93+
REQUIRE(way.column_type() == column_type_t::TEXT);
9494
}
9595

9696
REQUIRE(nodes[0].flags == column_flags::FLAG_LINEAR);
@@ -123,14 +123,14 @@ TEST_CASE("Parse style file with missing fields")
123123

124124
for (auto const &node : nodes) {
125125
REQUIRE(node.type == "text");
126-
REQUIRE(node.column_type() == ColumnType::TEXT);
126+
REQUIRE(node.column_type() == column_type_t::TEXT);
127127
}
128128
REQUIRE(nodes[0].flags == column_flags::FLAG_LINEAR);
129129
REQUIRE(nodes[1].flags == 0);
130130

131131
for (auto const &way : ways) {
132132
REQUIRE(way.type == "text");
133-
REQUIRE(way.column_type() == ColumnType::TEXT);
133+
REQUIRE(way.column_type() == column_type_t::TEXT);
134134
}
135135
REQUIRE(ways[0].flags == column_flags::FLAG_POLYGON);
136136
REQUIRE(ways[1].flags == 0);
@@ -153,17 +153,17 @@ TEST_CASE("Parse style file with way_area")
153153
REQUIRE(nodes[0].type == "text");
154154
REQUIRE(nodes[0].flags ==
155155
(column_flags::FLAG_POLYGON | column_flags::FLAG_NOCOLUMN));
156-
REQUIRE(nodes[0].column_type() == ColumnType::TEXT);
156+
REQUIRE(nodes[0].column_type() == column_type_t::TEXT);
157157

158158
REQUIRE(ways[0].type == "text");
159159
REQUIRE(ways[0].flags ==
160160
(column_flags::FLAG_POLYGON | column_flags::FLAG_NOCOLUMN));
161-
REQUIRE(ways[0].column_type() == ColumnType::TEXT);
161+
REQUIRE(ways[0].column_type() == column_type_t::TEXT);
162162

163163
REQUIRE(ways[1].type == "real");
164164
REQUIRE(ways[1].flags == 0);
165165
REQUIRE(ways[1].column_type() ==
166-
ColumnType::TEXT); // Special case for way_area!
166+
column_type_t::TEXT); // Special case for way_area!
167167
}
168168

169169
TEST_CASE("Parse style file with different data types")
@@ -183,30 +183,30 @@ TEST_CASE("Parse style file with different data types")
183183
REQUIRE(nodes[0].name == "name");
184184
REQUIRE(nodes[0].type == "text");
185185
REQUIRE(nodes[0].flags == column_flags::FLAG_LINEAR);
186-
REQUIRE(nodes[0].column_type() == ColumnType::TEXT);
186+
REQUIRE(nodes[0].column_type() == column_type_t::TEXT);
187187

188188
REQUIRE(nodes[1].name == "population");
189189
REQUIRE(nodes[1].type == "integer");
190190
REQUIRE(nodes[1].flags ==
191191
(column_flags::FLAG_POLYGON | column_flags::FLAG_INT_TYPE));
192-
REQUIRE(nodes[1].column_type() == ColumnType::INT);
192+
REQUIRE(nodes[1].column_type() == column_type_t::INT);
193193

194194
REQUIRE(ways[0].name == "name");
195195
REQUIRE(ways[0].type == "text");
196196
REQUIRE(ways[0].flags == column_flags::FLAG_LINEAR);
197-
REQUIRE(ways[0].column_type() == ColumnType::TEXT);
197+
REQUIRE(ways[0].column_type() == column_type_t::TEXT);
198198

199199
REQUIRE(ways[1].name == "width");
200200
REQUIRE(ways[1].type == "real");
201201
REQUIRE(ways[1].flags ==
202202
(column_flags::FLAG_LINEAR | column_flags::FLAG_REAL_TYPE));
203-
REQUIRE(ways[1].column_type() == ColumnType::REAL);
203+
REQUIRE(ways[1].column_type() == column_type_t::REAL);
204204

205205
REQUIRE(ways[2].name == "population");
206206
REQUIRE(ways[2].type == "integer");
207207
REQUIRE(ways[2].flags ==
208208
(column_flags::FLAG_POLYGON | column_flags::FLAG_INT_TYPE));
209-
REQUIRE(ways[2].column_type() == ColumnType::INT);
209+
REQUIRE(ways[2].column_type() == column_type_t::INT);
210210
}
211211

212212
TEST_CASE("Parse style file with invalid data types")
@@ -225,5 +225,5 @@ TEST_CASE("Parse style file with invalid data types")
225225
REQUIRE(ways[0].name == "highway");
226226
REQUIRE(ways[0].type == "foo");
227227
REQUIRE(ways[0].flags == column_flags::FLAG_LINEAR);
228-
REQUIRE(ways[0].column_type() == ColumnType::TEXT);
228+
REQUIRE(ways[0].column_type() == column_type_t::TEXT);
229229
}

0 commit comments

Comments
 (0)