Skip to content

Commit

Permalink
Add support for DocumentChange
Browse files Browse the repository at this point in the history
  • Loading branch information
darinf committed Feb 9, 2024
1 parent f30cbd1 commit 83b02ba
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Sources/FirebaseFirestore/DocumentChange+Swift.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// SPDX-License-Identifier: BSD-3-Clause

@_exported
import firebase
@_spi(Error)
import FirebaseCore

import CxxShim
import Foundation

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

0 comments on commit 83b02ba

Please sign in to comment.