diff --git a/include/boost/url/url_base.hpp b/include/boost/url/url_base.hpp index 9873dfb0..2bff0966 100644 --- a/include/boost/url/url_base.hpp +++ b/include/boost/url/url_base.hpp @@ -105,7 +105,16 @@ public: // //-------------------------------------------- - /** Return the encoded URL as a null-terminated string + /** Return the url as a null-terminated string + + This function returns a pointer to a null + terminated string representing the url, + which may contain percent escapes. + + @par Example + @code + assert( std::strlen( url( "http://www.example.com" ).c_str() ) == 22 ); + @endcode @par Complexity Constant. @@ -283,11 +292,13 @@ public: @par Exception Safety Strong guarantee. Calls to allocate may throw. + Exceptions thrown on invalid input. + + @throw system_error + The scheme is invalid. @param id The scheme to set. - @throw std::invalid_argument invalid scheme. - @par Specification @li 3.1. Scheme (rfc3986) @@ -364,6 +375,11 @@ public: Calls to allocate may throw. Exceptions thrown on invalid input. + @throw system_eror + The string contains an invalid percent-encoding. + + @param s The authority string to set. + @par BNF @code authority = [ userinfo "@" ] host [ ":" port ] @@ -376,11 +392,6 @@ public: @par Specification @li 3.2. Authority (rfc3986) - - @throw system_eror `s` contains an invalid percent-encoding. - - @param s The authority string to set. - @see @ref remove_authority. */ @@ -685,7 +696,7 @@ public: @par Example @code - assert( url( "http://user:pass@example.com" ).remove_password().encoded_authority() == "user@example.com" ); + assert( url( "http://user:pass@example.com" ).remove_password().authority().buffer() == "user@example.com" ); @endcode @par Postconditions @@ -1261,7 +1272,7 @@ public: @par Example @code - assert( url().set_host_address( ipv6_address( "1::6:c0a8:1" ) ).encoded_authority() == "[1::6:c0a8:1]" ); + assert( url().set_host_address( ipv6_address( "1::6:c0a8:1" ) ).authority().buffer() == "[1::6:c0a8:1]" ); @endcode @par Postconditions @@ -1475,7 +1486,7 @@ public: @par Example @code - assert( url( "http://www.example.com:80" ).remove_port().encoded_authority() == "www.example.com" ); + assert( url( "http://www.example.com:80" ).remove_port().authority().buffer() == "www.example.com" ); @endcode @par Postconditions @@ -1513,7 +1524,7 @@ public: @par Example @code - assert( url( "http://www.example.com" ).set_port( 8080 ).encoded_authority() == "www.example.com:8080" ); + assert( url( "http://www.example.com" ).set_port( 8080 ).authority().buffer() == "www.example.com:8080" ); @endcode @par Postconditions @@ -1558,7 +1569,7 @@ public: @par Example @code - assert( url( "http://www.example.com" ).set_port( "8080" ).encoded_authority() == "www.example.com:8080" ); + assert( url( "http://www.example.com" ).set_port( "8080" ).authority().buffer() == "www.example.com:8080" ); @endcode @par Postconditions diff --git a/include/boost/url/url_view_base.hpp b/include/boost/url/url_view_base.hpp index 785f991e..3ed025ae 100644 --- a/include/boost/url/url_view_base.hpp +++ b/include/boost/url/url_view_base.hpp @@ -66,17 +66,17 @@ class BOOST_SYMBOL_VISIBLE friend class url_view; friend class static_url_base; friend class params_base; - friend class params_view; - friend class params_encoded_view; friend class params_encoded_base; friend class params_encoded_ref; + friend class params_encoded_view; friend class params_ref; + friend class params_view; friend class segments_base; - friend class segments_view; - friend class segments_encoded_view; friend class segments_encoded_base; friend class segments_encoded_ref; + friend class segments_encoded_view; friend class segments_ref; + friend class segments_view; struct shared_impl; @@ -182,7 +182,7 @@ public: bool empty() const noexcept { - return size() == 0; + return u_.offset(id_end) == 0; } /** Return a pointer to the URL's character buffer @@ -206,8 +206,12 @@ public: /** Return the URL string This function returns the entire URL, - with any percent-escaped characters - preserved. + which main contain percent escapes. + + @par Example + @code + assert( url_view( "http://www.example.com" ).buffer() == "http://www.example.com" ); + @endcode @par Complexity Constant. @@ -460,6 +464,9 @@ public: authority_view a = url_view( "https://www.example.com:8080/index.htm" ).authority(); @endcode + @par Complexity + Constant. + @par Exception Safety Throws nothing.