encoding_opts.hpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //
  2. // Copyright (c) 2019 Vinnie Falco ([email protected])
  3. // Copyright (c) 2022 Alan de Freitas ([email protected])
  4. //
  5. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  6. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. //
  8. // Official repository: https://github.com/boostorg/url
  9. //
  10. #ifndef BOOST_URL_ENCODING_OPTS_HPP
  11. #define BOOST_URL_ENCODING_OPTS_HPP
  12. #include <boost/url/detail/config.hpp>
  13. namespace boost {
  14. namespace urls {
  15. /** Percent-encoding options
  16. These options are used to customize
  17. the behavior of algorithms which use
  18. percent escapes, such as encoding
  19. or decoding.
  20. @see
  21. @ref encode,
  22. @ref encoded_size,
  23. @ref pct_string_view.
  24. */
  25. struct BOOST_URL_DECL encoding_opts
  26. {
  27. /** True if spaces encode to and from plus signs
  28. This option controls whether or not
  29. the PLUS character ("+") is used to
  30. represent the SP character (" ") when
  31. encoding or decoding.
  32. Although not prescribed by the RFC, plus
  33. signs are commonly treated as spaces upon
  34. decoding when used in the query of URLs
  35. using well known schemes such as HTTP.
  36. @par Specification
  37. @li <a href="https://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1">
  38. application/x-www-form-urlencoded (w3.org)</a>
  39. */
  40. bool space_as_plus = false;
  41. /** True if hexadecimal digits are emitted as lower case
  42. By default, percent-encoding algorithms
  43. emit hexadecimal digits A through F as
  44. uppercase letters. When this option is
  45. `true`, lowercase letters are used.
  46. */
  47. bool lower_case = false;
  48. /** True if nulls are not allowed
  49. Normally all possible character values
  50. (from 0 to 255) are allowed, with reserved
  51. characters being replaced with escapes
  52. upon encoding. When this option is true,
  53. attempting to decode a null will result
  54. in an error.
  55. */
  56. bool disallow_null = false;
  57. #ifndef BOOST_URL_DOCS
  58. encoding_opts(
  59. bool space_as_plus_ = false,
  60. bool lower_case_ = false,
  61. bool disallow_null_ = false) noexcept;
  62. #endif
  63. };
  64. } // urls
  65. } // boost
  66. #endif