]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
*: specialize fmt::formatter<> for formatting using {fmt} 49001/head
authorKefu Chai <tchaikov@gmail.com>
Tue, 22 Nov 2022 04:26:19 +0000 (12:26 +0800)
committerKefu Chai <tchaikov@gmail.com>
Tue, 22 Nov 2022 12:41:17 +0000 (20:41 +0800)
in {fmt} v9, fmt::formatter<> is not defined automatically for
the types with operator<<, we need to define them explictly. so in this
change, the types printed using `fmt::print()` or `fmt::format()` are
equiped with fmt::formatter<> to appease {fmt} v9.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
src/common/ceph_time.h
src/common/hobject.h
src/common/snap_types.h
src/crush/CrushLocation.h
src/include/types.h
src/include/uuid.h
src/msg/Message.h
src/msg/msg_types.h
src/osd/osd_types.h
src/osd/osd_types_fmt.h
src/osd/recovery_types.h

index 9204802927407eb05b8e06c41e925baa933b4eba..22429fa282a85b63c9ac10845567103f5efd1fc4 100644 (file)
@@ -533,4 +533,9 @@ template<typename Rep, typename Period>
 ostream& operator<<(ostream& m, const chrono::duration<Rep, Period>& t);
 }
 
+#if FMT_VERSION >= 90000
+template<typename Clock>
+struct fmt::formatter<std::chrono::time_point<Clock>> : fmt::ostream_formatter {};
+#endif
+
 #endif // COMMON_CEPH_TIME_H
index 28f314d7935e426a9f04540816b83690eb4c3fa9..34191ccf5ec88b86a661f12073642cdb5190d613 100644 (file)
 #ifndef __CEPH_OS_HOBJECT_H
 #define __CEPH_OS_HOBJECT_H
 
+#if FMT_VERSION >= 90000
+#include <fmt/ostream.h>
+#endif
+
 #include "include/types.h"
 
 #include "json_spirit/json_spirit_value.h"
@@ -501,6 +505,10 @@ namespace std {
 
 std::ostream& operator<<(std::ostream& out, const ghobject_t& o);
 
+#if FMT_VERSION >= 90000
+template <> struct fmt::formatter<ghobject_t> : fmt::ostream_formatter {};
+#endif
+
 extern int cmp(const ghobject_t& l, const ghobject_t& r);
 
 
index 1705f8834cd2c469acf56f979d41d2415a7dd38a..70b72f10563d3af6ba0551bb9a35fa528d8a3e0d 100644 (file)
@@ -74,4 +74,8 @@ inline std::ostream& operator<<(std::ostream& out, const SnapContext& snapc) {
   return out << snapc.seq << "=" << snapc.snaps;
 }
 
+#if FMT_VERSION >= 90000
+template <> struct fmt::formatter<SnapContext> : fmt::ostream_formatter {};
+#endif
+
 #endif
index 678135c2e42aa1bdfa0ef0fbf5a82cf44aad18fa..24f43068d6171761521284da8e431b90df0e8cd3 100644 (file)
@@ -35,3 +35,7 @@ private:
 std::ostream& operator<<(std::ostream& os, const CrushLocation& loc);
 }
 #endif
+
+#if FMT_VERSION >= 90000
+template <> struct fmt::formatter<TOPNSPC::crush::CrushLocation> : fmt::ostream_formatter {};
+#endif
index e62ef446cb1b236daf5052d9cdb48cf598433e26..12a0b2a6dbff85815aeafd6fd753a3bdc811a9a4 100644 (file)
@@ -611,6 +611,10 @@ inline std::ostream &operator<<(std::ostream &out, const sha_digest_t<S> &b) {
   return out << str;
 }
 
+#if FMT_VERSION >= 90000
+template <uint8_t S> struct fmt::formatter<sha_digest_t<S>> : fmt::ostream_formatter {};
+#endif
+
 using sha1_digest_t = sha_digest_t<20>;
 WRITE_CLASS_ENCODER(sha1_digest_t)
 
index ac4098a16af2c698da24dd89f19710928c5cb508..6a30aa621c443e6d7ff256802c911d98ddff5332 100644 (file)
@@ -96,5 +96,8 @@ inline bool operator>(const uuid_d& l, const uuid_d& r) {
   return l.to_string() > r.to_string();
 }
 
+#if FMT_VERSION >= 90000
+template <> struct fmt::formatter<uuid_d> : fmt::ostream_formatter {};
+#endif
 
 #endif
index f6d34d8002cee8539a0896542641931a932c2f03..3a18c82a28062f9498abd214adcdb7732da9ff0d 100644 (file)
@@ -15,6 +15,7 @@
 #ifndef CEPH_MESSAGE_H
 #define CEPH_MESSAGE_H
 
+#include <concepts>
 #include <cstdlib>
 #include <ostream>
 #include <string_view>
@@ -570,4 +571,9 @@ MURef<T> make_message(Args&&... args) {
   return {new T(std::forward<Args>(args)...), TOPNSPC::common::UniquePtrDeleter{}};
 }
 }
+
+#if FMT_VERSION >= 90000
+template <std::derived_from<Message> M> struct fmt::formatter<M> : fmt::ostream_formatter {};
+#endif
+
 #endif
index a33545d916f3d51ed13592082bc72bea8b897d32..65cfee514bbab01b73c6ff7089125754ab4f1865 100644 (file)
@@ -18,6 +18,9 @@
 #include <sstream>
 
 #include <netinet/in.h>
+#if FMT_VERSION >= 90000
+#include <fmt/ostream.h>
+#endif
 
 #include "include/ceph_features.h"
 #include "include/types.h"
@@ -547,6 +550,9 @@ struct entity_addr_t {
 WRITE_CLASS_ENCODER_FEATURES(entity_addr_t)
 
 std::ostream& operator<<(std::ostream& out, const entity_addr_t &addr);
+#if FMT_VERSION >= 90000
+template <> struct fmt::formatter<entity_addr_t> : fmt::ostream_formatter {};
+#endif
 
 inline bool operator==(const entity_addr_t& a, const entity_addr_t& b) { return memcmp(&a, &b, sizeof(a)) == 0; }
 inline bool operator!=(const entity_addr_t& a, const entity_addr_t& b) { return memcmp(&a, &b, sizeof(a)) != 0; }
@@ -735,6 +741,9 @@ struct entity_addrvec_t {
   }
 };
 WRITE_CLASS_ENCODER_FEATURES(entity_addrvec_t);
+#if FMT_VERSION >= 90000
+template <> struct fmt::formatter<entity_addrvec_t> : fmt::ostream_formatter {};
+#endif
 
 namespace std {
 template<> struct hash<entity_addrvec_t> {
index f4a585362fa6c32dc70cc782526a1e72f031ada5..48a5c6401fc647c0937dd0d3e8692c9079cf6f71 100644 (file)
@@ -785,6 +785,10 @@ inline std::ostream& operator<<(std::ostream& out, const coll_t& c) {
   return out;
 }
 
+#if FMT_VERSION >= 90000
+template <> struct fmt::formatter<coll_t> : fmt::ostream_formatter {};
+#endif
+
 namespace std {
   template<> struct hash<coll_t> {
     size_t operator()(const coll_t &c) const { 
@@ -4711,6 +4715,9 @@ struct pg_missing_item {
 };
 WRITE_CLASS_ENCODER_FEATURES(pg_missing_item)
 std::ostream& operator<<(std::ostream& out, const pg_missing_item &item);
+#if FMT_VERSION >= 90000
+template <> struct fmt::formatter<pg_missing_item> : fmt::ostream_formatter {};
+#endif
 
 class pg_missing_const_i {
 public:
index fb555f3cb623227f6aae53f14e9cd3c806f4351d..2a43fe893ee5db43dc433552c42381242ca80df7 100644 (file)
@@ -324,3 +324,12 @@ struct fmt::formatter<ScrubMap> {
 
   bool debug_log{false};
 };
+
+#if FMT_VERSION >= 90000
+template <> struct fmt::formatter<ObjectRecoveryInfo> : fmt::ostream_formatter {};
+template <> struct fmt::formatter<ObjectRecoveryProgress> : fmt::ostream_formatter {};
+template <> struct fmt::formatter<PastIntervals> : fmt::ostream_formatter {};
+template <> struct fmt::formatter<pg_log_op_return_item_t> : fmt::ostream_formatter {};
+template <> struct fmt::formatter<watch_info_t> : fmt::ostream_formatter {};
+template <bool TrackChanges> struct fmt::formatter<pg_missing_set<TrackChanges>> : fmt::ostream_formatter {};
+#endif
index 73a62188289e2b2217af3a6be88c61d7784239e4..cffb2b7ea4c06251884e5180933a10d68cdb1172 100644 (file)
@@ -93,3 +93,6 @@ struct BackfillInterval {
 
 std::ostream &operator<<(std::ostream &out, const BackfillInterval &bi);
 
+#if FMT_VERSION >= 90000
+template <> struct fmt::formatter<BackfillInterval> : fmt::ostream_formatter {};
+#endif