cpp-msgpack-rpc
0.2.0
An RPC library implementing MessagePack RPC.
Toggle main menu visibility
Loading...
Searching...
No Matches
unix_socket_address.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2024 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
#include "
msgpack_rpc/addresses/unix_socket_address.h
"
21
22
#if MSGPACK_RPC_HAS_UNIX_SOCKETS
23
24
#include <utility>
25
26
#include <asio/local/basic_endpoint.hpp>
27
#include <fmt/format.h>
28
29
#include "
msgpack_rpc/addresses/schemes.h
"
30
31
namespace
msgpack_rpc::addresses
{
32
33
UnixSocketAddress::UnixSocketAddress(AsioUnixSocketAddress address)
34
: address_(std::move(address)) {}
35
36
std::string UnixSocketAddress::file_path()
const
{
return
address_.path(); }
37
38
URI UnixSocketAddress::to_uri()
const
{
39
return
URI(UNIX_SOCKET_SCHEME, address_.path());
40
}
41
42
std::string UnixSocketAddress::to_string()
const
{
43
return
fmt::format(
"unix://{}"
, address_.path());
44
}
45
46
const
AsioUnixSocketAddress& UnixSocketAddress::asio_address()
const
{
47
return
address_;
48
}
49
50
bool
UnixSocketAddress::operator==(
const
UnixSocketAddress& right)
const
{
51
return
address_ == right.address_;
52
}
53
54
bool
UnixSocketAddress::operator!=(
const
UnixSocketAddress& right)
const
{
55
return
!
operator==
(right);
56
}
57
58
}
// namespace msgpack_rpc::addresses
59
60
namespace
fmt
{
61
62
format_context::iterator
63
formatter<msgpack_rpc::addresses::UnixSocketAddress>::format(
// NOLINT
64
const
msgpack_rpc::addresses::UnixSocketAddress& val,
65
format_context& context)
const
{
66
return
fmt::format_to(context.out(),
"unix://{}"
, val.file_path());
67
}
68
69
}
// namespace fmt
70
71
std::ostream&
operator<<
(std::ostream& stream,
72
const
msgpack_rpc::addresses::UnixSocketAddress& address) {
73
stream <<
"unix://"
<< address.file_path();
74
return
stream;
75
}
76
77
#endif
fmt
Namespace of fmt library.
Definition
uri.h:113
msgpack_rpc::addresses
Namespace of addresses.
Definition
i_address.h:26
msgpack_rpc::messages::operator==
bool operator==(const MethodName &left, const MethodName &right) noexcept
Compare two method names.
Definition
method_name.h:114
schemes.h
Definition of constants of schemes.
unix_socket_address.h
Definition of UnixSocketAddress class.
operator<<
std::ostream & operator<<(std::ostream &stream, const msgpack_rpc::addresses::URI &uri)
Format a URI.
Definition
uri.cpp:110
src
msgpack_rpc
addresses
unix_socket_address.cpp
Generated on
for cpp-msgpack-rpc by
1.18.0