aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/core/src/firebase/firestore/model
diff options
context:
space:
mode:
Diffstat (limited to 'Firestore/core/src/firebase/firestore/model')
-rw-r--r--Firestore/core/src/firebase/firestore/model/database_id.cc4
-rw-r--r--Firestore/core/src/firebase/firestore/model/database_id.h25
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. */