| Line | Branch | Exec | Source |
|---|---|---|---|
| 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 | |||
| 10 | #ifndef BOOST_URL_IGNORE_CASE_HPP | ||
| 11 | #define BOOST_URL_IGNORE_CASE_HPP | ||
| 12 | |||
| 13 | #include <boost/url/detail/config.hpp> | ||
| 14 | |||
| 15 | namespace boost { | ||
| 16 | namespace urls { | ||
| 17 | |||
| 18 | namespace implementation_defined { | ||
| 19 | struct ignore_case_t {}; | ||
| 20 | } | ||
| 21 | |||
| 22 | /** Ignore case when comparing | ||
| 23 | |||
| 24 | This value may be optionally passed to | ||
| 25 | functions accepting a parameter of type | ||
| 26 | @ref ignore_case_param to indicate that | ||
| 27 | comparisons should be case-insensitive. | ||
| 28 | */ | ||
| 29 | BOOST_INLINE_CONSTEXPR | ||
| 30 | implementation_defined::ignore_case_t | ||
| 31 | ignore_case{}; | ||
| 32 | |||
| 33 | /** An optional parameter to determine case-sensitivity | ||
| 34 | |||
| 35 | Functions may use parameters of this type | ||
| 36 | to allow the user to optionally indicate | ||
| 37 | that comparisons should be case-insensitive | ||
| 38 | when the value @ref ignore_case is passed. | ||
| 39 | |||
| 40 | @see | ||
| 41 | @ref params_ref | ||
| 42 | */ | ||
| 43 | class ignore_case_param | ||
| 44 | { | ||
| 45 | /** True if an algorithm should ignore case | ||
| 46 | |||
| 47 | Functions accepting a parameter of type | ||
| 48 | `ignore_case_param` can check `value` | ||
| 49 | to determine if the caller has indicated | ||
| 50 | that comparisons should ignore case. | ||
| 51 | */ | ||
| 52 | bool value_ = false; | ||
| 53 | |||
| 54 | public: | ||
| 55 | /** Constructor | ||
| 56 | |||
| 57 | By default, comparisons are | ||
| 58 | case-sensitive. | ||
| 59 | |||
| 60 | @par Example | ||
| 61 | This function performs case-sensitive | ||
| 62 | comparisons when called with no | ||
| 63 | arguments: | ||
| 64 | @code | ||
| 65 | void f( ignore_case_param = {} ); | ||
| 66 | @endcode | ||
| 67 | */ | ||
| 68 | constexpr | ||
| 69 | 101 | ignore_case_param() noexcept = default; | |
| 70 | |||
| 71 | /** Constructor | ||
| 72 | |||
| 73 | Construction from @ref ignore_case | ||
| 74 | indicates that comparisons should | ||
| 75 | be case-insensitive. | ||
| 76 | |||
| 77 | The first parameter to this function | ||
| 78 | should be the variable | ||
| 79 | @ref ignore_case. | ||
| 80 | |||
| 81 | @par Example | ||
| 82 | When @ref ignore_case is passed as | ||
| 83 | an argument, this function ignores | ||
| 84 | case when performing comparisons: | ||
| 85 | @code | ||
| 86 | void f( ignore_case_param(ignore_case) ); | ||
| 87 | @endcode | ||
| 88 | */ | ||
| 89 | constexpr | ||
| 90 | 54 | ignore_case_param( | |
| 91 | implementation_defined::ignore_case_t) noexcept | ||
| 92 | 54 | : value_(true) | |
| 93 | { | ||
| 94 | 54 | } | |
| 95 | |||
| 96 | /** True if an algorithm should ignore case | ||
| 97 | |||
| 98 | Values of type `ignore_case_param` | ||
| 99 | evaluate to true when constructed | ||
| 100 | with the constant @ref ignore_case. | ||
| 101 | Otherwise, they are default-constructed | ||
| 102 | and evaluate to `false`. | ||
| 103 | |||
| 104 | @return `true` if case should be ignored | ||
| 105 | */ | ||
| 106 | 224 | operator | |
| 107 | bool() const noexcept | ||
| 108 | { | ||
| 109 | 224 | return value_; | |
| 110 | } | ||
| 111 | }; | ||
| 112 | |||
| 113 | } // urls | ||
| 114 | } // boost | ||
| 115 | |||
| 116 | #endif | ||
| 117 |