ctf: use `bt2c::Logger` throughout `src.ctf.fs`, `src.ctf.lttng-live`
[babeltrace.git] / src / plugins / ctf / common / src / bfcr / bfcr.hpp
index 9e3a2dc15357e78c1f0f81f31689727d38a0b2bd..984b695c401d59840f0a5088b67eeb6638e13904 100644 (file)
 
 #include <babeltrace2/babeltrace.h>
 
+#include "cpp-common/vendor/fmt/format.h" /* IWYU pragma: keep */
+
 #include "../metadata/tsdl/ctf-meta.hpp"
 
+namespace bt2c {
+
+class Logger;
+
+} /* namespace bt2c */
+
 /**
  * @file bfcr.h
  *
@@ -61,6 +69,29 @@ enum bt_bfcr_status
     BT_BFCR_STATUS_OK = 0,
 };
 
+inline const char *format_as(bt_bfcr_status status) noexcept
+{
+    switch (status) {
+    case BT_BFCR_STATUS_ENOMEM:
+        return "BT_BFCR_STATUS_ENOMEM";
+
+    case BT_BFCR_STATUS_EOF:
+        return "BT_BFCR_STATUS_EOF";
+
+    case BT_BFCR_STATUS_INVAL:
+        return "BT_BFCR_STATUS_INVAL";
+
+    case BT_BFCR_STATUS_ERROR:
+        return "BT_BFCR_STATUS_ERROR";
+
+    case BT_BFCR_STATUS_OK:
+        return "BT_BFCR_STATUS_OK";
+        break;
+    }
+
+    bt_common_abort();
+}
+
 typedef enum bt_bfcr_status (*bt_bfcr_unsigned_int_cb_func)(uint64_t, struct ctf_field_class *,
                                                             void *);
 
@@ -253,8 +284,7 @@ struct bt_bfcr_cbs
  * @param data         User data (passed to user callback functions)
  * @returns            New binary class reader on success, or \c NULL on error
  */
-struct bt_bfcr *bt_bfcr_create(struct bt_bfcr_cbs cbs, void *data, bt_logging_level log_level,
-                               bt_self_component *self_comp);
+struct bt_bfcr *bt_bfcr_create(struct bt_bfcr_cbs cbs, void *data, const bt2c::Logger& logger);
 
 /**
  * Destroys a CTF binary class reader, freeing all internal resources.
@@ -325,22 +355,4 @@ size_t bt_bfcr_continue(struct bt_bfcr *bfcr, const uint8_t *buf, size_t sz,
 
 void bt_bfcr_set_unsigned_int_cb(struct bt_bfcr *bfcr, bt_bfcr_unsigned_int_cb_func cb);
 
-static inline const char *bt_bfcr_status_string(enum bt_bfcr_status status)
-{
-    switch (status) {
-    case BT_BFCR_STATUS_ENOMEM:
-        return "ENOMEM";
-    case BT_BFCR_STATUS_EOF:
-        return "EOF";
-    case BT_BFCR_STATUS_INVAL:
-        return "INVAL";
-    case BT_BFCR_STATUS_ERROR:
-        return "ERROR";
-    case BT_BFCR_STATUS_OK:
-        return "OK";
-    }
-
-    bt_common_abort();
-}
-
 #endif /* CTF_BFCR_H */
This page took 0.023741 seconds and 4 git commands to generate.