From 1e1076e43fe8f38e33246fff3ce8651a93c371d9 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 7 Jul 2022 13:11:34 +0200 Subject: [PATCH] fix compilation with fmt v9.0.0 Prior to v9 all types that were outputtable via `operator<<` to `std::ostream` could be formatted. v9 changed that to require explicit tagging of those types that should work this way. This commit adds those tags for the types that are currently formatted via fmt. Fixes #3366. --- NEWS.md | 1 + src/common/aac.h | 4 ++++ src/common/bcp47.h | 5 +++++ src/common/bluray/track_chapter_names.cpp | 1 + src/common/error.h | 4 ++++ src/common/fourcc.h | 4 ++++ src/common/kax_analyzer.h | 4 ++++ src/common/math_fwd.h | 5 +++++ src/common/mm_io_x.h | 13 +++++++++++++ src/common/opus.h | 6 ++++++ src/common/path.h | 4 ++++ src/common/qt.h | 4 ++++ src/common/strings/formatting.h | 4 ++++ src/common/translation.h | 4 ++++ src/input/r_flac.cpp | 4 ++-- src/input/r_flv.h | 5 +++++ src/input/r_mpeg_ps.h | 5 +++++ src/input/r_ogm_flac.cpp | 2 +- src/input/r_qtmp4.h | 4 ++++ src/merge/item_selector.h | 4 ++++ src/propedit/attachment_target.cpp | 4 ++-- src/propedit/attachment_target.h | 4 ++++ src/propedit/tag_target.cpp | 6 +++--- src/propedit/track_target.cpp | 4 ++-- 24 files changed, 95 insertions(+), 10 deletions(-) diff --git a/src/common/aac.h b/src/common/aac.h index 2ba9f9d2f..253e628b1 100644 --- a/src/common/aac.h +++ b/src/common/aac.h @@ -221,3 +221,7 @@ protected: using parser_cptr = std::shared_ptr; } // namespace mtx::aac + +#if FMT_VERSION >= 90000 +template <> struct fmt::formatter : ostream_formatter {}; +#endif // FMT_VERSION >= 90000 diff --git a/src/common/bcp47.h b/src/common/bcp47.h index ae9668d39..c95511e9d 100644 --- a/src/common/bcp47.h +++ b/src/common/bcp47.h @@ -176,3 +176,8 @@ struct hash { }; } // namespace mtx::bcp47 + +#if FMT_VERSION >= 90000 +template <> struct fmt::formatter : ostream_formatter {}; +template <> struct fmt::formatter : ostream_formatter {}; +#endif // FMT_VERSION >= 90000 diff --git a/src/common/bluray/track_chapter_names.cpp b/src/common/bluray/track_chapter_names.cpp index 7c115743f..768410d0f 100644 --- a/src/common/bluray/track_chapter_names.cpp +++ b/src/common/bluray/track_chapter_names.cpp @@ -18,6 +18,7 @@ #include "common/bluray/track_chapter_names.h" #include "common/bluray/util.h" #include "common/debugging.h" +#include "common/path.h" #include "common/qt.h" #include "common/xml/xml.h" diff --git a/src/common/error.h b/src/common/error.h index c9ebf64e8..adc0182b3 100644 --- a/src/common/error.h +++ b/src/common/error.h @@ -45,3 +45,7 @@ operator <<(std::ostream &out, } } + +#if FMT_VERSION >= 90000 +template <> struct fmt::formatter : ostream_formatter {}; +#endif // FMT_VERSION >= 90000 diff --git a/src/common/fourcc.h b/src/common/fourcc.h index 88cbae6ac..92b1f2347 100644 --- a/src/common/fourcc.h +++ b/src/common/fourcc.h @@ -83,3 +83,7 @@ operator <<(std::ostream &out, out << fourcc.str(); return out; } + +#if FMT_VERSION >= 90000 +template <> struct fmt::formatter : ostream_formatter {}; +#endif // FMT_VERSION >= 90000 diff --git a/src/common/kax_analyzer.h b/src/common/kax_analyzer.h index e26dba196..a8f0d1ffd 100644 --- a/src/common/kax_analyzer.h +++ b/src/common/kax_analyzer.h @@ -239,3 +239,7 @@ public: virtual void debug_abort_process(); }; using console_kax_analyzer_cptr = std::shared_ptr; + +#if FMT_VERSION >= 90000 +template <> struct fmt::formatter : ostream_formatter {}; +#endif // FMT_VERSION >= 90000 diff --git a/src/common/math_fwd.h b/src/common/math_fwd.h index c69fb81a7..4d0f9ae3f 100644 --- a/src/common/math_fwd.h +++ b/src/common/math_fwd.h @@ -18,6 +18,11 @@ using mtx_mp_rational_t = boost::multiprecision::number; using mtx_mp_int_t = boost::multiprecision::number; +#if FMT_VERSION >= 90000 +template <> struct fmt::formatter : ostream_formatter {}; +template <> struct fmt::formatter : ostream_formatter {}; +#endif // FMT_VERSION >= 90000 + namespace mtx { // This conversion function exists to work around incomplete diff --git a/src/common/mm_io_x.h b/src/common/mm_io_x.h index 307cc7614..49d898547 100644 --- a/src/common/mm_io_x.h +++ b/src/common/mm_io_x.h @@ -155,3 +155,16 @@ operator <<(std::ostream &out, } }} + +#if FMT_VERSION >= 90000 +template <> struct fmt::formatter : ostream_formatter {}; +template <> struct fmt::formatter : ostream_formatter {}; +template <> struct fmt::formatter : ostream_formatter {}; +template <> struct fmt::formatter : ostream_formatter {}; +template <> struct fmt::formatter : ostream_formatter {}; +template <> struct fmt::formatter: ostream_formatter {}; +template <> struct fmt::formatter : ostream_formatter {}; +template <> struct fmt::formatter : ostream_formatter {}; +template <> struct fmt::formatter : ostream_formatter {}; +template <> struct fmt::formatter: ostream_formatter {}; +#endif // FMT_VERSION >= 90000 diff --git a/src/common/opus.h b/src/common/opus.h index dee5245ef..e98f8cb1c 100644 --- a/src/common/opus.h +++ b/src/common/opus.h @@ -91,3 +91,9 @@ operator <<(std::ostream &out, } } + +#if FMT_VERSION >= 90000 +template <> struct fmt::formatter : ostream_formatter {}; +template <> struct fmt::formatter : ostream_formatter {}; +template <> struct fmt::formatter : ostream_formatter {}; +#endif // FMT_VERSION >= 90000 diff --git a/src/common/path.h b/src/common/path.h index 396cf1946..3a4aa85a3 100644 --- a/src/common/path.h +++ b/src/common/path.h @@ -36,3 +36,7 @@ std::filesystem::path absolute(std::filesystem::path const &p); void create_directories(std::filesystem::path const &path, std::error_code &error_code); } // namespace mtx::fs + +#if FMT_VERSION >= 90000 +template <> struct fmt::formatter : ostream_formatter {}; +#endif // FMT_VERSION >= 90000 diff --git a/src/common/qt.h b/src/common/qt.h index 0d68c2c11..680073af3 100644 --- a/src/common/qt.h +++ b/src/common/qt.h @@ -102,3 +102,7 @@ operator <<(std::wostream &out, out << string.toStdWString(); return out; } + +#if FMT_VERSION >= 90000 +template <> struct fmt::formatter : ostream_formatter {}; +#endif // FMT_VERSION >= 90000 diff --git a/src/common/strings/formatting.h b/src/common/strings/formatting.h index a2b56c771..0dc7542b6 100644 --- a/src/common/strings/formatting.h +++ b/src/common/strings/formatting.h @@ -129,3 +129,7 @@ operator <<(std::ostream &out, out << mtx::string::format_timestamp(timestamp); return out; } + +#if FMT_VERSION >= 90000 +template <> struct fmt::formatter> : ostream_formatter {}; +#endif // FMT_VERSION >= 90000 diff --git a/src/common/translation.h b/src/common/translation.h index 9ec8ec721..318e4f7b3 100644 --- a/src/common/translation.h +++ b/src/common/translation.h @@ -80,4 +80,8 @@ operator <<(std::ostream &out, return out; } +#if FMT_VERSION >= 90000 +template <> struct fmt::formatter : ostream_formatter {}; +#endif + void init_locales(std::string locale = ""); diff --git a/src/input/r_flac.cpp b/src/input/r_flac.cpp index cc9b42363..cbc70af1a 100644 --- a/src/input/r_flac.cpp +++ b/src/input/r_flac.cpp @@ -240,7 +240,7 @@ flac_reader_c::handle_picture_metadata(FLAC__StreamMetadata const *metadata) { mxdebug_if(m_debug, fmt::format("flac_reader: MIME type: {0}\n", attachment->mime_type)); mxdebug_if(m_debug, fmt::format("flac_reader: data length: {0}\n", picture.data_length)); mxdebug_if(m_debug, fmt::format("flac_reader: ID: {0}\n", m_attachment_id)); - mxdebug_if(m_debug, fmt::format("flac_reader: mode: {0}\n", attach_mode)); + mxdebug_if(m_debug, fmt::format("flac_reader: mode: {0}\n", static_cast(attach_mode))); if (attachment->mime_type.empty() || attachment->name.empty()) return; @@ -276,7 +276,7 @@ flac_reader_c::flac_metadata_cb(const FLAC__StreamMetadata *metadata) { : metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT ? "VORBIS COMMENT" : metadata->type == FLAC__METADATA_TYPE_CUESHEET ? "CUESHEET" : "UNDEFINED", - metadata->type, metadata->length)); + static_cast(metadata->type), metadata->length)); break; } } diff --git a/src/input/r_flv.h b/src/input/r_flv.h index d7e42e1a9..b63f82980 100644 --- a/src/input/r_flv.h +++ b/src/input/r_flv.h @@ -173,3 +173,8 @@ protected: unsigned int add_track(char type); }; + +#if FMT_VERSION >= 90000 +template <> struct fmt::formatter : ostream_formatter {}; +template <> struct fmt::formatter : ostream_formatter {}; +#endif // FMT_VERSION >= 90000 diff --git a/src/input/r_mpeg_ps.h b/src/input/r_mpeg_ps.h index a99ebd36d..934f6766b 100644 --- a/src/input/r_mpeg_ps.h +++ b/src/input/r_mpeg_ps.h @@ -244,3 +244,8 @@ private: void sort_tracks(); void calculate_global_timestamp_offset(); }; + +#if FMT_VERSION >= 90000 +template <> struct fmt::formatter : ostream_formatter {}; +template <> struct fmt::formatter : ostream_formatter {}; +#endif // FMT_VERSION >= 90000 diff --git a/src/input/r_ogm_flac.cpp b/src/input/r_ogm_flac.cpp index 060ec835f..715d06889 100644 --- a/src/input/r_ogm_flac.cpp +++ b/src/input/r_ogm_flac.cpp @@ -104,7 +104,7 @@ fhe_metadata_cb(const FLAC__StreamDecoder *, : metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT ? "VORBIS COMMENT" : metadata->type == FLAC__METADATA_TYPE_CUESHEET ? "CUESHEET" : "UNDEFINED", - metadata->type, metadata->length)); + static_cast(metadata->type), metadata->length)); break; } } diff --git a/src/input/r_qtmp4.h b/src/input/r_qtmp4.h index 5d79ce9eb..03407980d 100644 --- a/src/input/r_qtmp4.h +++ b/src/input/r_qtmp4.h @@ -590,3 +590,7 @@ protected: virtual void process_atom(qt_atom_t const &parent, int level, std::function const &handler); }; + +#if FMT_VERSION >= 90000 +template <> struct fmt::formatter : ostream_formatter {}; +#endif // FMT_VERSION >= 90000 diff --git a/src/merge/item_selector.h b/src/merge/item_selector.h index c105d0aa4..d611c4f1f 100644 --- a/src/merge/item_selector.h +++ b/src/merge/item_selector.h @@ -139,3 +139,7 @@ operator <<(std::ostream &out, return out; } + +#if FMT_VERSION >= 90000 +template struct fmt::formatter> : ostream_formatter {}; +#endif // FMT_VERSION >= 90000 diff --git a/src/propedit/attachment_target.cpp b/src/propedit/attachment_target.cpp index 22083a11c..1a7ada282 100644 --- a/src/propedit/attachment_target.cpp +++ b/src/propedit/attachment_target.cpp @@ -83,14 +83,14 @@ attachment_target_c::dump_info() " selector_num_arg: {6}\n" " selector_string_arg: {7}\n", m_file_name, - m_command, + static_cast(m_command), ac_add == m_command ? "add" : ac_delete == m_command ? "delete" : ac_replace == m_command ? "replace" : ac_update == m_command ? "update" : "unknown", m_options, - m_selector_type, + static_cast(m_selector_type), st_id == m_selector_type ? "ID" : st_uid == m_selector_type ? "UID" : st_name == m_selector_type ? "name" diff --git a/src/propedit/attachment_target.h b/src/propedit/attachment_target.h index e443e6621..60905f0cb 100644 --- a/src/propedit/attachment_target.h +++ b/src/propedit/attachment_target.h @@ -130,3 +130,7 @@ operator <<(std::ostream &out, return out; } + +#if FMT_VERSION >= 90000 +template <> struct fmt::formatter : ostream_formatter {}; +#endif // FMT_VERSION >= 90000 diff --git a/src/propedit/tag_target.cpp b/src/propedit/tag_target.cpp index dd53bfd2c..659ced628 100644 --- a/src/propedit/tag_target.cpp +++ b/src/propedit/tag_target.cpp @@ -104,10 +104,10 @@ tag_target_c::dump_info() " selection_track_type: {3}\n" " track_uid: {4}\n" " file_name: {5}\n", - static_cast(m_operation_mode), - static_cast(m_selection_mode), + static_cast(m_operation_mode), + static_cast(m_selection_mode), m_selection_param, - m_selection_track_type, + static_cast(m_selection_track_type), m_track_uid, m_file_name)); diff --git a/src/propedit/track_target.cpp b/src/propedit/track_target.cpp index 9f66c49ed..3dd23158c 100644 --- a/src/propedit/track_target.cpp +++ b/src/propedit/track_target.cpp @@ -78,9 +78,9 @@ track_target_c::dump_info() " selection_track_type: {2}\n" " track_uid: {3}\n" " file_name: {4}\n", - static_cast(m_selection_mode), + static_cast(m_selection_mode), m_selection_param, - m_selection_track_type, + static_cast(m_selection_track_type), m_track_uid, m_file_name)); -- GitLab