]> git.proxmox.com Git - ceph.git/blame - ceph/src/msg/msg_fmt.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / msg / msg_fmt.h
CommitLineData
20effc67
TL
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3#pragma once
4
5/**
6 * \file fmtlib formatters for some msg_types.h classes
7 */
8
9#include <fmt/format.h>
10
20effc67
TL
11#include "msg/msg_types.h"
12
13template <>
14struct fmt::formatter<entity_name_t> {
15 constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
16
17 template <typename FormatContext>
18 auto format(const entity_name_t& addr, FormatContext& ctx)
19 {
20 if (addr.is_new() || addr.num() < 0) {
21 return fmt::format_to(ctx.out(), "{}.?", addr.type_str());
22 }
23 return fmt::format_to(ctx.out(), "{}.{}", addr.type_str(), addr.num());
24 }
25};