File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -416,6 +416,12 @@ class uri {
416
416
*/
417
417
std::u32string u32string () const ;
418
418
419
+ /* *
420
+ * \brief Returns the URI as a string_view object.
421
+ * \returns A URI string view.
422
+ */
423
+ string_view view () const noexcept ;
424
+
419
425
/* *
420
426
* \brief Checks if the uri object is empty, i.e. it has no parts.
421
427
* \returns \c true if there are no parts, \c false otherwise.
Original file line number Diff line number Diff line change @@ -446,6 +446,10 @@ std::u32string uri::u32string() const {
446
446
return std::u32string (std::begin (*this ), std::end (*this ));
447
447
}
448
448
449
+ uri::string_view uri::view () const noexcept {
450
+ return uri_view_;
451
+ }
452
+
449
453
bool uri::empty () const noexcept { return uri_.empty (); }
450
454
451
455
bool uri::is_absolute () const noexcept { return has_scheme (); }
@@ -685,18 +689,15 @@ bool uri::initialize(const string_type &uri) {
685
689
void swap (uri &lhs, uri &rhs) noexcept { lhs.swap (rhs); }
686
690
687
691
bool operator ==(const uri &lhs, const uri &rhs) noexcept {
688
- return lhs.compare (rhs, uri_comparison_level::syntax_based ) == 0 ;
692
+ return lhs.view ( ) == rhs. view () ;
689
693
}
690
694
691
695
bool operator ==(const uri &lhs, const char *rhs) noexcept {
692
- if (std::strlen (rhs) !=
693
- std::size_t (std::distance (std::begin (lhs), std::end (lhs)))) {
694
- return false ;
695
- }
696
- return std::equal (std::begin (lhs), std::end (lhs), rhs);
696
+ return lhs.view () == string_view{rhs};
697
697
}
698
698
699
699
bool operator <(const uri &lhs, const uri &rhs) noexcept {
700
- return lhs.compare (rhs, uri_comparison_level::syntax_based ) < 0 ;
700
+ return lhs.view ( ) < rhs. view () ;
701
701
}
702
+
702
703
} // namespace network
You can’t perform that action at this time.
0 commit comments