Skip to content

Commit 0ccd6d3

Browse files
committed
create url_pattern-inl.h
1 parent 02492e1 commit 0ccd6d3

File tree

3 files changed

+76
-20
lines changed

3 files changed

+76
-20
lines changed

Diff for: include/ada.h

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "ada/url_search_params.h"
2828
#include "ada/url_search_params-inl.h"
2929
#include "ada/url_pattern.h"
30+
#include "ada/url_pattern-inl.h"
3031

3132
// Public API
3233
#include "ada/ada_version.h"

Diff for: include/ada/url_pattern-inl.h

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/**
2+
* @file url_pattern-inl.h
3+
* @brief Declaration for the URLPattern inline functions.
4+
*/
5+
#ifndef ADA_URL_PATTERN_INL_H
6+
#define ADA_URL_PATTERN_INL_H
7+
8+
#include "common_defs.h"
9+
#include "url_pattern.h"
10+
11+
#include <string_view>
12+
13+
namespace ada {
14+
inline std::string_view URLPattern::Component::get_pattern() const noexcept
15+
ada_lifetime_bound {
16+
return pattern;
17+
}
18+
19+
inline std::string_view URLPattern::Component::get_regex() const noexcept
20+
ada_lifetime_bound {
21+
return regex;
22+
}
23+
24+
inline const std::vector<std::string>& URLPattern::Component::get_names()
25+
const noexcept ada_lifetime_bound {
26+
return names;
27+
}
28+
29+
inline const URLPattern::Component& URLPattern::get_protocol() const
30+
ada_lifetime_bound {
31+
return protocol;
32+
}
33+
inline const URLPattern::Component& URLPattern::get_username() const
34+
ada_lifetime_bound {
35+
return username;
36+
}
37+
inline const URLPattern::Component& URLPattern::get_password() const
38+
ada_lifetime_bound {
39+
return password;
40+
}
41+
inline const URLPattern::Component& URLPattern::get_port() const
42+
ada_lifetime_bound {
43+
return port;
44+
}
45+
inline const URLPattern::Component& URLPattern::get_pathname() const
46+
ada_lifetime_bound {
47+
return pathname;
48+
}
49+
inline const URLPattern::Component& URLPattern::get_search() const
50+
ada_lifetime_bound {
51+
return search;
52+
}
53+
inline const URLPattern::Component& URLPattern::get_hash() const
54+
ada_lifetime_bound {
55+
return hash;
56+
}
57+
58+
inline bool URLPattern::case_ignored() const ada_lifetime_bound {
59+
return ignore_case;
60+
}
61+
62+
} // namespace ada
63+
64+
#endif

Diff for: include/ada/url_pattern.h

+11-20
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,10 @@ class URLPattern {
2323
explicit Component(std::string_view pattern, std::string_view regex,
2424
const std::vector<std::string>& names);
2525

26-
// TODO(anonrig): Move these implementations to `url_pattern-inl.h`
27-
std::string_view get_pattern() const noexcept ada_lifetime_bound {
28-
return pattern;
29-
}
30-
std::string_view get_regex() const noexcept ada_lifetime_bound {
31-
return regex;
32-
}
26+
std::string_view get_pattern() const noexcept ada_lifetime_bound;
27+
std::string_view get_regex() const noexcept ada_lifetime_bound;
3328
const std::vector<std::string>& get_names() const noexcept
34-
ada_lifetime_bound {
35-
return names;
36-
}
29+
ada_lifetime_bound;
3730

3831
private:
3932
// Disallow copy.
@@ -106,19 +99,17 @@ class URLPattern {
10699
bool test(std::optional<Input> input,
107100
std::optional<std::string_view> base_url);
108101

109-
// TODO(anonrig): Move these to `url_pattern-inl.h`.
110-
const Component& get_protocol() const ada_lifetime_bound { return protocol; }
111-
const Component& get_username() const ada_lifetime_bound { return username; }
112-
const Component& get_password() const ada_lifetime_bound { return password; }
113-
const Component& get_port() const ada_lifetime_bound { return port; }
114-
const Component& get_pathname() const ada_lifetime_bound { return pathname; }
115-
const Component& get_search() const ada_lifetime_bound { return search; }
116-
const Component& get_hash() const ada_lifetime_bound { return hash; }
102+
const Component& get_protocol() const ada_lifetime_bound;
103+
const Component& get_username() const ada_lifetime_bound;
104+
const Component& get_password() const ada_lifetime_bound;
105+
const Component& get_port() const ada_lifetime_bound;
106+
const Component& get_pathname() const ada_lifetime_bound;
107+
const Component& get_search() const ada_lifetime_bound;
108+
const Component& get_hash() const ada_lifetime_bound;
117109

118110
// If ignoreCase is true, the JavaScript regular expression created for each
119111
// pattern must use the `vi` flag. Otherwise, they must use the `v` flag.
120-
// TODO(anonrig): Move these to `url_pattern-inl.h`.
121-
bool case_ignored() const ada_lifetime_bound { return ignore_case; }
112+
bool case_ignored() const ada_lifetime_bound;
122113

123114
private:
124115
Component protocol;

0 commit comments

Comments
 (0)