132struct fmt::formatter<std::filesystem::path> : fmt::formatter<std::string_view>
134 template <
typename FormatContext>
135 auto format (
const std::filesystem::path &p, FormatContext &ctx)
const
137 return fmt::formatter<std::string_view>::format (
138 utils::Utf8String::from_path (p).view (), ctx);
144struct fmt::formatter<juce::String> : fmt::formatter<std::string_view>
146 template <
typename FormatContext>
147 auto format (
const juce::String &s, FormatContext &ctx)
const
149 return fmt::formatter<std::string_view>::format (
150 utils::Utf8String::from_juce_string (s).view (), ctx);
155template <>
struct fmt::formatter<juce::File> : fmt::formatter<std::string_view>
157 template <
typename FormatContext>
158 auto format (
const juce::File &s, FormatContext &ctx)
const
160 return fmt::formatter<std::string_view>::format (
161 utils::Utf8String::from_juce_string (s.getFullPathName ()).view (), ctx);
166template <>
struct fmt::formatter<QString> : fmt::formatter<std::string_view>
168 template <
typename FormatContext>
169 auto format (
const QString &s, FormatContext &ctx)
const
171 return fmt::formatter<std::string_view>::format (
172 utils::Utf8String::from_qstring (s).view (), ctx);
178struct fmt::formatter<Ptr> : fmt::formatter<std::string_view>
180 template <
typename FormatContext>
181 auto format (
const Ptr &ptr, FormatContext &ctx)
const
185 return fmt::formatter<std::string_view>::format (
186 fmt::format (
"{}", *ptr), ctx);
189 return fmt::formatter<std::string_view>::format (
"(null)", ctx);
195struct fmt::formatter<std::optional<T>> : fmt::formatter<std::string_view>
197 template <
typename FormatContext>
198 auto format (
const std::optional<T> &opt, FormatContext &ctx)
const
200 if (opt.has_value ())
202 return fmt::formatter<std::string_view>::format (
203 fmt::format (
"{}", *opt), ctx);
205 return fmt::formatter<std::string_view>::format (
"(nullopt)", ctx);
223struct fmt::formatter<QPointer<T>> : fmt::formatter<std::string_view>
225 template <
typename FormatContext>
226 auto format (
const QPointer<T> &opt, FormatContext &ctx)
const
230 return fmt::formatter<std::string_view>::format (
231 fmt::format (
"{}", *opt), ctx);
233 return fmt::formatter<std::string_view>::format (
"(null)", ctx);
255template <>
struct fmt::formatter<QUuid> : fmt::formatter<std::string_view>
257 template <
typename FormatContext>
258 auto format (
const QUuid &uuid, FormatContext &ctx)
const
260 return fmt::formatter<QString>{}.format (
261 uuid.toString (QUuid::WithoutBraces), ctx);
267struct fmt::formatter<std::source_location> : fmt::formatter<std::string_view>
269 template <
typename FormatContext>
270 auto format (
const std::source_location &loc, FormatContext &ctx)
const
272 return fmt::formatter<std::string_view>::format (
274 "{}:{}:{}:{}", loc.file_name (), loc.function_name (), loc.line (),
298struct fmt::formatter<T> : fmt::formatter<std::string_view>
300 template <
typename FormatContext>
301 auto format (
const T &val, FormatContext &ctx)
const
303 return fmt::formatter<std::string_view>::format (
304 fmt::format (
"{}", ENUM_NAME (val)), ctx);
318struct fmt::formatter<
322 boost::describe::has_describe_bases<T>::value
323 && boost::describe::has_describe_members<T>::value && !std::is_union_v<T>>>
325 constexpr auto parse (format_parse_context &ctx)
327 const auto * it = ctx.begin ();
328 const auto * end = ctx.end ();
330 if (it != end && *it !=
'}')
332 throw std::format_error (
"invalid format");
340 template <
typename List,
typename F>
static void for_each_descriptor (F &&f)
342 constexpr auto N = boost::mp11::mp_size<List>::value;
343 [&f]<std::size_t... Is> (std::index_sequence<Is...>) {
344 (f (boost::mp11::mp_at_c<List, Is>{}), ...);
345 }(std::make_index_sequence<N>{});
348 auto format (T
const &t, format_context &ctx)
const
350 using namespace boost::describe;
352 using Bases = describe_bases<T, mod_any_access>;
353 using Members = describe_members<T, mod_any_access>;
356 std::vector<std::string> parts;
358 for_each_descriptor<Bases> ([&] (
auto Base) {
359 using BaseType =
typename decltype (Base)::type;
360 parts.push_back (fmt::format (
"{}",
static_cast<BaseType
const &
> (t)));
363 for_each_descriptor<Members> ([&] (
auto Member) {
364 parts.push_back (fmt::format (
".{}={}", Member.name, t.*Member.pointer));
368 return fmt::format_to (ctx.out (),
"{{ {} }}", fmt::join (parts,
", "));