Crow  1.1
A C++ microframework for the web
 
Loading...
Searching...
No Matches
ci_map.h
1#pragma once
2
3#include <locale>
4#include <unordered_map>
5#include "crow/utility.h"
6
7namespace crow
8{
9 /// Hashing function for ci_map (unordered_multimap).
10 struct ci_hash
11 {
12 size_t operator()(const std::string& key) const
13 {
14 std::size_t seed = 0;
15 std::locale locale;
16
17 for (auto c : key)
18 hash_combine(seed, std::toupper(c, locale));
19
20 return seed;
21 }
22
23 private:
24 static inline void hash_combine(std::size_t& seed, char v)
25 {
26 std::hash<char> hasher;
27 seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
28 }
29 };
30
31 /// Equals function for ci_map (unordered_multimap).
32 struct ci_key_eq
33 {
34 bool operator()(const std::string& l, const std::string& r) const
35 {
36 return utility::string_equals(l, r);
37 }
38 };
39
40 using ci_map = std::unordered_multimap<std::string, std::string, ci_hash, ci_key_eq>;
41} // namespace crow
The main namespace of the library. In this namespace is defined the most important classes and functi...
Hashing function for ci_map (unordered_multimap).
Definition ci_map.h:11
Equals function for ci_map (unordered_multimap).
Definition ci_map.h:33