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
#
ifndef
DOXYGEN_SHOULD_SKIP_THIS
20
21
#
include
"CiStringMap.h"
22
23
#
include
<
algorithm
>
24
#
include
<
cctype
>
25
#
include
<
strings
.
h
>
26
27
#
endif
// DOXYGEN_SHOULD_SKIP_THIS
28
29
namespace
web::http {
30
31
bool
ciContains
(
const
std::string& str1,
const
std::string& str2) {
32
auto
it = std::search(str1.begin(), str1.end(), str2.begin(), str2.end(), [](
char
ch1,
char
ch2) {
33
return
std::tolower(ch1) == std::tolower(ch2);
34
});
35
36
return
(it != str1.end());
37
}
38
39
bool
ciEquals
(
const
std::string& str1,
const
std::string& str2) {
40
return
std::equal(str1.begin(), str1.end(), str2.begin(), str2.end(), [](
char
ch1,
char
ch2) {
41
return
std::tolower(ch1) == std::tolower(ch2);
42
});
43
}
44
45
bool
ciLess
::
operator
()(
const
std::string& a,
const
std::string& b)
const
{
46
return
::strcasecmp(a.c_str(), b.c_str()) < 0;
47
}
48
49
}
// namespace web::http
web::http::ciEquals
bool ciEquals(const std::string &str1, const std::string &str2)
Definition
CiStringMap.cpp:39
web::http::ciContains
bool ciContains(const std::string &str1, const std::string &str2)
Definition
CiStringMap.cpp:31
web::http::ciLess
Definition
CiStringMap.h:34
web::http::ciLess::operator()
bool operator()(const std::string &a, const std::string &b) const
Definition
CiStringMap.cpp:45
web
http
CiStringMap.cpp
Generated on Mon Feb 10 2025 20:21:56 for SNode.C by
1.11.0