cpp-msgpack-rpc
0.2.0
An RPC library implementing MessagePack RPC.
Toggle main menu visibility
Loading...
Searching...
No Matches
uri.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 <cstdint>
23
#include <optional>
24
#include <ostream>
25
#include <string>
26
#include <string_view>
27
28
#include <fmt/base.h>
29
30
#include "msgpack_rpc/impl/msgpack_rpc_export.h"
31
32
namespace
msgpack_rpc::addresses
{
33
38
class
MSGPACK_RPC_EXPORT
URI
{
39
public
:
49
URI
(std::string_view
scheme
, std::string_view
host_or_path
,
50
std::optional<std::uint16_t>
port_number
=
51
std::optional<std::uint16_t>());
52
58
[[nodiscard]] std::string_view
scheme
()
const
noexcept
;
59
65
[[nodiscard]] std::string_view
host_or_path
()
const
noexcept
;
66
72
[[nodiscard]] std::optional<std::uint16_t>
port_number
()
const
noexcept
;
73
81
bool
operator==
(
const
URI
& right)
const
;
82
90
bool
operator!=
(
const
URI
& right)
const
;
91
98
[[nodiscard]]
static
URI
parse
(std::string_view uri_string);
99
100
private
:
102
std::string
scheme_
;
103
105
std::string
host_or_path_
;
106
108
std::optional<std::uint16_t>
port_number_
;
109
};
110
111
}
// namespace msgpack_rpc::addresses
112
113
namespace
fmt
{
114
119
template
<>
120
class
formatter<
msgpack_rpc
::addresses::URI> {
121
public
:
128
constexpr
format_parse_context::iterator
parse
(
// NOLINT
129
format_parse_context& context) {
130
return
context.end();
131
}
132
140
MSGPACK_RPC_EXPORT format_context::iterator format(
// NOLINT
141
const
msgpack_rpc::addresses::URI
& val, format_context& context)
const
;
142
};
143
144
}
// namespace fmt
145
153
MSGPACK_RPC_EXPORT std::ostream&
operator<<
(
154
std::ostream& stream,
const
msgpack_rpc::addresses::URI
& uri);
fmt::formatter< msgpack_rpc::addresses::URI >::parse
constexpr format_parse_context::iterator parse(format_parse_context &context)
Parse format.
Definition
uri.h:128
msgpack_rpc::addresses::URI
Class of URIs (Uniform Resource Identifiers) to specify endpoints in this library.
Definition
uri.h:38
msgpack_rpc::addresses::URI::scheme
std::string_view scheme() const noexcept
Get the scheme.
Definition
uri.cpp:38
msgpack_rpc::addresses::URI::scheme_
std::string scheme_
Scheme.
Definition
uri.h:102
msgpack_rpc::addresses::URI::port_number
std::optional< std::uint16_t > port_number() const noexcept
Get the port number.
Definition
uri.cpp:42
msgpack_rpc::addresses::URI::host_or_path_
std::string host_or_path_
Host name or file path.
Definition
uri.h:105
msgpack_rpc::addresses::URI::port_number_
std::optional< std::uint16_t > port_number_
Port.
Definition
uri.h:108
msgpack_rpc::addresses::URI::host_or_path
std::string_view host_or_path() const noexcept
Get the host name or file path.
Definition
uri.cpp:40
msgpack_rpc::addresses::URI::parse
static URI parse(std::string_view uri_string)
Parse a string to create a URI.
Definition
uri.cpp:54
msgpack_rpc::addresses::URI::operator==
bool operator==(const URI &right) const
Compare with a URI.
Definition
uri.cpp:46
msgpack_rpc::addresses::URI::operator!=
bool operator!=(const URI &right) const
Compare with a URI.
Definition
uri.cpp:52
msgpack_rpc::addresses::URI::URI
URI(std::string_view scheme, std::string_view host_or_path, std::optional< std::uint16_t > port_number=std::optional< std::uint16_t >())
Constructor.
Definition
uri.cpp:34
fmt
Namespace of fmt library.
Definition
uri.h:113
msgpack_rpc::addresses
Namespace of addresses.
Definition
i_address.h:26
msgpack_rpc
Namespace of cpp-msgpack-rpc library.
Definition
i_address.h:26
operator<<
std::ostream & operator<<(std::ostream &stream, const msgpack_rpc::addresses::URI &uri)
Format a URI.
Definition
uri.cpp:110
include
msgpack_rpc
addresses
uri.h
Generated on
for cpp-msgpack-rpc by
1.18.0