]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: use fmt/ranges.h for printing ranges 47286/head
authorKefu Chai <tchaikov@gmail.com>
Tue, 26 Jul 2022 16:38:31 +0000 (00:38 +0800)
committerKefu Chai <tchaikov@gmail.com>
Tue, 26 Jul 2022 23:16:11 +0000 (07:16 +0800)
now that fmt/ranges.h provides a generic mechinary for printing
ranges. let's just use it.

the output format is changed a little bit when it comes to
set and map, but as long as it makes sense, and we don't use
a tool to parse the logging messages for extracting information
from the messages printed by fmt::format(), we should be safe.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
src/common/hobject_fmt.h
src/include/types_fmt.h [deleted file]
src/msg/msg_fmt.h
src/osd/osd_types_fmt.h
src/osd/scrubber/pg_scrubber.cc
src/osd/scrubber/scrub_backend.cc
src/test/osd/scrubber_generators.cc
src/test/osd/test_scrubber_be.cc

index e60fc2a14fc0e4e1915a88ef50077de5723e2815..9c33f43446a8ccf4e96e0dfbe315a555d12a6015 100644 (file)
@@ -9,7 +9,6 @@
 
 #include "common/hobject.h"
 #include "include/object_fmt.h"
-#include "include/types_fmt.h"
 #include "msg/msg_fmt.h"
 
 // \todo reimplement
diff --git a/src/include/types_fmt.h b/src/include/types_fmt.h
deleted file mode 100644 (file)
index a3ea24d..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-#pragma once
-/**
- * \file fmtlib formatters for some types.h classes
- */
-
-#include <fmt/format.h>
-
-#include <string_view>
-
-#include "include/types.h"
-
-template <class Key, class T>
-struct fmt::formatter<std::pair<const Key, T>> {
-  constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
-
-  template <typename FormatContext>
-  auto format(const std::pair<const Key, T>& p, FormatContext& ctx)
-  {
-    return fmt::format_to(ctx.out(), "{}={}", p.first, p.second);
-  }
-};
-
-template <class A, class B, class Comp, class Alloc>
-struct fmt::formatter<std::map<A, B, Comp, Alloc>> {
-  constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
-
-  template <typename FormatContext>
-  auto format(const std::map<A, B, Comp, Alloc>& m, FormatContext& ctx)
-  {
-    return fmt::format_to(ctx.out(), "{{{}}}", fmt::join(m, ","));
-  }
-};
-
-template <class... Args>
-struct fmt::formatter<std::list<Args...>> {
-  constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
-
-  template <typename FormatContext>
-  auto format(const std::list<Args...>& l, FormatContext& ctx)
-  {
-    return fmt::format_to(ctx.out(), "{}", fmt::join(l, ","));
-  }
-};
-
-template <class... Args>
-struct fmt::formatter<std::vector<Args...>> {
-  constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
-
-  template <typename FormatContext>
-  auto format(const std::vector<Args...>& v, FormatContext& ctx)
-  {
-    return fmt::format_to(ctx.out(), "[{}]", fmt::join(v, ","));
-  }
-};
-
-template <class... Args>
-struct fmt::formatter<std::set<Args...>> {
-  constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
-
-  template <typename FormatContext>
-  auto format(const std::set<Args...>& s, FormatContext& ctx)
-  {
-    return fmt::format_to(ctx.out(), "{}", fmt::join(s, ","));
-  }
-};
index 5ed4ca997fe51a120f698250fbc5dfcd4bbeec02..41c4c6af89debbf4648c39097a21f0916c6a9cf1 100644 (file)
@@ -8,7 +8,6 @@
 
 #include <fmt/format.h>
 
-#include "include/types_fmt.h"
 #include "msg/msg_types.h"
 
 template <>
index cb54572c8e247e7820044cad83600893e91e1e52..9124ac2020853d91067e51f70d0fe40a2fd1e010 100644 (file)
@@ -6,7 +6,6 @@
  */
 
 #include "common/hobject_fmt.h"
-#include "include/types_fmt.h"
 #include "osd/osd_types.h"
 #include <fmt/chrono.h>
 
@@ -195,23 +194,6 @@ struct fmt::formatter<pg_info_t> {
 
 // snaps and snap-sets
 
-template <typename T, template <typename, typename, typename...> class C>
-struct fmt::formatter<interval_set<T, C>> {
-  constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
-
-  template <typename FormatContext>
-  auto format(const interval_set<T, C>& inter, FormatContext& ctx)
-  {
-    bool first = true;
-    fmt::format_to(ctx.out(), "[");
-    for (const auto& [start, len] : inter) {
-      fmt::format_to(ctx.out(), "{}{}~{}", (first ? "" : ","), start, len);
-      first = false;
-    }
-    return fmt::format_to(ctx.out(), "]");
-  }
-};
-
 template <>
 struct fmt::formatter<SnapSet> {
   template <typename ParseContext>
index f27a9c79a9c416effbd4ea3c68c0b88446cd50a1..557e32e328aeb79f915ddeb49d0b5c79fec6289c 100644 (file)
@@ -7,6 +7,8 @@
 #include <iostream>
 #include <vector>
 
+#include <fmt/ranges.h>
+
 #include "debug.h"
 
 #include "common/errno.h"
index 70b3eed9ed0ad4c2ba7881e225a57aa283ca96ef..478eca12380f9b8efca1a3571a225cc12c66d2f2 100644 (file)
@@ -5,6 +5,8 @@
 
 #include <algorithm>
 
+#include <fmt/ranges.h>
+
 #include "common/debug.h"
 
 #include "include/utime_fmt.h"
index 4e84406c6789a3713963c2c6b6f711bafa9712b4..0f2f371e714b9e87e9ae1d5954f36cc7d4c992d5 100644 (file)
@@ -3,6 +3,8 @@
 
 #include "test/osd/scrubber_generators.h"
 
+#include <fmt/ranges.h>
+
 using namespace ScrubGenerator;
 
 // ref: PGLogTestRebuildMissing()
index d42634020af942368b90dfd6b62b1ff090a8f11e..1c7f0abab655ffd9e41dc3cd1f872468c6d1668a 100644 (file)
@@ -7,6 +7,8 @@
 #include <signal.h>
 #include <stdio.h>
 
+#include <fmt/ranges.h>
+
 #include "common/async/context_pool.h"
 #include "common/ceph_argparse.h"
 #include "global/global_context.h"