Commit | Line | Data |
---|---|---|
7cf8258b SM |
1 | /* |
2 | * Copyright (c) 2024 EfficiOS, inc. | |
3 | * | |
4 | * SPDX-License-Identifier: MIT | |
5 | */ | |
6 | ||
7cf8258b | 7 | #include "cpp-common/vendor/fmt/format.h" /* IWYU pragma: keep */ |
91730cec | 8 | #include "cpp-common/vendor/wise-enum/wise_enum.h" |
7cf8258b | 9 | |
8f7f6134 SM |
10 | #include "uuid.hpp" |
11 | ||
91730cec SM |
12 | namespace internal { |
13 | ||
14 | template <typename T> | |
15 | using EnableIfIsWiseEnum = | |
16 | typename std::enable_if<wise_enum::is_wise_enum<T>::value, const char *>::type; | |
17 | ||
18 | } /* namespace internal */ | |
19 | ||
7cf8258b SM |
20 | namespace bt2 { |
21 | ||
91730cec SM |
22 | template <typename T> |
23 | ::internal::EnableIfIsWiseEnum<T> format_as(const T val) noexcept | |
24 | { | |
25 | return wise_enum::to_string<T>(val); | |
26 | } | |
27 | ||
7cf8258b | 28 | } /* namespace bt2 */ |
e05975eb SM |
29 | |
30 | namespace bt2c { | |
31 | ||
91730cec SM |
32 | template <typename T> |
33 | ::internal::EnableIfIsWiseEnum<T> format_as(const T val) noexcept | |
34 | { | |
35 | return wise_enum::to_string<T>(val); | |
36 | } | |
37 | ||
e05975eb SM |
38 | inline std::string format_as(const UuidView uuid) |
39 | { | |
40 | return uuid.str(); | |
41 | } | |
42 | ||
43 | } /* namespace bt2c */ |