.gitignore: add some more IDE / tools related file
[babeltrace.git] / src / cpp-common / bt2c / fmt.hpp
index 8af3d71e49ca84f0205fb6f20e112ea84e5a5aed..f29a77a209484827ef0002c3e43494712e909e95 100644 (file)
@@ -4,25 +4,45 @@
  * SPDX-License-Identifier: MIT
  */
 
  * SPDX-License-Identifier: MIT
  */
 
-#include "common/common.h"
-#include "cpp-common/bt2/message.hpp"
-#include "cpp-common/bt2c/uuid.hpp"
+#ifndef BABELTRACE_CPP_COMMON_BT2C_FMT_HPP
+#define BABELTRACE_CPP_COMMON_BT2C_FMT_HPP
+
 #include "cpp-common/vendor/fmt/format.h" /* IWYU pragma: keep */
 #include "cpp-common/vendor/fmt/format.h" /* IWYU pragma: keep */
+#include "cpp-common/vendor/wise-enum/wise_enum.h"
+
+#include "uuid.hpp"
+
+namespace internal {
+
+template <typename T>
+using EnableIfIsWiseEnum =
+    typename std::enable_if<wise_enum::is_wise_enum<T>::value, wise_enum::string_type>::type;
+
+} /* namespace internal */
 
 namespace bt2 {
 
 
 namespace bt2 {
 
-inline const char *format_as(const MessageType type)
+template <typename T>
+::internal::EnableIfIsWiseEnum<T> format_as(const T val) noexcept
 {
 {
-    return bt_common_message_type_string(static_cast<bt_message_type>(type));
+    return wise_enum::to_string<T>(val);
 }
 
 } /* namespace bt2 */
 
 namespace bt2c {
 
 }
 
 } /* namespace bt2 */
 
 namespace bt2c {
 
+template <typename T>
+::internal::EnableIfIsWiseEnum<T> format_as(const T val) noexcept
+{
+    return wise_enum::to_string<T>(val);
+}
+
 inline std::string format_as(const UuidView uuid)
 {
     return uuid.str();
 }
 
 } /* namespace bt2c */
 inline std::string format_as(const UuidView uuid)
 {
     return uuid.str();
 }
 
 } /* namespace bt2c */
+
+#endif /* BABELTRACE_CPP_COMMON_BT2C_FMT_HPP */
This page took 0.027023 seconds and 4 git commands to generate.