1  
//
1  
//
2  
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
2  
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
3  
//
3  
//
4  
// Distributed under the Boost Software License, Version 1.0. (See accompanying
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)
5  
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6  
//
6  
//
7  
// Official repository: https://github.com/boostorg/url
7  
// Official repository: https://github.com/boostorg/url
8  
//
8  
//
9  

9  

10  
#ifndef BOOST_URL_IGNORE_CASE_HPP
10  
#ifndef BOOST_URL_IGNORE_CASE_HPP
11  
#define BOOST_URL_IGNORE_CASE_HPP
11  
#define BOOST_URL_IGNORE_CASE_HPP
12  

12  

13  
#include <boost/url/detail/config.hpp>
13  
#include <boost/url/detail/config.hpp>
14  

14  

15  
namespace boost {
15  
namespace boost {
16  
namespace urls {
16  
namespace urls {
17  

17  

18  
namespace implementation_defined {
18  
namespace implementation_defined {
19  
struct ignore_case_t {};
19  
struct ignore_case_t {};
20  
}
20  
}
21  

21  

22  
/** Ignore case when comparing
22  
/** Ignore case when comparing
23  

23  

24  
    This value may be optionally passed to
24  
    This value may be optionally passed to
25  
    functions accepting a parameter of type
25  
    functions accepting a parameter of type
26  
    @ref ignore_case_param to indicate that
26  
    @ref ignore_case_param to indicate that
27  
    comparisons should be case-insensitive.
27  
    comparisons should be case-insensitive.
28  
*/
28  
*/
29  
BOOST_INLINE_CONSTEXPR
29  
BOOST_INLINE_CONSTEXPR
30  
implementation_defined::ignore_case_t
30  
implementation_defined::ignore_case_t
31  
ignore_case{};
31  
ignore_case{};
32  

32  

33  
/** An optional parameter to determine case-sensitivity
33  
/** An optional parameter to determine case-sensitivity
34  

34  

35  
    Functions may use parameters of this type
35  
    Functions may use parameters of this type
36  
    to allow the user to optionally indicate
36  
    to allow the user to optionally indicate
37  
    that comparisons should be case-insensitive
37  
    that comparisons should be case-insensitive
38  
    when the value @ref ignore_case is passed.
38  
    when the value @ref ignore_case is passed.
39  

39  

40  
    @see
40  
    @see
41  
        @ref params_ref
41  
        @ref params_ref
42  
*/
42  
*/
43  
class ignore_case_param
43  
class ignore_case_param
44  
{
44  
{
45  
    /** True if an algorithm should ignore case
45  
    /** True if an algorithm should ignore case
46  

46  

47  
        Functions accepting a parameter of type
47  
        Functions accepting a parameter of type
48  
        `ignore_case_param` can check `value`
48  
        `ignore_case_param` can check `value`
49  
        to determine if the caller has indicated
49  
        to determine if the caller has indicated
50  
        that comparisons should ignore case.
50  
        that comparisons should ignore case.
51  
    */
51  
    */
52  
    bool value_ = false;
52  
    bool value_ = false;
53  

53  

54  
public:
54  
public:
55  
    /** Constructor
55  
    /** Constructor
56  

56  

57  
        By default, comparisons are
57  
        By default, comparisons are
58  
        case-sensitive.
58  
        case-sensitive.
59  

59  

60  
        @par Example
60  
        @par Example
61  
        This function performs case-sensitive
61  
        This function performs case-sensitive
62  
        comparisons when called with no
62  
        comparisons when called with no
63  
        arguments:
63  
        arguments:
64  
        @code
64  
        @code
65  
        void f( ignore_case_param = {} );
65  
        void f( ignore_case_param = {} );
66  
        @endcode
66  
        @endcode
67  
    */
67  
    */
68  
    constexpr
68  
    constexpr
69  
    ignore_case_param() noexcept = default;
69  
    ignore_case_param() noexcept = default;
70  

70  

71  
    /** Constructor
71  
    /** Constructor
72  

72  

73  
        Construction from @ref ignore_case
73  
        Construction from @ref ignore_case
74  
        indicates that comparisons should
74  
        indicates that comparisons should
75  
        be case-insensitive.
75  
        be case-insensitive.
76  

76  

77  
        The first parameter to this function
77  
        The first parameter to this function
78  
        should be the variable
78  
        should be the variable
79  
        @ref ignore_case.
79  
        @ref ignore_case.
80  

80  

81  
        @par Example
81  
        @par Example
82  
        When @ref ignore_case is passed as
82  
        When @ref ignore_case is passed as
83  
        an argument, this function ignores
83  
        an argument, this function ignores
84  
        case when performing comparisons:
84  
        case when performing comparisons:
85  
        @code
85  
        @code
86  
        void f( ignore_case_param(ignore_case) );
86  
        void f( ignore_case_param(ignore_case) );
87  
        @endcode
87  
        @endcode
88  
    */
88  
    */
89  
    constexpr
89  
    constexpr
90  
    ignore_case_param(
90  
    ignore_case_param(
91  
        implementation_defined::ignore_case_t) noexcept
91  
        implementation_defined::ignore_case_t) noexcept
92  
        : value_(true)
92  
        : value_(true)
93  
    {
93  
    {
94  
    }
94  
    }
95  

95  

96  
    /** True if an algorithm should ignore case
96  
    /** True if an algorithm should ignore case
97  

97  

98  
        Values of type `ignore_case_param`
98  
        Values of type `ignore_case_param`
99  
        evaluate to true when constructed
99  
        evaluate to true when constructed
100  
        with the constant @ref ignore_case.
100  
        with the constant @ref ignore_case.
101  
        Otherwise, they are default-constructed
101  
        Otherwise, they are default-constructed
102  
        and evaluate to `false`.
102  
        and evaluate to `false`.
103  

103  

104  
        @return `true` if case should be ignored
104  
        @return `true` if case should be ignored
105  
    */
105  
    */
106  
    operator
106  
    operator
107  
    bool() const noexcept
107  
    bool() const noexcept
108  
    {
108  
    {
109  
        return value_;
109  
        return value_;
110  
    }
110  
    }
111  
};
111  
};
112  

112  

113  
} // urls
113  
} // urls
114  
} // boost
114  
} // boost
115  

115  

116  
#endif
116  
#endif