Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 08:53:59

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     @par Specification
0050     @li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-4.3"
0051         >4.3. Absolute URI (rfc3986)</a>
0052 
0053     @see
0054         @ref parse_origin_form,
0055         @ref parse_relative_ref,
0056         @ref parse_uri,
0057         @ref parse_uri_reference,
0058         @ref url_view.
0059 
0060     @param s The string to parse
0061     @return A view to the parsed URL
0062 */
0063 BOOST_URL_DECL
0064 system::result<url_view>
0065 parse_absolute_uri(
0066     core::string_view s);
0067 
0068 //------------------------------------------------
0069 
0070 /** Return a reference to a parsed URL string
0071 
0072     This function parses a string according
0073     to the grammar below and returns a view
0074     referencing the passed string upon success,
0075     else returns an error.
0076     Ownership of the string is not transferred;
0077     the caller is responsible for ensuring that
0078     the lifetime of the character buffer extends
0079     until the view is no longer being accessed.
0080 
0081     @par Example
0082     @code
0083     system::result< url_view > = parse_origin_form( "/index.htm?layout=mobile" );
0084     @endcode
0085 
0086     @par BNF
0087     @code
0088     origin-form    = absolute-path [ "?" query ]
0089 
0090     absolute-path = 1*( "/" segment )
0091     @endcode
0092 
0093     @throw std::length_error `s.size() > url_view::max_size`
0094 
0095     @par Specification
0096     @li <a href="https://datatracker.ietf.org/doc/html/rfc7230#section-5.3.1"
0097         >5.3.1.  origin-form (rfc7230)</a>
0098 
0099     @see
0100         @ref parse_absolute_uri,
0101         @ref parse_relative_ref,
0102         @ref parse_uri,
0103         @ref parse_uri_reference,
0104         @ref url_view.
0105 
0106     @param s The string to parse
0107     @return A view to the parsed URL
0108 */
0109 BOOST_URL_DECL
0110 system::result<url_view>
0111 parse_origin_form(
0112     core::string_view s);
0113 
0114 //------------------------------------------------
0115 
0116 /** Return a reference to a parsed URL string
0117 
0118     This function parses a string according
0119     to the grammar below and returns a view
0120     referencing the passed string upon success,
0121     else returns an error.
0122     Ownership of the string is not transferred;
0123     the caller is responsible for ensuring that
0124     the lifetime of the character buffer extends
0125     until the view is no longer being accessed.
0126 
0127     @par Example
0128     @code
0129     system::result< url_view > = parse_relative_ref( "images/dot.gif?v=hide#a" );
0130     @endcode
0131 
0132     @par BNF
0133     @code
0134     relative-ref  = relative-part [ "?" query ] [ "#" fragment ]
0135 
0136     relative-part = "//" authority path-abempty
0137                   / path-absolute
0138                   / path-noscheme
0139                   / path-abempty
0140                   / path-empty
0141     @endcode
0142 
0143     @throw std::length_error `s.size() > url_view::max_size`
0144 
0145     @par Specification
0146     @li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-4.2"
0147         >4.2. Relative Reference (rfc3986)</a>
0148     @li <a href="https://www.rfc-editor.org/errata/eid5428"
0149         >Errata ID: 5428 (rfc3986)</a>
0150 
0151     @see
0152         @ref parse_absolute_uri,
0153         @ref parse_origin_form,
0154         @ref parse_uri,
0155         @ref parse_uri_reference,
0156         @ref url_view.
0157 
0158     @param s The string to parse
0159     @return A view to the parsed URL
0160 */
0161 BOOST_URL_DECL
0162 system::result<url_view>
0163 parse_relative_ref(
0164     core::string_view s);
0165 
0166 //------------------------------------------------
0167 
0168 /** Return a reference to a parsed URL string
0169 
0170     This function parses a string according
0171     to the grammar below and returns a view
0172     referencing the passed string upon success,
0173     else returns an error.
0174     Ownership of the string is not transferred;
0175     the caller is responsible for ensuring that
0176     the lifetime of the character buffer extends
0177     until the view is no longer being accessed.
0178 
0179     @par Example
0180     @code
0181     system::result< url_view > = parse_uri( "https://www.example.com/index.htm?id=guest#s1" );
0182     @endcode
0183 
0184     @par BNF
0185     @code
0186     URI           = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
0187 
0188     hier-part     = "//" authority path-abempty
0189                   / path-absolute
0190                   / path-rootless
0191                   / path-empty
0192     @endcode
0193 
0194     @throw std::length_error `s.size() > url_view::max_size`
0195 
0196     @par Specification
0197     @li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-3"
0198         >3. Syntax Components (rfc3986)</a>
0199 
0200     @see
0201         @ref parse_absolute_uri,
0202         @ref parse_origin_form,
0203         @ref parse_relative_ref,
0204         @ref parse_uri_reference,
0205         @ref url_view.
0206 
0207     @param s The string to parse
0208     @return A `boost::system::result` containing a value or an error
0209 */
0210 BOOST_URL_DECL
0211 system::result<url_view>
0212 parse_uri(
0213     core::string_view s);
0214 
0215 //------------------------------------------------
0216 
0217 /** Return a reference to a parsed URL string
0218 
0219     This function parses a string according
0220     to the grammar below and returns a view
0221     referencing the passed string upon success,
0222     else returns an error.
0223     Ownership of the string is not transferred;
0224     the caller is responsible for ensuring that
0225     the lifetime of the character buffer extends
0226     until the view is no longer being accessed.
0227 
0228     @par Example
0229     @code
0230     system::result< url_view > = parse_uri_reference( "ws://echo.example.com/?name=boost#demo" );
0231     @endcode
0232 
0233     @par BNF
0234     @code
0235     URI-reference = URI / relative-ref
0236 
0237     URI           = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
0238 
0239     relative-ref  = relative-part [ "?" query ] [ "#" fragment ]
0240 
0241     hier-part     = "//" authority path-abempty
0242                   / path-absolute
0243                   / path-rootless
0244                   / path-empty
0245 
0246     relative-part = "//" authority path-abempty
0247                   / path-absolute
0248                   / path-noscheme
0249                   / path-abempty
0250                   / path-empty
0251     @endcode
0252 
0253     @throw std::length_error `s.size() > url_view::max_size`
0254 
0255     @par Specification
0256     @li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-4.1"
0257         >4.1. URI Reference (rfc3986)</a>
0258     @li <a href="https://www.rfc-editor.org/errata/eid5428"
0259         >Errata ID: 5428 (rfc3986)</a>
0260 
0261     @see
0262         @ref parse_absolute_uri,
0263         @ref parse_origin_form,
0264         @ref parse_relative_ref,
0265         @ref parse_uri,
0266         @ref url_view.
0267 
0268     @param s The string to parse
0269     @return A view to the parsed URL
0270 */
0271 BOOST_URL_DECL
0272 system::result<url_view>
0273 parse_uri_reference(
0274     core::string_view s);
0275 
0276 } // url
0277 } // boost
0278 
0279 #endif