sstables: Implement fmt::formatter<sstable_format_types>

Same as in previous patch for another enum-class type.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
Pavel Emelyanov
2023-03-17 12:13:14 +03:00
parent 6b04eb74d6
commit bb59dc2ec1
2 changed files with 9 additions and 1 deletions

View File

@@ -2040,7 +2040,7 @@ sstring sstable::component_basename(const sstring& ks, const sstring& cf, versio
format_types format, sstring component) {
sstring v = fmt::to_string(version);
sstring g = to_sstring(generation);
sstring f = format_string.at(format);
sstring f = fmt::to_string(format);
switch (version) {
case sstable::version_types::ka:
return ks + "-" + cf + "-" + v + "-" + g + "-" + component;

View File

@@ -96,3 +96,11 @@ struct fmt::formatter<sstables::sstable_version_types> : fmt::formatter<std::str
return fmt::format_to(ctx.out(), "{}", sstables::version_string.at(version));
}
};
template <>
struct fmt::formatter<sstables::sstable_format_types> : fmt::formatter<std::string_view> {
template <typename FormatContext>
auto format(const sstables::sstable_format_types& format, FormatContext& ctx) const {
return fmt::format_to(ctx.out(), "{}", sstables::format_string.at(format));
}
};