cpp-msgpack-rpc 0.2.0
An RPC library implementing MessagePack RPC.
Loading...
Searching...
No Matches
format_msgpack_object.h
Go to the documentation of this file.
1/*
2 * Copyright 2023 MusicScience37 (Kenta Kabashima)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
20#pragma once
21
22#include <fmt/base.h>
23#include <msgpack.hpp>
24
25#include "msgpack_rpc/impl/msgpack_rpc_export.h"
26
28
32class MSGPACK_RPC_EXPORT FmtMsgpackObjectProxy {
33public:
39 explicit FmtMsgpackObjectProxy(const msgpack::object& object);
40
46 [[nodiscard]] const msgpack::object& object() const noexcept;
47
48private:
50 const msgpack::object&
51 object_; // NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members)
52 // This class is used only as temporary objects.
53};
54
55} // namespace msgpack_rpc::util::impl
56
57namespace fmt {
58
63template <>
64struct formatter<msgpack_rpc::util::impl::FmtMsgpackObjectProxy> {
65public:
72 constexpr format_parse_context::iterator parse( // NOLINT
73 format_parse_context& context) {
74 return context.end();
75 }
76
84 [[nodiscard]] MSGPACK_RPC_EXPORT format_context::iterator format(
86 format_context& context) const;
87};
88
89} // namespace fmt
90
91namespace msgpack_rpc::util {
92
99[[nodiscard]] MSGPACK_RPC_EXPORT impl::FmtMsgpackObjectProxy
100format_msgpack_object(const msgpack::object& object);
101
102} // namespace msgpack_rpc::util
Class to format objects in msgpack library using fmt library.
const msgpack::object & object() const noexcept
Get the object in msgpack library.
const msgpack::object & object_
Object in msgpack library.
FmtMsgpackObjectProxy(const msgpack::object &object)
Constructor.
Namespace of fmt library.
Definition uri.h:113
Namespace of internal implementations.
Namespace of utilities.
impl::FmtMsgpackObjectProxy format_msgpack_object(const msgpack::object &object)
Format an object in msgpack library using fmt library.
Namespace of cpp-msgpack-rpc library.
Definition i_address.h:26
constexpr format_parse_context::iterator parse(format_parse_context &context)
Parse format.