1 | //===----------------------------------------------------------------------===// |
---|---|
2 | // DuckDB |
3 | // |
4 | // duckdb/common/case_insensitive_map.hpp |
5 | // |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #pragma once |
10 | |
11 | #include "duckdb/common/unordered_map.hpp" |
12 | #include "duckdb/common/unordered_set.hpp" |
13 | #include "duckdb/common/string.hpp" |
14 | #include "duckdb/common/string_util.hpp" |
15 | |
16 | namespace duckdb { |
17 | |
18 | struct CaseInsensitiveStringHashFunction { |
19 | uint64_t operator()(const string &str) const { |
20 | return StringUtil::CIHash(str); |
21 | } |
22 | }; |
23 | |
24 | struct CaseInsensitiveStringEquality { |
25 | bool operator()(const string &a, const string &b) const { |
26 | return StringUtil::CIEquals(l1: a, l2: b); |
27 | } |
28 | }; |
29 | |
30 | template <typename T> |
31 | using case_insensitive_map_t = |
32 | unordered_map<string, T, CaseInsensitiveStringHashFunction, CaseInsensitiveStringEquality>; |
33 | |
34 | using case_insensitive_set_t = unordered_set<string, CaseInsensitiveStringHashFunction, CaseInsensitiveStringEquality>; |
35 | |
36 | } // namespace duckdb |
37 |