MongoDB C++ Driver legacy-1.1.2
Loading...
Searching...
No Matches
string_map.h
1// string_map.h
2
3/* Copyright 2012 10gen Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#pragma once
19
20#include "mongo/base/string_data.h"
21#include "mongo/util/unordered_fast_key_table.h"
22
23namespace mongo {
24
25typedef StringData::Hasher StringMapDefaultHash;
26
28 bool operator()(const StringData& a, const StringData& b) const {
29 return a == b;
30 }
31};
32
34 StringData operator()(const std::string& s) const {
35 return StringData(s);
36 }
37};
38
40 std::string operator()(const StringData& s) const {
41 return s.toString();
42 }
43};
44
45template <typename V>
46class StringMap : public UnorderedFastKeyTable<StringData, // K_L
47 std::string, // K_S
48 V, // V
49 StringMapDefaultHash,
50 StringMapDefaultEqual,
51 StringMapDefaultConvertor,
52 StringMapDefaultConvertorOther> {};
53}
A StringData object wraps a 'const string&' or a 'const char*' without copying its contents.
Definition string_data.h:43
Definition string_map.h:52
Definition unordered_fast_key_table.h:41
Utility functions for parsing numbers from strings.
Definition compare_numbers.h:20
Definition string_map.h:39
Definition string_map.h:33
Definition string_map.h:27