Skip to content

Commit 812ba2f

Browse files
authored
Merge pull request #2336 from joto/enum-refactor
Enum refactorings
2 parents ce415eb + dde38e0 commit 812ba2f

File tree

5 files changed

+35
-35
lines changed

5 files changed

+35
-35
lines changed

src/db-copy.hpp

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "pgsql-params.hpp"
1616

1717
#include <cassert>
18+
#include <cstddef>
1819
#include <condition_variable>
1920
#include <deque>
2021
#include <future>
@@ -74,12 +75,11 @@ class db_target_descr_t
7475
*/
7576
class db_deleter_by_id_t
7677
{
77-
enum
78-
{
79-
// There is a trade-off here between sending as few DELETE SQL as
80-
// possible and keeping the size of the deletable vector managable.
81-
Max_entries = 1000000
82-
};
78+
/**
79+
* There is a trade-off here between sending as few DELETE SQL as
80+
* possible and keeping the size of the deletable vector managable.
81+
*/
82+
static constexpr std::size_t Max_entries = 1000000;
8383

8484
public:
8585
bool has_data() const noexcept { return !m_deletables.empty(); }
@@ -101,12 +101,11 @@ class db_deleter_by_id_t
101101
*/
102102
class db_deleter_by_type_and_id_t
103103
{
104-
enum
105-
{
106-
// There is a trade-off here between sending as few DELETE SQL as
107-
// possible and keeping the size of the deletable vector managable.
108-
Max_entries = 1000000
109-
};
104+
/**
105+
* There is a trade-off here between sending as few DELETE SQL as
106+
* possible and keeping the size of the deletable vector managable.
107+
*/
108+
static constexpr std::size_t Max_entries = 1000000;
110109

111110
struct item_t
112111
{
@@ -140,23 +139,23 @@ class db_deleter_by_type_and_id_t
140139

141140
struct db_cmd_copy_t
142141
{
143-
enum
144-
{
145-
/** Size of a single buffer with COPY data for Postgresql.
146-
* This is a trade-off between memory usage and sending large chunks
147-
* to speed up processing. Currently a one-size fits all value.
148-
* Needs more testing and individual values per queue.
149-
*/
150-
Max_buf_size = 10 * 1024 * 1024,
151-
/** Maximum length of the queue with COPY data.
152-
* In the usual case, PostgreSQL should be faster processing the
153-
* data than it can be produced and there should only be one element
154-
* in the queue. If PostgreSQL is slower, then the queue will always
155-
* be full and it is better to keep the queue smaller to reduce memory
156-
* usage. Current value is just assumed to be a reasonable trade off.
157-
*/
158-
Max_buffers = 10
159-
};
142+
/**
143+
* Size of a single buffer with COPY data for Postgresql.
144+
* This is a trade-off between memory usage and sending large chunks
145+
* to speed up processing. Currently a one-size fits all value.
146+
* Needs more testing and individual values per queue.
147+
*/
148+
static constexpr std::size_t Max_buf_size = 10 * 1024 * 1024;
149+
150+
/**
151+
* Maximum length of the queue with COPY data.
152+
* In the usual case, PostgreSQL should be faster processing the
153+
* data than it can be produced and there should only be one element
154+
* in the queue. If PostgreSQL is slower, then the queue will always
155+
* be full and it is better to keep the queue smaller to reduce memory
156+
* usage. Current value is just assumed to be a reasonable trade off.
157+
*/
158+
static constexpr std::size_t Max_buffers = 10;
160159

161160
/// Name of the target table for the copy operation
162161
std::shared_ptr<db_target_descr_t> target;

src/middle-pgsql.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,18 +235,18 @@ class member_list_json_builder
235235
}
236236

237237
private:
238-
osmium::builder::RelationMemberListBuilder *m_builder;
239238
std::string m_role;
239+
osmium::builder::RelationMemberListBuilder *m_builder;
240240
osmium::object_id_type m_ref = 0;
241241
osmium::item_type m_type = osmium::item_type::undefined;
242-
enum class next_val
242+
enum class next_val : std::uint8_t
243243
{
244244
none,
245245
type,
246246
ref,
247247
role
248248
} m_next_val = next_val::none;
249-
};
249+
}; // class member_list_json_builder
250250

251251
template <typename T>
252252
void pgsql_parse_json_members(char const *string,

src/output-flex.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct options_t;
4040
* When C++ code is called from the Lua code we sometimes need to know
4141
* in what context this happens. These are the possible contexts.
4242
*/
43-
enum class calling_context
43+
enum class calling_context : std::uint8_t
4444
{
4545
main = 0, ///< In main context, i.e. the Lua script outside any callbacks
4646
process_node = 1, ///< In the process_node() callback

src/taginfo.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
* For a full list of authors see the git log.
1111
*/
1212

13+
#include <cstdint>
1314
#include <string>
1415
#include <vector>
1516

16-
enum class ColumnType
17+
enum class ColumnType : std::uint8_t
1718
{
1819
INT,
1920
REAL,

tests/test-output-flex-nodes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ TEST_CASE("add nodes")
5353
CHECK(1 == conn.get_count("osm2pgsql_test_t1", "node_id = 17"));
5454
}
5555

56-
enum class node_relationship
56+
enum class node_relationship : std::uint8_t
5757
{
5858
none,
5959
in_way,

0 commit comments

Comments
 (0)