Use Q_ENUM_NS to pretty print csync enums
authorHannah von Reth <hannah.vonreth@owncloud.com>
Tue, 3 Mar 2020 15:43:02 +0000 (16:43 +0100)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:59:07 +0000 (10:59 +0100)
src/csync/csync.h
src/csync/csync_util.cpp

index cc9e1c1a6ec037ed19cbd9d029d6a5be9a5458bc..0d2cc9505662d6907455e943acec0fc2cfd8f547 100644 (file)
@@ -59,7 +59,10 @@ class SyncJournalFileRecord;
 #define BITFIELD(size) :size
 #endif
 
-enum CSYNC_STATUS {
+namespace CSyncEnums {
+OCSYNC_EXPORT Q_NAMESPACE
+
+enum csync_status_codes_e {
   CSYNC_STATUS_OK         = 0,
 
   CSYNC_STATUS_ERROR      = 1024, /* don't use this code,
@@ -94,17 +97,7 @@ enum CSYNC_STATUS {
     CSYNC_STATUS_INDIVIDUAL_IS_CONFLICT_FILE,
     CSYNC_STATUS_INDIVIDUAL_CANNOT_ENCODE
 };
-
-#ifndef likely
-# define likely(x) (x)
-#endif
-#ifndef unlikely
-# define unlikely(x) (x)
-#endif
-
-#define CSYNC_STATUS_IS_OK(x) (likely((x) == CSYNC_STATUS_OK))
-#define CSYNC_STATUS_IS_ERR(x) (unlikely((x) >= CSYNC_STATUS_ERROR))
-#define CSYNC_STATUS_IS_EQUAL(x, y) ((x) == (y))
+Q_ENUM_NS(csync_status_codes_e)
 
 /**
   * Instruction enum. In the file traversal structure, it describes
@@ -129,6 +122,8 @@ enum csync_instructions_e {
                                                       but without any propagation (UPDATE|RECONCILE) */
 };
 
+Q_ENUM_NS(csync_instructions_e)
+
 // This enum is used with BITFIELD(3) and BITFIELD(4) in several places.
 // Also, this value is stored in the database, so beware of value changes.
 enum ItemType {
@@ -165,7 +160,22 @@ enum ItemType {
      */
     ItemTypeVirtualFileDehydration = 6,
 };
+Q_ENUM_NS(ItemType)
+}
+
+using namespace CSyncEnums;
+using CSYNC_STATUS = CSyncEnums::csync_status_codes_e;
+
+#ifndef likely
+#define likely(x) (x)
+#endif
+#ifndef unlikely
+#define unlikely(x) (x)
+#endif
 
+#define CSYNC_STATUS_IS_OK(x) (likely((x) == CSYNC_STATUS_OK))
+#define CSYNC_STATUS_IS_ERR(x) (unlikely((x) >= CSYNC_STATUS_ERROR))
+#define CSYNC_STATUS_IS_EQUAL(x, y) ((x) == (y))
 
 #define FILE_ID_BUF_SIZE 36
 
index 696aa41fef4c4a154e83de73073fc06de863eb29..fd946bd891018976450cf446338a3b91ad73edc2 100644 (file)
@@ -198,3 +198,5 @@ bool csync_is_collision_safe_hash(const QByteArray &checksum_header)
     return checksum_header.startsWith("SHA")
         || checksum_header.startsWith("MD5:");
 }
+
+#include "moc_csync.cpp"