occ_command: switch to std::formatter for enums
Commit 48002498740996ce57bce399960b0f6f2ff6d1df switched to std::format
but missed changing the custom formatter from fmt to std::format. Add
std::formatter overrides for the enums.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I59e727c42cf8d91d1841daee64bd4d9e066e5151
diff --git a/occ_command.hpp b/occ_command.hpp
index 58d351a..91fdddc 100644
--- a/occ_command.hpp
+++ b/occ_command.hpp
@@ -60,11 +60,6 @@
MAX_PERF = 0x0C // Maximum Performance
};
-static inline auto format_as(SysPwrMode spm)
-{
- return std::to_underlying(spm);
-}
-
// Only some of the SysPwrModes are currently supported and allowed to be set
#define VALID_POWER_MODE_SETTING(mode) \
((mode == SysPwrMode::STATIC) || (mode == SysPwrMode::POWER_SAVING) || \
@@ -96,11 +91,6 @@
COMM_FAILURE = 0x03
};
-static inline auto format_as(CmdStatus cs)
-{
- return std::to_underlying(cs);
-}
-
/** @brief Trace block of data in hex with log<level:INFO>
*
* @param[in] data - vector containing data to trace
@@ -189,3 +179,21 @@
} // namespace occ
} // namespace open_power
+
+template <>
+struct std::formatter<open_power::occ::SysPwrMode> : formatter<int>
+{
+ auto format(open_power::occ::SysPwrMode f, format_context& ctx) const
+ {
+ return formatter<int>::format(std::to_underlying(f), ctx);
+ }
+};
+
+template <>
+struct std::formatter<open_power::occ::CmdStatus> : formatter<int>
+{
+ auto format(open_power::occ::CmdStatus f, format_context& ctx) const
+ {
+ return formatter<int>::format(std::to_underlying(f), ctx);
+ }
+};