#include <fmt/format.h>
#include "include/utime.h"
+#include "include/utime_fmt.h"
#include "msg/msg_fmt.h"
#include "msg/msg_types.h"
#include "common/entity_name.h"
template <> struct fmt::formatter<EntityName> : fmt::formatter<std::string_view> {
template <typename FormatContext>
- auto format(const EntityName& e, FormatContext& ctx) {
+ auto format(const EntityName& e, FormatContext& ctx) const {
return formatter<std::string_view>::format(e.to_str(), ctx);
}
};
template <> struct fmt::formatter<LogEntry> : fmt::formatter<std::string_view> {
template <typename FormatContext>
- auto format(const LogEntry& e, FormatContext& ctx) {
+ auto format(const LogEntry& e, FormatContext& ctx) const {
return fmt::format_to(ctx.out(), "{} {} ({}) {} : {} [{}] {}",
e.stamp, e.name, e.rank, e.seq, e.channel,
LogEntry::level_to_str(e.prio), e.msg);
concept has_alt_fmt_print = requires(T t) {
{ t.alt_fmt_print(bool{}) } -> std::same_as<std::string>;
};
+#if FMT_VERSION >= 110000
+template<class T>
+concept has_fmt_print_ctx = requires(
+ T t, fmt::buffered_context<char> &ctx) {
+ { t.fmt_print_ctx(ctx) } -> std::same_as<decltype(ctx.out())>;
+};
+#else
template<class T>
concept has_fmt_print_ctx = requires(
T t, fmt::buffer_context<char> &ctx) {
{ t.fmt_print_ctx(ctx) } -> std::same_as<decltype(ctx.out())>;
};
+#endif
namespace fmt {
}
template <typename FormatContext>
- auto format(const utime_t& utime, FormatContext& ctx)
+ auto format(const utime_t& utime, FormatContext& ctx) const
{
if (utime.sec() < ((time_t)(60 * 60 * 24 * 365 * 10))) {
// raw seconds. this looks like a relative time.
std::ostringstream oss;
m.print(oss);
if (auto ver = m.get_header().version; ver) {
- return fmt::format_to(ctx.out(), "{} v{}", oss.str(), ver);
+ return fmt::format_to(ctx.out(), "{} v{}", oss.str(), (uint32_t)ver);
} else {
return fmt::format_to(ctx.out(), "{}", oss.str());
}
sizeof(*preamble) - sizeof(preamble->crc));
if (crc != preamble->crc) {
throw FrameError(fmt::format(
- "bad preamble crc calculated={} expected={}", crc, preamble->crc));
+ "bad preamble crc calculated={} expected={}", crc, (uint32_t)preamble->crc));
}
// see calc_num_segments()
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
template <typename FormatContext>
- auto format(const entity_name_t& addr, FormatContext& ctx)
+ auto format(const entity_name_t& addr, FormatContext& ctx) const
{
if (addr.is_new() || addr.num() < 0) {
return fmt::format_to(ctx.out(), "{}.?", addr.type_str());