SNode.C
Loading...
Searching...
No Matches
CiStringMap.cpp
Go to the documentation of this file.
1
/*
2
* SNode.C - A Slim Toolkit for Network Communication
3
* Copyright (C) 2020, 2021, 2022, 2023 Volker Christian <me@vchrist.at>
4
*
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU Lesser General Public License as published
7
* by the Free Software Foundation, either version 3 of the License, or
8
* (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU Lesser General Public License for more details.
14
*
15
* You should have received a copy of the GNU Lesser General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
/*
20
* MIT License
21
*
22
* Permission is hereby granted, free of charge, to any person obtaining a copy
23
* of this software and associated documentation files (the "Software"), to deal
24
* in the Software without restriction, including without limitation the rights
25
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
26
* copies of the Software, and to permit persons to whom the Software is
27
* furnished to do so, subject to the following conditions:
28
*
29
* The above copyright notice and this permission notice shall be included in
30
* all copies or substantial portions of the Software.
31
*
32
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
35
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
37
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
38
* THE SOFTWARE.
39
*/
40
41
#
ifndef
DOXYGEN_SHOULD_SKIP_THIS
42
43
#
include
"CiStringMap.h"
44
45
#
include
<
algorithm
>
46
#
include
<
cctype
>
47
#
include
<
strings
.
h
>
48
49
#
endif
// DOXYGEN_SHOULD_SKIP_THIS
50
51
namespace
web::http {
52
53
bool
ciContains
(
const
std::string& str1,
const
std::string& str2) {
54
auto
it = std::search(str1.begin(), str1.end(), str2.begin(), str2.end(), [](
char
ch1,
char
ch2) {
55
return
std::tolower(ch1) == std::tolower(ch2);
56
});
57
58
return
(it != str1.end());
59
}
60
61
bool
ciEquals
(
const
std::string& str1,
const
std::string& str2) {
62
return
std::equal(str1.begin(), str1.end(), str2.begin(), str2.end(), [](
char
ch1,
char
ch2) {
63
return
std::tolower(ch1) == std::tolower(ch2);
64
});
65
}
66
67
bool
ciLess
::
operator
()(
const
std::string& a,
const
std::string& b)
const
{
68
return
::strcasecmp(a.c_str(), b.c_str()) < 0;
69
}
70
71
}
// namespace web::http
web::http::ciEquals
bool ciEquals(const std::string &str1, const std::string &str2)
Definition
CiStringMap.cpp:61
web::http::ciContains
bool ciContains(const std::string &str1, const std::string &str2)
Definition
CiStringMap.cpp:53
web::http::ciLess
Definition
CiStringMap.h:56
web::http::ciLess::operator()
bool operator()(const std::string &a, const std::string &b) const
Definition
CiStringMap.cpp:67
web
http
CiStringMap.cpp
Generated on Mon Mar 31 2025 11:56:40 for SNode.C by
1.11.0