diff options
author | zxu <zxu@google.com> | 2018-03-27 14:33:39 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-27 14:33:39 -0400 |
commit | cb8c4b6b1f1ad213a5b3272e2c2e94f755bbabf9 (patch) | |
tree | eb3eeddefb5fca423f59432933721d6d47100aa5 /Firestore/core/src/firebase/firestore/model | |
parent | a335d78a62c213b1ae6465bad28aaedfafd828bc (diff) |
port C++ DocumentKey to the rest of Firestore code (#977)
* port C++ DocumentKey to API's and Core's
* address changes
* address changes
* fix Hash return types
Diffstat (limited to 'Firestore/core/src/firebase/firestore/model')
3 files changed, 7 insertions, 3 deletions
diff --git a/Firestore/core/src/firebase/firestore/model/base_path.h b/Firestore/core/src/firebase/firestore/model/base_path.h index 73ac611..bc1f89d 100644 --- a/Firestore/core/src/firebase/firestore/model/base_path.h +++ b/Firestore/core/src/firebase/firestore/model/base_path.h @@ -162,9 +162,9 @@ class BasePath { #if defined(__OBJC__) // For Objective-C++ hash; to be removed after migration. // Do NOT use in C++ code. - uint64_t Hash() const { + NSUInteger Hash() const { std::hash<std::string> hash_fn; - uint64_t hash_result = 0; + NSUInteger hash_result = 0; for (const std::string& segment : segments_) { hash_result = hash_result * 31u + hash_fn(segment); } diff --git a/Firestore/core/src/firebase/firestore/model/database_id.h b/Firestore/core/src/firebase/firestore/model/database_id.h index 01ccf76..2ad1332 100644 --- a/Firestore/core/src/firebase/firestore/model/database_id.h +++ b/Firestore/core/src/firebase/firestore/model/database_id.h @@ -64,7 +64,7 @@ class DatabaseId { #if defined(__OBJC__) // For objective-c++ hash; to be removed after migration. // Do NOT use in C++ code. - uint64_t Hash() const { + NSUInteger Hash() const { std::hash<std::string> hash_fn; return hash_fn(project_id_) * 31u + hash_fn(database_id_); } diff --git a/Firestore/core/src/firebase/firestore/model/document_key.h b/Firestore/core/src/firebase/firestore/model/document_key.h index 134bda5..4bdc04b 100644 --- a/Firestore/core/src/firebase/firestore/model/document_key.h +++ b/Firestore/core/src/firebase/firestore/model/document_key.h @@ -59,6 +59,10 @@ class DocumentKey { std::string ToString() const { return path().CanonicalString(); } + + NSUInteger Hash() const { + return std::hash<std::string>{}(ToString()); + } #endif /** |