13 #include <restinio/impl/include_fmtlib.hpp> 15 #include <restinio/string_view.hpp> 16 #include <restinio/exception.hpp> 17 #include <restinio/expected.hpp> 19 #include <restinio/utils/utf8_checker.hpp> 41 (
'0' <= c && c <=
'9' ) ||
42 (
'a' <= c && c <=
'z' ) ||
43 (
'A' <= c && c <=
'Z' ) ||
66 (
'0' <= c && c <=
'9' ) ||
67 (
'a' <= c && c <=
'z' ) ||
68 (
'A' <= c && c <=
'Z' ) ||
101 return nullptr != std::strchr(
103 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 104 "abcdefghijklmnopqrstuvwxyz" 126 static constexpr bool 130 (
'0' <= c && c <=
'9' ) ||
131 (
'a' <= c && c <=
'z' ) ||
132 (
'A' <= c && c <=
'Z' ) ||
166 std::string description )
193 (
'0' <= c && c <=
'9' ) ||
194 (
'a' <= c && c <=
'f' ) ||
195 (
'A' <= c && c <=
'F' );
203 if(
'0' <= c1 && c1 <=
'9' )
208 result = 10 + c1 -
'a';
213 if(
'0' <= c2 && c2 <=
'9' )
218 result += 10 + c2 -
'a';
234 typename Chars_Collector >
258 "next byte from UTF-8 sequence expected at {}" ),
273 "invalid UTF-8 sequence detected at {}" ),
290 "invalid escape sequence at pos {}" ),
312 "invalid non-escaped char with code {:#02X} at pos: {}" ),
484 constexpr inline bool 507 typename One_Byte_Handler,
508 typename Three_Byte_Handler >
512 One_Byte_Handler && one_byte_handler,
513 Three_Byte_Handler && three_byte_handler )
531 "next byte from UTF-8 sequence expected at {}" ),
550 "invalid UTF-8 sequence detected at {}" ),
622 std::size_t calculated_capacity = 0u;
624 impl::run_normalization_algo( what,
625 [&calculated_capacity](
char )
noexcept {
626 ++calculated_capacity;
628 [&calculated_capacity](
char,
char,
char )
noexcept {
629 calculated_capacity += 3u;
632 return calculated_capacity;
658 impl::run_normalization_algo( what,
659 [&dest](
char ch )
noexcept {
662 [&dest](
char ch1,
char ch2,
char ch3 )
noexcept {
expected_t< std::size_t, unescape_percent_encoding_failure_t > try_inplace_unescape_percent_encoding(char *data, std::size_t size)
Helper function for unescaping percent-encoded string inplace.
static constexpr bool ordinary_char(char c) noexcept
string_view_t from_string< string_view_t >(string_view_t s)
Get a value from string_view.
std::size_t inplace_unescape_percent_encoding(char *data, std::size_t size)
static bool ordinary_char(char c) noexcept
The traits for escaping and unexcaping symbols in JavaScript-compatible mode.
std::string m_description
Description of a failure.
The default traits for escaping and unexcaping symbols in a query string.
std::enable_if< std::is_same< Parameter_Container, query_string_params_t >::value||std::is_same< Parameter_Container, router::route_params_t >::value, std::optional< Value_Type > >::type opt_value(const Parameter_Container ¶ms, string_view_t key)
Gets the value of a parameter specified by key wrapped in std::optional<Value_Type> if parameter exis...
std::string giveout_description() noexcept
Get out the value of the description of the failure.
std::string unescape_percent_encoding(const string_view_t data)
void run_normalization_algo(string_view_t what, One_Byte_Handler &&one_byte_handler, Three_Byte_Handler &&three_byte_handler)
Internal helper to perform the main logic of enumeration of symbols in URI.
expected_t< std::string, unescape_percent_encoding_failure_t > try_unescape_percent_encoding(const string_view_t data)
Helper function for unescaping percent-encoded string.
Traits for escaping and unescaping symbols in a query string in very relaxed mode.
void normalize_to(string_view_t what, char *dest)
Perform normalization of URI value.
char extract_escaped_char(char c1, char c2)
expected_t< unescape_percent_encoding_success_t, unescape_percent_encoding_failure_t > do_unescape_percent_encoding(const string_view_t data, Chars_Collector &&collector)
The actual implementation of unescape-percent-encoding procedure.
std::string escape_percent_encoding(const string_view_t data)
Percent encoding.
unescape_percent_encoding_failure_t(std::string description)
constexpr bool is_unreserved_char(const char ch) noexcept
Is this symbol a part of unreserved set?
const std::string & description() const noexcept
Get a reference to the description of the failure.
std::size_t estimate_required_capacity(string_view_t what)
Calculate the size of a buffer to hold normalized value of a URI.
static constexpr bool ordinary_char(char c) noexcept
Type that indicates a failure of unescaping of percent-encoded symbols.
Type that indicates that unescaping of percent-encoded symbols completed successfully.