From cb8c4b6b1f1ad213a5b3272e2c2e94f755bbabf9 Mon Sep 17 00:00:00 2001 From: zxu Date: Tue, 27 Mar 2018 14:33:39 -0400 Subject: 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 --- Firestore/core/src/firebase/firestore/model/base_path.h | 4 ++-- Firestore/core/src/firebase/firestore/model/database_id.h | 2 +- Firestore/core/src/firebase/firestore/model/document_key.h | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'Firestore/core/src/firebase/firestore/model') 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 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 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{}(ToString()); + } #endif /** -- cgit v1.2.3