Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:52:42

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_ENCODING_OPTS_HPP
0012 #define BOOST_URL_ENCODING_OPTS_HPP
0013 
0014 #include <boost/url/detail/config.hpp>
0015 
0016 namespace boost {
0017 namespace urls {
0018 
0019 /** Percent-encoding options
0020 
0021     These options are used to customize
0022     the behavior of algorithms which use
0023     percent escapes, such as encoding
0024     or decoding.
0025 
0026     @see
0027         @ref encode,
0028         @ref encoded_size,
0029         @ref pct_string_view.
0030 */
0031 struct encoding_opts
0032 {
0033     /** True if spaces encode to and from plus signs
0034 
0035         This option controls whether or not
0036         the PLUS character ("+") is used to
0037         represent the SP character (" ") when
0038         encoding or decoding.
0039         Although not prescribed by the RFC, plus
0040         signs are commonly treated as spaces upon
0041         decoding when used in the query of URLs
0042         using well known schemes such as HTTP.
0043 
0044         @par Specification
0045         @li <a href="https://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1">
0046             application/x-www-form-urlencoded (w3.org)</a>
0047     */
0048     bool space_as_plus = false;
0049 
0050     /** True if hexadecimal digits are emitted as lower case
0051 
0052         By default, percent-encoding algorithms
0053         emit hexadecimal digits A through F as
0054         uppercase letters. When this option is
0055         `true`, lowercase letters are used.
0056     */
0057     bool lower_case = false;
0058 
0059     /** True if nulls are not allowed
0060 
0061         Normally all possible character values
0062         (from 0 to 255) are allowed, with reserved
0063         characters being replaced with escapes
0064         upon encoding. When this option is true,
0065         attempting to decode a null will result
0066         in an error.
0067     */
0068     bool disallow_null = false;
0069 
0070     /** Constructs an `encoding_opts` object with the specified options.
0071 
0072         @param space_as_plus If true, spaces will be encoded as plus signs.
0073         @param lower_case If true, hexadecimal digits will be emitted as lower case.
0074         @param disallow_null If true, null characters will not be allowed.
0075      */
0076     BOOST_CXX14_CONSTEXPR
0077     inline
0078     encoding_opts(
0079         bool const space_as_plus = false,
0080         bool const lower_case = false,
0081         bool const disallow_null = false) noexcept
0082         : space_as_plus(space_as_plus)
0083         , lower_case(lower_case)
0084         , disallow_null(disallow_null) {}
0085 };
0086 
0087 } // urls
0088 } // boost
0089 
0090 #endif