Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for DocumentChange #20

Merged
merged 2 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Sources/FirebaseFirestore/DocumentChange+Swift.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: BSD-3-Clause

@_exported
import firebase

import CxxShim

public typealias DocumentChange = firebase.firestore.DocumentChange
public typealias DocumentChangeType = firebase.firestore.DocumentChange.`Type`

extension DocumentChange {
public var type: DocumentChangeType {
swift_firebase.swift_cxx_shims.firebase.firestore.document_change_type(self)
}

public var document: DocumentSnapshot {
swift_firebase.swift_cxx_shims.firebase.firestore.document_change_document(self)
}

public var oldIndex: UInt {
UInt(swift_firebase.swift_cxx_shims.firebase.firestore.document_change_old_index(self))
}

public var newIndex: UInt {
UInt(swift_firebase.swift_cxx_shims.firebase.firestore.document_change_new_index(self))
}
}
22 changes: 22 additions & 0 deletions Sources/firebase/include/FirebaseFirestore.hh
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,28 @@ const uint8_t *field_get_blob(const ::firebase::firestore::FieldValue field) {

typedef std::vector<::firebase::firestore::FieldValue> FirestoreFieldValues;

// MARK: - DocumentChange

inline ::firebase::firestore::DocumentChange::Type
document_change_type(const ::firebase::firestore::DocumentChange change) {
return change.type();
}

inline ::firebase::firestore::DocumentSnapshot
document_change_document(const ::firebase::firestore::DocumentChange change) {
return change.document();
}

inline ::std::size_t
document_change_old_index(const ::firebase::firestore::DocumentChange change) {
return change.old_index();
}

inline ::std::size_t
document_change_new_index(const ::firebase::firestore::DocumentChange change) {
return change.new_index();
}

} // namespace swift_firebase::swift_cxx_shims::firebase::firestore

#endif