Skip to content

Commit 2d58f86

Browse files
committed
build: make use of C++20 using enum
1 parent 03b47d7 commit 2d58f86

File tree

6 files changed

+86
-77
lines changed

6 files changed

+86
-77
lines changed

exch/emsmdb/notify.cpp

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -373,64 +373,66 @@ ec_error_t notify_response::cvt_from_dbnotify(BOOL b_cache, const DB_NOTIFY &dbn
373373
auto &n = *this;
374374

375375
switch (dbn.type) {
376-
case db_notify_type::new_mail:
376+
using enum db_notify_type;
377+
case new_mail:
377378
return cvt_new_mail(n, *static_cast<const DB_NOTIFY_NEW_MAIL *>(dbn.pdata), b_cache);
378-
case db_notify_type::folder_created:
379+
case folder_created:
379380
return cvt_fld_created(n, *static_cast<const DB_NOTIFY_FOLDER_CREATED *>(dbn.pdata));
380-
case db_notify_type::message_created:
381+
case message_created:
381382
return cvt_msg_created(n, *static_cast<const DB_NOTIFY_MESSAGE_CREATED *>(dbn.pdata));
382-
case db_notify_type::link_created:
383+
case link_created:
383384
return cvt_link_created(n, *static_cast<const DB_NOTIFY_LINK_CREATED *>(dbn.pdata));
384-
case db_notify_type::folder_deleted:
385+
case folder_deleted:
385386
return cvt_fld_deleted(n, *static_cast<const DB_NOTIFY_FOLDER_DELETED *>(dbn.pdata));
386-
case db_notify_type::message_deleted:
387+
case message_deleted:
387388
return cvt_msg_deleted(n, *static_cast<const DB_NOTIFY_MESSAGE_DELETED *>(dbn.pdata));
388-
case db_notify_type::link_deleted:
389+
case link_deleted:
389390
return cvt_link_deleted(n, *static_cast<const DB_NOTIFY_LINK_DELETED *>(dbn.pdata));
390-
case db_notify_type::folder_modified:
391+
case folder_modified:
391392
return cvt_fld_modified(n, *static_cast<const DB_NOTIFY_FOLDER_MODIFIED *>(dbn.pdata));
392-
case db_notify_type::message_modified:
393+
case message_modified:
393394
return cvt_msg_modified(n, *static_cast<const DB_NOTIFY_MESSAGE_MODIFIED *>(dbn.pdata));
394-
case db_notify_type::folder_moved:
395-
case db_notify_type::folder_copied: {
396-
auto nf = dbn.type == db_notify_type::folder_moved ?
395+
case folder_moved:
396+
case folder_copied: {
397+
auto nf = dbn.type == folder_moved ?
397398
NF_OBJECT_MOVED : NF_OBJECT_COPIED;
398399
return cvt_fld_mvcp(n, nf, *static_cast<const DB_NOTIFY_FOLDER_MVCP *>(dbn.pdata));
399400
}
400-
case db_notify_type::message_moved:
401-
case db_notify_type::message_copied: {
402-
auto nf = dbn.type == db_notify_type::message_moved ?
401+
case message_moved:
402+
case message_copied: {
403+
auto nf = dbn.type == message_moved ?
403404
NF_OBJECT_MOVED : NF_OBJECT_COPIED;
404405
return cvt_msg_mvcp(n, nf, *static_cast<const DB_NOTIFY_MESSAGE_MVCP *>(dbn.pdata));
405406
}
406-
case db_notify_type::search_completed:
407+
case search_completed:
407408
return cvt_fld_search_completed(n, *static_cast<const DB_NOTIFY_SEARCH_COMPLETED *>(dbn.pdata));
408-
case db_notify_type::hiertbl_changed:
409+
case hiertbl_changed:
409410
return cvt_hiertbl_changed(n);
410-
case db_notify_type::cttbl_changed:
411+
case cttbl_changed:
411412
return cvt_cttbl_changed(n);
412-
case db_notify_type::srchtbl_changed:
413+
case srchtbl_changed:
413414
return cvt_srchtbl_changed(n);
414-
case db_notify_type::hiertbl_row_added:
415+
case hiertbl_row_added:
415416
return cvt_hierrow_added(n, *static_cast<const DB_NOTIFY_HIERARCHY_TABLE_ROW_ADDED *>(dbn.pdata));
416-
case db_notify_type::cttbl_row_added:
417+
case cttbl_row_added:
417418
return cvt_ctrow_added(n, *static_cast<const DB_NOTIFY_CONTENT_TABLE_ROW_ADDED *>(dbn.pdata));
418-
case db_notify_type::srchtbl_row_added:
419+
case srchtbl_row_added:
419420
return cvt_srchrow_added(n, *static_cast<const DB_NOTIFY_CONTENT_TABLE_ROW_ADDED *>(dbn.pdata));
420-
case db_notify_type::hiertbl_row_deleted:
421+
case hiertbl_row_deleted:
421422
return cvt_hierrow_deleted(n, *static_cast<const DB_NOTIFY_HIERARCHY_TABLE_ROW_DELETED *>(dbn.pdata));
422-
case db_notify_type::cttbl_row_deleted:
423+
case cttbl_row_deleted:
423424
return cvt_ctrow_deleted(n, *static_cast<const DB_NOTIFY_CONTENT_TABLE_ROW_DELETED *>(dbn.pdata));
424-
case db_notify_type::srchtbl_row_deleted:
425+
case srchtbl_row_deleted:
425426
return cvt_srchrow_deleted(n, *static_cast<const DB_NOTIFY_CONTENT_TABLE_ROW_DELETED *>(dbn.pdata));
426-
case db_notify_type::hiertbl_row_modified:
427+
case hiertbl_row_modified:
427428
return cvt_hierrow_modified(n, *static_cast<const DB_NOTIFY_HIERARCHY_TABLE_ROW_MODIFIED *>(dbn.pdata));
428-
case db_notify_type::cttbl_row_modified:
429+
case cttbl_row_modified:
429430
return cvt_ctrow_modified(n, *static_cast<const DB_NOTIFY_CONTENT_TABLE_ROW_MODIFIED *>(dbn.pdata));
430-
case db_notify_type::srchtbl_row_modified:
431+
case srchtbl_row_modified:
431432
return cvt_srchrow_modified(n, *static_cast<const DB_NOTIFY_CONTENT_TABLE_ROW_MODIFIED *>(dbn.pdata));
433+
default:
434+
return ecInvalidParam;
432435
}
433-
return ecInvalidParam;
434436
}
435437

436438
void notify_response::ctrow_event_to_change()

exch/emsmdb/oxcprpt.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ ec_error_t rop_getpropertyidsfromnames(uint8_t flags,
3939
if (rop_processor_get_object(plogmap, logon_id, hin, &object_type) == nullptr)
4040
return ecNullObject;
4141
switch (object_type) {
42-
case ems_objtype::logon:
43-
case ems_objtype::folder:
44-
case ems_objtype::message:
45-
case ems_objtype::attach:
42+
using enum ems_objtype;
43+
case logon:
44+
case folder:
45+
case message:
46+
case attach:
4647
break;
4748
default:
4849
return ecNotSupported;

exch/http/http_parser.cpp

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,11 @@ static void httpctx_report(const HTTP_CONTEXT &ctx, size_t i)
140140
cn.client_ip, cn.client_port, cn.server_ip, cn.server_port);
141141
const char *chtyp = "NONE";
142142
switch (ctx.channel_type) {
143-
case hchannel_type::none: chtyp = "NONE"; break;
144-
case hchannel_type::in: chtyp = "IN"; break;
145-
case hchannel_type::out: chtyp = "OUT"; break;
146-
default: chtyp = "?"; break;
143+
using enum hchannel_type;
144+
case none: chtyp = "NONE"; break;
145+
case in: chtyp = "IN"; break;
146+
case out: chtyp = "OUT"; break;
147+
default: chtyp = "?"; break;
147148
}
148149
mlog(LV_INFO, " %4s [%s]:%hu %s",
149150
chtyp, ctx.host, ctx.port, ctx.username);
@@ -401,21 +402,22 @@ static int http_parser_reconstruct_stream(STREAM &stream_src)
401402
static const char *status_text(http_status s)
402403
{
403404
switch (s) {
404-
case http_status::not_modified: return "Not Modified";
405-
case http_status::bad_request: return "Bad Request";
406-
case http_status::unauthorized: return "Unauthorized";
407-
case http_status::forbidden: return "Forbidden";
408-
case http_status::not_found: return "Not Found";
409-
case http_status::method_not_allowed: return "Method Not Allowed";
410-
case http_status::timeout: return "Request Timeout";
411-
case http_status::uri_too_long: return "URI Too Long";
412-
case http_status::range_insatisfiable: return "Range Not Satisfiable";
413-
case http_status::too_many_ranges: return "Too Many Ranges";
414-
case http_status::not_impl: return "Not Implemented";
415-
case http_status::bad_gateway: return "Bad FCGI Gateway";
416-
case http_status::service_unavailable: return "Service Unavailable";
417-
case http_status::resources_exhausted: return "Resources Exhausted";
418-
case http_status::gateway_timeout: return "Gateway Timeout";
405+
using enum http_status;
406+
case not_modified: return "Not Modified";
407+
case bad_request: return "Bad Request";
408+
case unauthorized: return "Unauthorized";
409+
case forbidden: return "Forbidden";
410+
case not_found: return "Not Found";
411+
case method_not_allowed: return "Method Not Allowed";
412+
case timeout: return "Request Timeout";
413+
case uri_too_long: return "URI Too Long";
414+
case range_insatisfiable: return "Range Not Satisfiable";
415+
case too_many_ranges: return "Too Many Ranges";
416+
case not_impl: return "Not Implemented";
417+
case bad_gateway: return "Bad FCGI Gateway";
418+
case service_unavailable: return "Service Unavailable";
419+
case resources_exhausted: return "Resources Exhausted";
420+
case gateway_timeout: return "Gateway Timeout";
419421
default: return "Server Error";
420422
}
421423
}

exch/nsp/ab_tree.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,14 +1187,15 @@ static void ab_tree_dump_node(const tree_node *tnode, unsigned int lvl)
11871187
auto &a = *containerof(tnode, NSAB_NODE, stree);
11881188
const char *ty;
11891189
switch (a.node_type) {
1190-
case abnode_type::remote: ty = "remote"; break;
1191-
case abnode_type::user: ty = "user"; break;
1192-
case abnode_type::mlist: ty = "mlist"; break;
1193-
case abnode_type::folder: ty = "folder"; break;
1194-
case abnode_type::domain: ty = "domain"; break;
1195-
case abnode_type::group: ty = "group"; break;
1196-
case abnode_type::abclass: ty = "abclass"; break;
1197-
default: ty = "?"; break;
1190+
using enum abnode_type;
1191+
case remote: ty = "remote"; break;
1192+
case user: ty = "user"; break;
1193+
case mlist: ty = "mlist"; break;
1194+
case folder: ty = "folder"; break;
1195+
case domain: ty = "domain"; break;
1196+
case group: ty = "group"; break;
1197+
case abclass: ty = "abclass"; break;
1198+
default: ty = "?"; break;
11981199
}
11991200
fprintf(stderr, "%-*sminid %xh, nodeid %d, type %s",
12001201
4 * lvl, "", a.minid, a.id, ty);

exch/zcore/zserver.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3865,10 +3865,11 @@ ec_error_t zs_getnamedpropids(GUID hsession, uint32_t hstore,
38653865
return ecNullObject;
38663866
store_object *pstore = nullptr;
38673867
switch (mapi_type) {
3868-
case zs_objtype::store: pstore = static_cast<store_object *>(obj); break;
3869-
case zs_objtype::folder: pstore = static_cast<folder_object *>(obj)->pstore; break;
3870-
case zs_objtype::message: pstore = static_cast<message_object *>(obj)->get_store(); break;
3871-
case zs_objtype::attach: pstore = static_cast<attachment_object *>(obj)->get_store(); break;
3868+
using enum zs_objtype;
3869+
case store: pstore = static_cast<store_object *>(obj); break;
3870+
case folder: pstore = static_cast<folder_object *>(obj)->pstore; break;
3871+
case message: pstore = static_cast<message_object *>(obj)->get_store(); break;
3872+
case attach: pstore = static_cast<attachment_object *>(obj)->get_store(); break;
38723873
default: break;
38733874
}
38743875
if (pstore == nullptr)
@@ -3889,10 +3890,11 @@ ec_error_t zs_getpropnames(GUID hsession, uint32_t hstore,
38893890
return ecNullObject;
38903891
store_object *pstore = nullptr;
38913892
switch (mapi_type) {
3892-
case zs_objtype::store: pstore = static_cast<store_object *>(obj); break;
3893-
case zs_objtype::folder: pstore = static_cast<folder_object *>(obj)->pstore; break;
3894-
case zs_objtype::message: pstore = static_cast<message_object *>(obj)->get_store(); break;
3895-
case zs_objtype::attach: pstore = static_cast<attachment_object *>(obj)->get_store(); break;
3893+
using enum zs_objtype;
3894+
case store: pstore = static_cast<store_object *>(obj); break;
3895+
case folder: pstore = static_cast<folder_object *>(obj)->pstore; break;
3896+
case message: pstore = static_cast<message_object *>(obj)->get_store(); break;
3897+
case attach: pstore = static_cast<attachment_object *>(obj)->get_store(); break;
38963898
default: break;
38973899
}
38983900
if (pstore == nullptr)

lib/exmdb_ext.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4238,15 +4238,16 @@ pack_result exmdb_ext_push_db_notify(const DB_NOTIFY_DATAGRAM *pnotify,
42384238
const char *exmdb_rpc_strerror(exmdb_response v)
42394239
{
42404240
switch (v) {
4241-
case exmdb_response::access_deny: return "Access denied";
4242-
case exmdb_response::max_reached: return "Server reached maximum number of connections";
4243-
case exmdb_response::lack_memory: return "Out of memory";
4244-
case exmdb_response::misconfig_prefix: return "Prefix is not served";
4245-
case exmdb_response::misconfig_mode: return "Prefix has type mismatch";
4246-
case exmdb_response::connect_incomplete: return "No prior CONNECT RPC made";
4247-
case exmdb_response::pull_error: return "Invalid request/Server-side deserializing error";
4248-
case exmdb_response::dispatch_error: return "Dispatch error/Request rejected/DB error (check gromox-http log)";
4249-
case exmdb_response::push_error: return "Server-side serialize error";
4241+
using enum exmdb_response;
4242+
case access_deny: return "Access denied";
4243+
case max_reached: return "Server reached maximum number of connections";
4244+
case lack_memory: return "Out of memory";
4245+
case misconfig_prefix: return "Prefix is not served";
4246+
case misconfig_mode: return "Prefix has type mismatch";
4247+
case connect_incomplete: return "No prior CONNECT RPC made";
4248+
case pull_error: return "Invalid request/Server-side deserializing error";
4249+
case dispatch_error: return "Dispatch error/Request rejected/DB error (check gromox-http log)";
4250+
case push_error: return "Server-side serialize error";
42504251
default: break;
42514252
}
42524253
thread_local char xbuf[32];

0 commit comments

Comments
 (0)