RESTinio
Loading...
Searching...
No Matches
restinio
impl
string_caseless_compare.hpp
Go to the documentation of this file.
1
/*
2
* RESTinio
3
*/
4
11
12
#pragma once
13
14
#include <
restinio/impl/to_lower_lut.hpp
>
15
#include <
restinio/string_view.hpp
>
16
17
namespace
restinio
18
{
19
20
namespace
impl
21
{
22
23
namespace
string_caseless_compare_details
24
{
25
26
constexpr
auto
27
uchar_at
(
const
char
*
const
from,
const
std::size_t at )
noexcept
28
{
29
return
static_cast<
unsigned
char
>
( from[ at ] );
30
}
31
32
}
/* namespace string_caseless_compare_details */
33
34
//
35
// is_equal_caseless()
36
//
37
39
inline
bool
40
is_equal_caseless
(
41
const
char
* a,
42
const
char
* b,
43
std::size_t size )
noexcept
44
{
45
using namespace
string_caseless_compare_details
;
46
47
const
unsigned
char
*
const
table =
to_lower_lut< unsigned char >
();
48
49
for
( std::size_t i = 0; i < size; ++i )
50
if
( table[ uchar_at( a, i ) ] != table[ uchar_at( b, i ) ] )
51
return
false
;
52
53
return
true
;
54
}
55
56
//
57
// is_equal_caseless()
58
//
59
61
inline
bool
62
is_equal_caseless
(
63
const
char
* a,
64
std::size_t a_size,
65
const
char
* b,
66
std::size_t b_size )
noexcept
67
{
68
if
( a_size == b_size )
69
{
70
return
is_equal_caseless
( a, b, a_size );
71
}
72
73
return
false
;
74
}
75
76
//
77
// is_equal_caseless()
78
//
79
81
inline
bool
82
is_equal_caseless
(
string_view_t
a,
string_view_t
b )
noexcept
83
{
84
return
is_equal_caseless
( a.data(), a.size(), b.data(), b.size() );
85
}
86
87
}
/* namespace impl */
88
89
}
/* namespace restinio */
90
restinio::impl::string_caseless_compare_details
Definition
string_caseless_compare.hpp:24
restinio::impl::string_caseless_compare_details::uchar_at
constexpr auto uchar_at(const char *const from, const std::size_t at) noexcept
Definition
string_caseless_compare.hpp:27
restinio::impl
Definition
asio_include.hpp:150
restinio::impl::to_lower_lut
const C * to_lower_lut()
Definition
to_lower_lut.hpp:13
restinio::impl::is_equal_caseless
bool is_equal_caseless(const char *a, const char *b, std::size_t size) noexcept
Comparator for fields names.
Definition
string_caseless_compare.hpp:40
restinio
Definition
asio_include.hpp:21
restinio::string_view_t
std::string_view string_view_t
Definition
string_view.hpp:15
string_view.hpp
to_lower_lut.hpp
Generated by
1.13.2