summaryrefslogtreecommitdiff
path: root/src/mongo/util/string_map.h
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2012-12-10 15:15:21 -0500
committerEliot Horowitz <eliot@10gen.com>2012-12-10 15:15:21 -0500
commitf52ad32e62cfa750e386c257abddf33eaca7ec8b (patch)
treead4f5f023fde7f5af7c2b09f1bddc966fe6c9011 /src/mongo/util/string_map.h
parent8bc1aa3f748264648af4d53f263ada813a581434 (diff)
downloadmongo-f52ad32e62cfa750e386c257abddf33eaca7ec8b.tar.gz
SERVER-7886 - StringMap is now based on StringData
- UnorderedFastKeyTable more methods to match std::map
Diffstat (limited to 'src/mongo/util/string_map.h')
-rw-r--r--src/mongo/util/string_map.h31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/mongo/util/string_map.h b/src/mongo/util/string_map.h
index e2fd7e01bc7..1aa6c678e60 100644
--- a/src/mongo/util/string_map.h
+++ b/src/mongo/util/string_map.h
@@ -17,34 +17,41 @@
#pragma once
-#include <string>
+#include "mongo/base/string_data.h"
#include "mongo/util/unordered_fast_key_table.h"
namespace mongo {
struct StringMapDefaultHash {
- size_t operator()( const char* k ) const;
+ size_t operator()( const StringData& k ) const;
};
struct StringMapDefaultEqual {
- bool operator()( const char* a, const char* b ) const {
- return strcmp( a,b ) == 0;
+ bool operator()( const StringData& a, const StringData& b ) const {
+ return a == b;
}
};
struct StringMapDefaultConvertor {
- const char* operator()( const std::string& s ) const {
- return s.c_str();
+ StringData operator()( const std::string& s ) const {
+ return StringData( s );
+ }
+ };
+
+ struct StringMapDefaultConvertorOther {
+ string operator()( const StringData& s ) const {
+ return s.toString();
}
};
template< typename V >
- class StringMap : public UnorderedFastKeyTable< const char*, // K_L
- std::string, // K_S
- V, // V
- StringMapDefaultHash,
- StringMapDefaultEqual,
- StringMapDefaultConvertor > {
+ class StringMap : public UnorderedFastKeyTable< StringData, // K_L
+ std::string, // K_S
+ V, // V
+ StringMapDefaultHash,
+ StringMapDefaultEqual,
+ StringMapDefaultConvertor,
+ StringMapDefaultConvertorOther > {
};
}