ignore_case.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. //
  2. // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // Official repository: https://github.com/boostorg/url
  8. //
  9. #ifndef BOOST_URL_IGNORE_CASE_HPP
  10. #define BOOST_URL_IGNORE_CASE_HPP
  11. #include <boost/url/detail/config.hpp>
  12. namespace boost {
  13. namespace urls {
  14. #ifndef BOOST_URL_DOCS
  15. struct ignore_case_t
  16. {
  17. };
  18. #endif
  19. /** Ignore case when comparing
  20. This value may be optionally passed to
  21. functions accepting a parameter of type
  22. @ref ignore_case_param to indicate that
  23. comparisons should be case-insensitive.
  24. */
  25. constexpr
  26. #ifdef BOOST_URL_DOCS
  27. __implementation_defined__
  28. #else
  29. ignore_case_t
  30. #endif
  31. ignore_case{};
  32. /** An optional parameter to determine case-sensitivity
  33. Functions may use parameters of this type
  34. to allow the user to optionally indicate
  35. that comparisons should be case-insensitive
  36. when the value @ref ignore_case is passed.
  37. */
  38. class ignore_case_param
  39. {
  40. /** True if an algorithm should ignore case
  41. Functions accepting a parameter of type
  42. `ignore_case_param` can check `value`
  43. to determine if the caller has indicated
  44. that comparisons should ignore case.
  45. */
  46. bool value_ = false;
  47. public:
  48. /** Constructor
  49. By default, comparisons are
  50. case-sensitive.
  51. @par Example
  52. This function performs case-sensitive
  53. comparisons when called with no
  54. arguments:
  55. @code
  56. void f( ignore_case_param = {} );
  57. @endcode
  58. */
  59. constexpr
  60. ignore_case_param() noexcept = default;
  61. /** Constructor
  62. Construction from @ref ignore_case
  63. indicates that comparisons should
  64. be case-insensitive.
  65. @par Example
  66. When @ref ignore_case is passed as
  67. an argument, this function ignores
  68. case when performing comparisons:
  69. @code
  70. void f( ignore_case_param = {} );
  71. @endcode
  72. */
  73. constexpr
  74. ignore_case_param(
  75. #ifdef BOOST_URL_DOCS
  76. __implementation_defined__
  77. #else
  78. ignore_case_t
  79. #endif
  80. ) noexcept
  81. : value_(true)
  82. {
  83. }
  84. /** True if an algorithm should ignore case
  85. Values of type `ignore_case_param`
  86. evaluate to true when constructed
  87. with the constant @ref ignore_case.
  88. Otherwise, they are default-constructed
  89. and evaluate to `false`.
  90. */
  91. operator
  92. bool() const noexcept
  93. {
  94. return value_;
  95. }
  96. };
  97. } // urls
  98. } // boost
  99. #endif