Line data Source code
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 : #ifndef BOOST_URL_DOCS
19 : struct ignore_case_t
20 : {
21 : };
22 : #endif
23 :
24 : /** Ignore case when comparing
25 :
26 : This value may be optionally passed to
27 : functions accepting a parameter of type
28 : @ref ignore_case_param to indicate that
29 : comparisons should be case-insensitive.
30 : */
31 : constexpr
32 : BOOST_URL_IMPLEMENTATION_DEFINED(ignore_case_t)
33 : ignore_case{};
34 :
35 : /** An optional parameter to determine case-sensitivity
36 :
37 : Functions may use parameters of this type
38 : to allow the user to optionally indicate
39 : that comparisons should be case-insensitive
40 : when the value @ref ignore_case is passed.
41 : */
42 : class ignore_case_param
43 : {
44 : /** True if an algorithm should ignore case
45 :
46 : Functions accepting a parameter of type
47 : `ignore_case_param` can check `value`
48 : to determine if the caller has indicated
49 : that comparisons should ignore case.
50 : */
51 : bool value_ = false;
52 :
53 : public:
54 : /** Constructor
55 :
56 : By default, comparisons are
57 : case-sensitive.
58 :
59 : @par Example
60 : This function performs case-sensitive
61 : comparisons when called with no
62 : arguments:
63 : @code
64 : void f( ignore_case_param = {} );
65 : @endcode
66 : */
67 : constexpr
68 101 : ignore_case_param() noexcept = default;
69 :
70 : /** Constructor
71 :
72 : Construction from @ref ignore_case
73 : indicates that comparisons should
74 : be case-insensitive.
75 :
76 : @par Example
77 : When @ref ignore_case is passed as
78 : an argument, this function ignores
79 : case when performing comparisons:
80 : @code
81 : void f( ignore_case_param = {} );
82 : @endcode
83 : */
84 : constexpr
85 54 : ignore_case_param(
86 : #ifdef BOOST_URL_DOCS
87 : __implementation_defined__
88 : #else
89 : ignore_case_t
90 : #endif
91 : ) 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 224 : operator
105 : bool() const noexcept
106 : {
107 224 : return value_;
108 : }
109 : };
110 :
111 : } // urls
112 : } // boost
113 :
114 : #endif
|