RESTinio
Loading...
Searching...
No Matches
restinio
router
impl
target_path_holder.hpp
Go to the documentation of this file.
1
/*
2
* RESTinio
3
*/
4
11
12
#pragma once
13
14
#include <
restinio/utils/percent_encoding.hpp
>
15
16
#include <
restinio/string_view.hpp
>
17
18
#include <memory>
19
20
namespace
restinio
21
{
22
23
namespace
router
24
{
25
26
namespace
impl
27
{
28
29
//
30
// target_path_holder_t
31
//
45
class
target_path_holder_t
46
{
47
public
:
48
using
data_t
= std::unique_ptr<char[]>;
49
51
62
target_path_holder_t
(
string_view_t
original_path )
63
:
m_size
{
restinio
::
utils
::uri_normalization::
64
unreserved_chars::estimate_required_capacity( original_path ) }
65
{
66
m_data
.reset(
new
char
[
m_size
] );
67
68
if
(
m_size
!= original_path.size() )
69
// Transformation is actually needed.
70
restinio::utils::uri_normalization::unreserved_chars
::
71
normalize_to( original_path,
m_data
.get() );
72
else
73
// Just copy original value to the destination.
74
std::copy(
75
original_path.begin(), original_path.end(),
76
m_data
.get() );
77
}
78
80
84
[[nodiscard]]
85
string_view_t
86
view
() const noexcept
87
{
88
return
{
m_data
.get(),
m_size
};
89
}
90
92
97
[[nodiscard]]
98
data_t
99
giveout_data
() noexcept
100
{
101
return
std::move(
m_data
);
102
}
103
104
private
:
106
110
data_t
m_data
;
112
std::size_t
m_size
;
113
};
114
115
}
/* namespace impl */
116
117
}
/* namespace router */
118
119
}
/* namespace restinio */
120
restinio::router::impl::target_path_holder_t::giveout_data
data_t giveout_data() noexcept
Give out the value from holder.
Definition
target_path_holder.hpp:99
restinio::router::impl::target_path_holder_t::view
string_view_t view() const noexcept
Get access to the value of target_path.
Definition
target_path_holder.hpp:86
restinio::router::impl::target_path_holder_t::m_data
data_t m_data
Actual data with target_path.
Definition
target_path_holder.hpp:110
restinio::router::impl::target_path_holder_t::target_path_holder_t
target_path_holder_t(string_view_t original_path)
Initializing constructor.
Definition
target_path_holder.hpp:62
restinio::router::impl::target_path_holder_t::m_size
std::size_t m_size
The length of target_path.
Definition
target_path_holder.hpp:112
restinio::router::impl::target_path_holder_t::data_t
std::unique_ptr< char[]> data_t
Definition
target_path_holder.hpp:48
restinio::router::impl
Definition
express.hpp:33
restinio::router
Definition
boost_regex_engine.hpp:17
restinio::utils::uri_normalization::unreserved_chars
Definition
percent_encoding.hpp:471
restinio::utils
Definition
at_scope_exit.hpp:23
restinio
Definition
asio_include.hpp:21
restinio::string_view_t
std::string_view string_view_t
Definition
string_view.hpp:15
percent_encoding.hpp
string_view.hpp
Generated by
1.13.2