Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:02:05

0001 //
0002 // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
0003 // Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
0004 //
0005 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0006 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 //
0008 // Official repository: https://github.com/boostorg/url
0009 //
0010 
0011 #ifndef BOOST_URL_PARSE_HPP
0012 #define BOOST_URL_PARSE_HPP
0013 
0014 #include <boost/url/detail/config.hpp>
0015 #include <boost/url/error_types.hpp>
0016 #include <boost/url/url_view.hpp>
0017 
0018 namespace boost {
0019 namespace urls {
0020 
0021 /** Return a reference to a parsed URL string
0022 
0023     This function parses a string according
0024     to the grammar below and returns a view
0025     referencing the passed string upon success,
0026     else returns an error.
0027     Ownership of the string is not transferred;
0028     the caller is responsible for ensuring that
0029     the lifetime of the character buffer extends
0030     until the view is no longer being accessed.
0031 
0032     @par Example
0033     @code
0034     system::result< url_view > rv = parse_absolute_uri( "http://example.com/index.htm?id=1" );
0035     @endcode
0036 
0037     @par BNF
0038     @code
0039     absolute-URI    = scheme ":" hier-part [ "?" query ]
0040 
0041     hier-part       = "//" authority path-abempty
0042                     / path-absolute
0043                     / path-rootless
0044                     / path-empty
0045     @endcode
0046 
0047     @throw std::length_error `s.size() > url_view::max_size`
0048 
0049     @return A @ref result containing a value or an error
0050 
0051     @param s The string to parse
0052 
0053     @par Specification
0054     @li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-4.3"
0055         >4.3. Absolute URI (rfc3986)</a>
0056 
0057     @see
0058         @ref parse_origin_form,
0059         @ref parse_relative_ref,
0060         @ref parse_uri,
0061         @ref parse_uri_reference,
0062         @ref url_view.
0063 */
0064 BOOST_URL_DECL
0065 system::result<url_view>
0066 parse_absolute_uri(
0067     core::string_view s);
0068 
0069 //------------------------------------------------
0070 
0071 /** Return a reference to a parsed URL string
0072 
0073     This function parses a string according
0074     to the grammar below and returns a view
0075     referencing the passed string upon success,
0076     else returns an error.
0077     Ownership of the string is not transferred;
0078     the caller is responsible for ensuring that
0079     the lifetime of the character buffer extends
0080     until the view is no longer being accessed.
0081 
0082     @par Example
0083     @code
0084     system::result< url_view > = parse_origin_form( "/index.htm?layout=mobile" );
0085     @endcode
0086 
0087     @par BNF
0088     @code
0089     origin-form    = absolute-path [ "?" query ]
0090 
0091     absolute-path = 1*( "/" segment )
0092     @endcode
0093 
0094     @throw std::length_error `s.size() > url_view::max_size`
0095 
0096     @return A @ref result containing a value or an error
0097 
0098     @param s The string to parse
0099 
0100     @par Specification
0101     @li <a href="https://datatracker.ietf.org/doc/html/rfc7230#section-5.3.1"
0102         >5.3.1.  origin-form (rfc7230)</a>
0103 
0104     @see
0105         @ref parse_absolute_uri,
0106         @ref parse_relative_ref,
0107         @ref parse_uri,
0108         @ref parse_uri_reference,
0109         @ref url_view.
0110 */
0111 BOOST_URL_DECL
0112 system::result<url_view>
0113 parse_origin_form(
0114     core::string_view s);
0115 
0116 //------------------------------------------------
0117 
0118 /** Return a reference to a parsed URL string
0119 
0120     This function parses a string according
0121     to the grammar below and returns a view
0122     referencing the passed string upon success,
0123     else returns an error.
0124     Ownership of the string is not transferred;
0125     the caller is responsible for ensuring that
0126     the lifetime of the character buffer extends
0127     until the view is no longer being accessed.
0128 
0129     @par Example
0130     @code
0131     system::result< url_view > = parse_relative_ref( "images/dot.gif?v=hide#a" );
0132     @endcode
0133 
0134     @par BNF
0135     @code
0136     relative-ref  = relative-part [ "?" query ] [ "#" fragment ]
0137 
0138     relative-part = "//" authority path-abempty
0139                   / path-absolute
0140                   / path-noscheme
0141                   / path-abempty
0142                   / path-empty
0143     @endcode
0144 
0145     @return A @ref result containing a value or an error
0146 
0147     @param s The string to parse
0148 
0149     @throw std::length_error `s.size() > url_view::max_size`
0150 
0151     @par Specification
0152     @li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-4.2"
0153         >4.2. Relative Reference (rfc3986)</a>
0154     @li <a href="https://www.rfc-editor.org/errata/eid5428"
0155         >Errata ID: 5428 (rfc3986)</a>
0156 
0157     @see
0158         @ref parse_absolute_uri,
0159         @ref parse_origin_form,
0160         @ref parse_uri,
0161         @ref parse_uri_reference,
0162         @ref url_view.
0163 */
0164 BOOST_URL_DECL
0165 system::result<url_view>
0166 parse_relative_ref(
0167     core::string_view s);
0168 
0169 //------------------------------------------------
0170 
0171 /** Return a reference to a parsed URL string
0172 
0173     This function parses a string according
0174     to the grammar below and returns a view
0175     referencing the passed string upon success,
0176     else returns an error.
0177     Ownership of the string is not transferred;
0178     the caller is responsible for ensuring that
0179     the lifetime of the character buffer extends
0180     until the view is no longer being accessed.
0181 
0182     @par Example
0183     @code
0184     system::result< url_view > = parse_uri( "https://www.example.com/index.htm?id=guest#s1" );
0185     @endcode
0186 
0187     @par BNF
0188     @code
0189     URI           = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
0190 
0191     hier-part     = "//" authority path-abempty
0192                   / path-absolute
0193                   / path-rootless
0194                   / path-empty
0195     @endcode
0196 
0197     @throw std::length_error `s.size() > url_view::max_size`
0198 
0199     @return A @ref result containing a value or an error
0200 
0201     @param s The string to parse
0202 
0203     @par Specification
0204     @li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-3"
0205         >3. Syntax Components (rfc3986)</a>
0206 
0207     @see
0208         @ref parse_absolute_uri,
0209         @ref parse_origin_form,
0210         @ref parse_relative_ref,
0211         @ref parse_uri_reference,
0212         @ref url_view.
0213 */
0214 BOOST_URL_DECL
0215 system::result<url_view>
0216 parse_uri(
0217     core::string_view s);
0218 
0219 //------------------------------------------------
0220 
0221 /** Return a reference to a parsed URL string
0222 
0223     This function parses a string according
0224     to the grammar below and returns a view
0225     referencing the passed string upon success,
0226     else returns an error.
0227     Ownership of the string is not transferred;
0228     the caller is responsible for ensuring that
0229     the lifetime of the character buffer extends
0230     until the view is no longer being accessed.
0231 
0232     @par Example
0233     @code
0234     system::result< url_view > = parse_uri_reference( "ws://echo.example.com/?name=boost#demo" );
0235     @endcode
0236 
0237     @par BNF
0238     @code
0239     URI-reference = URI / relative-ref
0240 
0241     URI           = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
0242 
0243     relative-ref  = relative-part [ "?" query ] [ "#" fragment ]
0244 
0245     hier-part     = "//" authority path-abempty
0246                   / path-absolute
0247                   / path-rootless
0248                   / path-empty
0249 
0250     relative-part = "//" authority path-abempty
0251                   / path-absolute
0252                   / path-noscheme
0253                   / path-abempty
0254                   / path-empty
0255     @endcode
0256 
0257     @throw std::length_error `s.size() > url_view::max_size`
0258 
0259     @return A @ref result containing a value or an error
0260 
0261     @param s The string to parse
0262 
0263     @par Specification
0264     @li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-4.1"
0265         >4.1. URI Reference (rfc3986)</a>
0266     @li <a href="https://www.rfc-editor.org/errata/eid5428"
0267         >Errata ID: 5428 (rfc3986)</a>
0268 
0269     @see
0270         @ref parse_absolute_uri,
0271         @ref parse_origin_form,
0272         @ref parse_relative_ref,
0273         @ref parse_uri,
0274         @ref url_view.
0275 */
0276 BOOST_URL_DECL
0277 system::result<url_view>
0278 parse_uri_reference(
0279     core::string_view s);
0280 
0281 } // url
0282 } // boost
0283 
0284 #endif