cpp-msgpack-rpc
0.2.0
An RPC library implementing MessagePack RPC.
Toggle main menu visibility
Loading...
Searching...
No Matches
method_name.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 <cstddef>
23
#include <string>
24
#include <string_view>
25
#include <utility>
26
27
#include <fmt/base.h>
28
#include <fmt/format.h>
29
30
namespace
msgpack_rpc::messages
{
31
35
class
MethodName
{
36
public
:
45
MethodName
(
// NOLINT(google-explicit-constructor, hicpp-explicit-conversions)
46
std::string
name
)
47
:
name_
(
std
::move(
name
)) {
48
// TODO Add a validation of UTF-8.
49
}
50
59
MethodName
(
// NOLINT(google-explicit-constructor, hicpp-explicit-conversions)
60
std::string_view
name
)
61
:
name_
(
name
) {
62
// TODO Add a validation of UTF-8.
63
}
64
74
MethodName
(
// NOLINT(google-explicit-constructor, hicpp-explicit-conversions)
75
const
char
*
name
, std::size_t size)
76
:
name_
(
name
, size) {
77
// TODO Add a validation of UTF-8.
78
}
79
88
MethodName
(
// NOLINT(google-explicit-constructor, hicpp-explicit-conversions)
89
const
char
*
name
)
90
:
name_
(
name
) {
91
// TODO Add a validation of UTF-8.
92
}
93
99
[[nodiscard]] std::string_view
name
() const noexcept {
return
name_
; }
100
101
private
:
103
std::string
name_
;
104
};
105
114
[[nodiscard]]
inline
bool
operator==
(
115
const
MethodName
& left,
const
MethodName
& right)
noexcept
{
116
return
left.name() == right.name();
117
}
118
127
[[nodiscard]]
inline
bool
operator!=
(
128
const
MethodName
& left,
const
MethodName
& right)
noexcept
{
129
return
left.name() != right.name();
130
}
131
132
}
// namespace msgpack_rpc::messages
133
134
namespace
fmt
{
135
140
template
<>
141
class
formatter<
msgpack_rpc
::messages::MethodName>
142
:
public
formatter<std::string_view> {
143
public
:
151
format_context::iterator
format
(
152
const
msgpack_rpc::messages::MethodName
& val,
153
format_context& context)
const
{
154
return
formatter<std::string_view>::format(val.
name
(), context);
155
}
156
};
157
158
}
// namespace fmt
fmt::formatter< msgpack_rpc::messages::MethodName >::format
format_context::iterator format(const msgpack_rpc::messages::MethodName &val, format_context &context) const
Format a value.
Definition
method_name.h:151
msgpack_rpc::messages::MethodName
Class of method names.
Definition
method_name.h:35
msgpack_rpc::messages::MethodName::MethodName
MethodName(const char *name)
Constructor.
Definition
method_name.h:88
msgpack_rpc::messages::MethodName::MethodName
MethodName(const char *name, std::size_t size)
Constructor.
Definition
method_name.h:74
msgpack_rpc::messages::MethodName::MethodName
MethodName(std::string_view name)
Constructor.
Definition
method_name.h:59
msgpack_rpc::messages::MethodName::name_
std::string name_
Method name.
Definition
method_name.h:103
msgpack_rpc::messages::MethodName::MethodName
MethodName(std::string name)
Constructor.
Definition
method_name.h:45
msgpack_rpc::messages::MethodName::name
std::string_view name() const noexcept
Get the method name.
Definition
method_name.h:99
fmt
Namespace of fmt library.
Definition
uri.h:113
msgpack_rpc::messages
Namespace of messages.
Definition
buffer_view.h:24
msgpack_rpc::messages::operator!=
bool operator!=(const MethodName &left, const MethodName &right) noexcept
Compare two method names.
Definition
method_name.h:127
msgpack_rpc::messages::operator==
bool operator==(const MethodName &left, const MethodName &right) noexcept
Compare two method names.
Definition
method_name.h:114
msgpack_rpc
Namespace of cpp-msgpack-rpc library.
Definition
i_address.h:26
std
STL namespace.
include
msgpack_rpc
messages
method_name.h
Generated on
for cpp-msgpack-rpc by
1.18.0