|
| 1 | +/* |
| 2 | + * Copyright 2022 Google LLC |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +#ifndef FIRESTORE_CORE_SRC_INDEX_INDEX_ENTRY_H_ |
| 18 | +#define FIRESTORE_CORE_SRC_INDEX_INDEX_ENTRY_H_ |
| 19 | + |
| 20 | +#include <iostream> |
| 21 | +#include <memory> |
| 22 | +#include <string> |
| 23 | +#include <utility> |
| 24 | + |
| 25 | +#include "Firestore/core/src/model/document_key.h" |
| 26 | +#include "Firestore/core/src/util/comparison.h" |
| 27 | + |
| 28 | +namespace firebase { |
| 29 | +namespace firestore { |
| 30 | +namespace index { |
| 31 | + |
| 32 | +/** Represents an index entry saved by the SDK in its local storage. */ |
| 33 | +class IndexEntry : public util::Comparable<IndexEntry> { |
| 34 | + public: |
| 35 | + IndexEntry(int32_t index_id, |
| 36 | + model::DocumentKey key, |
| 37 | + std::string array_value, |
| 38 | + std::string directional_value) |
| 39 | + : index_id_(index_id), |
| 40 | + key_(std::move(key)), |
| 41 | + array_value_(std::move(array_value)), |
| 42 | + directional_value_(std::move(directional_value)) { |
| 43 | + } |
| 44 | + |
| 45 | + int32_t index_id() const { |
| 46 | + return index_id_; |
| 47 | + } |
| 48 | + |
| 49 | + const model::DocumentKey& document_key() const { |
| 50 | + return key_; |
| 51 | + } |
| 52 | + |
| 53 | + const std::string& array_value() const { |
| 54 | + return array_value_; |
| 55 | + } |
| 56 | + |
| 57 | + const std::string& directional_value() const { |
| 58 | + return directional_value_; |
| 59 | + } |
| 60 | + |
| 61 | + util::ComparisonResult CompareTo(const IndexEntry& rhs) const; |
| 62 | + size_t Hash() const; |
| 63 | + |
| 64 | + std::string ToString() const; |
| 65 | + friend std::ostream& operator<<(std::ostream& out, |
| 66 | + const IndexEntry& database_id); |
| 67 | + |
| 68 | + private: |
| 69 | + int32_t index_id_; |
| 70 | + model::DocumentKey key_; |
| 71 | + std::string array_value_; |
| 72 | + std::string directional_value_; |
| 73 | +}; |
| 74 | + |
| 75 | +} // namespace index |
| 76 | +} // namespace firestore |
| 77 | +} // namespace firebase |
| 78 | + |
| 79 | +#endif // FIRESTORE_CORE_SRC_INDEX_INDEX_ENTRY_H_ |
0 commit comments