MCPcopy Create free account
hub / github.com/FastLED/FastLED / url

Class url

src/fl/stl/url.h:15–244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13namespace fl {
14
15class url {
16 public:
17 url() FL_NOEXCEPT : mValid(false), mRepaired(false) { zeroOffsets(); }
18
19 explicit url(const char *url) FL_NOEXCEPT
20 : mUrl(url), mValid(false), mRepaired(false) {
21 zeroOffsets();
22 parse();
23 }
24
25 explicit url(const fl::string &u) FL_NOEXCEPT
26 : mUrl(u), mValid(false), mRepaired(false) {
27 zeroOffsets();
28 parse();
29 }
30
31 explicit url(fl::string_view url) FL_NOEXCEPT
32 : mUrl(url.data(), url.size()), mValid(false), mRepaired(false) {
33 zeroOffsets();
34 parse();
35 }
36
37 bool isValid() const FL_NOEXCEPT { return mValid; }
38 explicit operator bool() const FL_NOEXCEPT { return mValid; }
39
40 /// True if the URL was missing a scheme and "https://" was assumed.
41 bool wasRepaired() const FL_NOEXCEPT { return mRepaired; }
42
43 // ---- Component accessors (return views into mUrl) ----
44 fl::string_view scheme() const FL_NOEXCEPT { return view(mScheme); }
45 fl::string_view userinfo() const FL_NOEXCEPT { return view(mUserinfo); }
46 fl::string_view host() const FL_NOEXCEPT { return view(mHost); }
47 fl::string_view port_str() const FL_NOEXCEPT { return view(mPort); }
48 fl::string_view path() const FL_NOEXCEPT { return view(mPath); }
49 fl::string_view query() const FL_NOEXCEPT { return view(mQuery); }
50 fl::string_view fragment() const FL_NOEXCEPT { return view(mFragment); }
51 fl::string_view authority() const FL_NOEXCEPT { return view(mAuthority); }
52
53 /// Numeric port. Returns the explicit port if present, otherwise the
54 /// well-known default for the scheme (80 for http, 443 for https, etc.).
55 fl::u16 port() const FL_NOEXCEPT {
56 fl::string_view p = port_str();
57 if (p.empty()) {
58 return defaultPort();
59 }
60 fl::u16 result = 0;
61 for (fl::size i = 0; i < p.size(); ++i) {
62 result = static_cast<fl::u16>(result * 10 +
63 static_cast<fl::u16>(p[i] - '0'));
64 }
65 return result;
66 }
67
68 // ---- Whole-URL access ----
69 fl::string_view str() const FL_NOEXCEPT {
70 return fl::string_view(mUrl.c_str(), mUrl.size());
71 }
72 const fl::string &string() const FL_NOEXCEPT { return mUrl; }

Callers 7

parse_lnkFunction · 0.85
parse_lnk_with_metadataFunction · 0.85
lookup_registryFunction · 0.85
resolve_hostFunction · 0.85
resolve_assetFunction · 0.85
FL_TEST_FILEFunction · 0.85
FL_TEST_FILEFunction · 0.85

Calls 7

stringClass · 0.70
string_viewClass · 0.70
emptyMethod · 0.45
c_strMethod · 0.45
sizeMethod · 0.45
findMethod · 0.45
substrMethod · 0.45

Tested by

no test coverage detected