4633ebca73b03233e1cc2c9ec7e9df120c66d463
[babeltrace.git] / src / cpp-common / bt2c / fmt.hpp
1 /*
2 * Copyright (c) 2024 EfficiOS, inc.
3 *
4 * SPDX-License-Identifier: MIT
5 */
6
7 #include "common/common.h"
8 #include "cpp-common/bt2/message.hpp"
9 #include "cpp-common/vendor/fmt/format.h" /* IWYU pragma: keep */
10 #include "cpp-common/vendor/wise-enum/wise_enum.h"
11
12 #include "uuid.hpp"
13
14 namespace internal {
15
16 template <typename T>
17 using EnableIfIsWiseEnum =
18 typename std::enable_if<wise_enum::is_wise_enum<T>::value, const char *>::type;
19
20 } /* namespace internal */
21
22 namespace bt2 {
23
24 template <typename T>
25 ::internal::EnableIfIsWiseEnum<T> format_as(const T val) noexcept
26 {
27 return wise_enum::to_string<T>(val);
28 }
29
30 inline const char *format_as(const MessageType type)
31 {
32 return bt_common_message_type_string(static_cast<bt_message_type>(type));
33 }
34
35 } /* namespace bt2 */
36
37 namespace bt2c {
38
39 template <typename T>
40 ::internal::EnableIfIsWiseEnum<T> format_as(const T val) noexcept
41 {
42 return wise_enum::to_string<T>(val);
43 }
44
45 inline std::string format_as(const UuidView uuid)
46 {
47 return uuid.str();
48 }
49
50 } /* namespace bt2c */
This page took 0.030753 seconds and 3 git commands to generate.