Ada
2.9.2
Fast spec-compliant URL parser
Loading...
Searching...
No Matches
url_components-inl.h
Go to the documentation of this file.
1
5
#ifndef ADA_URL_COMPONENTS_INL_H
6
#define ADA_URL_COMPONENTS_INL_H
7
8
#include "
ada/url_components.h
"
9
10
namespace
ada
{
11
12
[[nodiscard]]
constexpr
bool
url_components::check_offset_consistency
()
13
const noexcept {
26
// These conditions can be made more strict.
27
uint32_t index = 0;
28
29
if
(
protocol_end
==
url_components::omitted
) {
30
return
false
;
31
}
32
if
(
protocol_end
< index) {
33
return
false
;
34
}
35
index =
protocol_end
;
36
37
if
(
username_end
==
url_components::omitted
) {
38
return
false
;
39
}
40
if
(
username_end
< index) {
41
return
false
;
42
}
43
index =
username_end
;
44
45
if
(
host_start
==
url_components::omitted
) {
46
return
false
;
47
}
48
if
(
host_start
< index) {
49
return
false
;
50
}
51
index =
host_start
;
52
53
if
(
port
!=
url_components::omitted
) {
54
if
(
port
> 0xffff) {
55
return
false
;
56
}
57
uint32_t port_length = helpers::fast_digit_count(
port
) + 1;
58
if
(index + port_length < index) {
59
return
false
;
60
}
61
index += port_length;
62
}
63
64
if
(
pathname_start
==
url_components::omitted
) {
65
return
false
;
66
}
67
if
(
pathname_start
< index) {
68
return
false
;
69
}
70
index =
pathname_start
;
71
72
if
(
search_start
!=
url_components::omitted
) {
73
if
(
search_start
< index) {
74
return
false
;
75
}
76
index =
search_start
;
77
}
78
79
if
(
hash_start
!=
url_components::omitted
) {
80
if
(
hash_start
< index) {
81
return
false
;
82
}
83
}
84
85
return
true
;
86
}
87
88
}
// namespace ada
89
#endif
ada
Definition
ada_idna.h:13
ada::url_components::pathname_start
uint32_t pathname_start
Definition
url_components.h:57
ada::url_components::hash_start
uint32_t hash_start
Definition
url_components.h:59
ada::url_components::port
uint32_t port
Definition
url_components.h:56
ada::url_components::omitted
static constexpr uint32_t omitted
Definition
url_components.h:24
ada::url_components::check_offset_consistency
constexpr bool check_offset_consistency() const noexcept
Definition
url_components-inl.h:12
ada::url_components::protocol_end
uint32_t protocol_end
Definition
url_components.h:48
ada::url_components::search_start
uint32_t search_start
Definition
url_components.h:58
ada::url_components::username_end
uint32_t username_end
Definition
url_components.h:53
ada::url_components::host_start
uint32_t host_start
Definition
url_components.h:54
url_components.h
Declaration for the URL Components.