From 84b95d12a1d046a809c84ead4eb4913c2048244a Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Thu, 25 Aug 2022 09:39:07 -0700 Subject: [PATCH] add ignore_case --- doc/qbk/quickref.xml | 2 + include/boost/url.hpp | 1 + include/boost/url/ignore_case.hpp | 103 ++++++++++++++++++++++++++++++ test/unit/CMakeLists.txt | 1 + test/unit/Jamfile | 1 + test/unit/ignore_case.cpp | 11 ++++ test/unit/params.cpp | 29 +++++++++ 7 files changed, 148 insertions(+) create mode 100644 include/boost/url/ignore_case.hpp create mode 100644 test/unit/ignore_case.cpp diff --git a/doc/qbk/quickref.xml b/doc/qbk/quickref.xml index 3388e259..8a405220 100644 --- a/doc/qbk/quickref.xml +++ b/doc/qbk/quickref.xml @@ -51,6 +51,7 @@ Types (1/2) authority_view + ignore_case_param ipv4_address ipv6_address params @@ -80,6 +81,7 @@ Constants error + ignore_case host_type scheme diff --git a/include/boost/url.hpp b/include/boost/url.hpp index ff9a9586..ebe1ccab 100644 --- a/include/boost/url.hpp +++ b/include/boost/url.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include diff --git a/include/boost/url/ignore_case.hpp b/include/boost/url/ignore_case.hpp new file mode 100644 index 00000000..e33cf079 --- /dev/null +++ b/include/boost/url/ignore_case.hpp @@ -0,0 +1,103 @@ +// +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/CPPAlliance/url +// + +#ifndef BOOST_URL_IGNORE_CASE_HPP +#define BOOST_URL_IGNORE_CASE_HPP + +#include + +namespace boost { +namespace urls { + +#ifndef BOOST_URL_DOCS +struct ignore_case_t +{ +}; +#endif + +/** Ignore case when comparing + + This value may be optionally passed to + functions accepting a parameter of type + @ref ignore_case_param to indicate that + comparisons should be case-insensitive. +*/ +constexpr +#ifdef BOOST_URL_DOCS +__implementation_defined__ +#else +ignore_case_t +#endif +ignore_case{}; + +/** An optional parameter to determine case-sensitivity + + Functions may use parameters of this type + to allow the user to optionally indicate + that comparisons should be case-insensitive + when the value @ref ignore_case is passed. +*/ +struct ignore_case_param +{ + /** True if an algorithm should ignore case + + Functions accepting a parameter of type + `ignore_case_param` can check `value` + to determine if the caller has indicated + that comparisons should ignore case. + */ + bool value = false; + + /** Constructor + + By default, comparisons are + case-sensitive. + + @par Example + This function performs case-sensitive + comparisons when called with no + arguments: + @code + void f( ignore_case_param = {} ); + @endcode + */ + constexpr + ignore_case_param() noexcept = default; + + /** Constructor + + Construction from @ref ignore_case + indicates that comparisons should + be case-insensitive. + + @par Example + When @ref ignore_case is passed as + an argument, this function ignores + case when performing comparisons: + @code + void f( ignore_case_param = {} ); + @endcode + */ + constexpr + ignore_case_param( + #ifdef BOOST_URL_DOCS + __implementation_defined__ + #else + ignore_case_t + #endif + ) noexcept + : value(true) + { + } +}; + +} // urls +} // boost + +#endif diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index 262fb0df..ecdb8716 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -26,6 +26,7 @@ set(BOOST_URL_TESTS_FILES error_types.cpp grammar.cpp host_type.cpp + ignore_case.cpp ipv4_address.cpp ipv6_address.cpp natvis.cpp diff --git a/test/unit/Jamfile b/test/unit/Jamfile index 133cf738..f2601497 100644 --- a/test/unit/Jamfile +++ b/test/unit/Jamfile @@ -30,6 +30,7 @@ local SOURCES = decode_view.cpp grammar.cpp host_type.cpp + ignore_case.cpp ipv4_address.cpp ipv6_address.cpp optional.cpp diff --git a/test/unit/ignore_case.cpp b/test/unit/ignore_case.cpp new file mode 100644 index 00000000..27dae39b --- /dev/null +++ b/test/unit/ignore_case.cpp @@ -0,0 +1,11 @@ +// +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/CPPAlliance/url +// + +// Test that header file is self-contained. +#include diff --git a/test/unit/params.cpp b/test/unit/params.cpp index 4f64a543..82b77154 100644 --- a/test/unit/params.cpp +++ b/test/unit/params.cpp @@ -534,3 +534,32 @@ TEST_SUITE( } // urls } // boost + +/* + + operator=(std::initializer_list) + assign(std::initializer_list) + assign(FwdIt, FwdIt) + insert(iterator, value_type) + insert(iterator, initializer_list) + insert(iterator, FwdIt, FwdIt) + replace(iterator, value_type) + replace(iterator, iterator, FwdIt, FwdIt) + replace(iterator, initializer_list) + replace(iterator, value_type) + erase(iterator) + erase(iterator, iterator) + push_back(value_type) + + // key/value + remove_value(iterator) + replace_value(iterator, value) + replace(iterator, key, value) + replace(iterator, key) + insert(iterator, key, value) + insert(iterator, key) + erase(key) + append(key) + append(key, value) + +*/ \ No newline at end of file