diff options
author | zxu <zxu@google.com> | 2018-02-06 13:51:11 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-06 13:51:11 -0500 |
commit | a441190635d494f128cf02e07566ae2003af4e08 (patch) | |
tree | 618e6b0ecdb5d243f6e97f319f98f09dc9ca0a7e /Firestore/core/src/firebase/firestore/model | |
parent | 7cac9dc47a8c6b7321ebf5fc13fa7140e784c8ca (diff) |
Implement Firestore DatabaseInfo and port both Database{Id,Info} C++ to the iOS code (#738)
* implement Firestore DatabaseInfo in C++
* temporary stash changes; blocking on the massive renaming of .m to .mm
* add database_info_test to project
* finish port DatabaseId and fix style, modular fixing DatabaseInfo
* port DatabaseInfo
* remove FSTDatabase{ID,Info} and their tests from project
* fix unit test
* use namespace alias
* use namespace alias, leftover
* address more changes
* refactoring to use raw pointer instead of value for property
* address changes
* remove self->
* fix style
* remove the name suffix Alloc
* fix a bug
Diffstat (limited to 'Firestore/core/src/firebase/firestore/model')
-rw-r--r-- | Firestore/core/src/firebase/firestore/model/database_id.cc | 4 | ||||
-rw-r--r-- | Firestore/core/src/firebase/firestore/model/database_id.h | 25 |
2 files changed, 22 insertions, 7 deletions
diff --git a/Firestore/core/src/firebase/firestore/model/database_id.cc b/Firestore/core/src/firebase/firestore/model/database_id.cc index af12d30..d7e8a85 100644 --- a/Firestore/core/src/firebase/firestore/model/database_id.cc +++ b/Firestore/core/src/firebase/firestore/model/database_id.cc @@ -31,10 +31,6 @@ DatabaseId::DatabaseId(const absl::string_view project_id, FIREBASE_ASSERT(!database_id.empty()); } -bool DatabaseId::IsDefaultDatabase() { - return database_id_ == kDefaultDatabaseId; -} - } // namespace model } // namespace firestore } // namespace firebase diff --git a/Firestore/core/src/firebase/firestore/model/database_id.h b/Firestore/core/src/firebase/firestore/model/database_id.h index 48c547c..648f982 100644 --- a/Firestore/core/src/firebase/firestore/model/database_id.h +++ b/Firestore/core/src/firebase/firestore/model/database_id.h @@ -17,6 +17,8 @@ #ifndef FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_MODEL_DATABASE_ID_H_ #define FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_MODEL_DATABASE_ID_H_ +#include <stdint.h> + #include <string> #include "absl/strings/string_view.h" @@ -31,6 +33,12 @@ class DatabaseId { /** The default name for "unset" database ID in resource names. */ static constexpr const char* kDefaultDatabaseId = "(default)"; +#if defined(__OBJC__) + // For objective-c++ initialization; to be removed after migration. + // Do NOT use in C++ code. + DatabaseId() = default; +#endif // defined(__OBJC__) + /** * Creates and returns a new DatabaseId. * @@ -49,13 +57,24 @@ class DatabaseId { } /** Whether this is the default database of the project. */ - bool IsDefaultDatabase(); + bool IsDefaultDatabase() const { + return database_id_ == kDefaultDatabaseId; + } + +#if defined(__OBJC__) + // For objective-c++ hash; to be removed after migration. + // Do NOT use in C++ code. + uint64_t Hash() const { + std::hash<std::string> hash_fn; + return hash_fn(project_id_) * 31u + hash_fn(database_id_); + } +#endif // defined(__OBJC__) friend bool operator<(const DatabaseId& lhs, const DatabaseId& rhs); private: - const std::string project_id_; - const std::string database_id_; + std::string project_id_; + std::string database_id_; }; /** Compares against another DatabaseId. */ |