... based on things learned porting Timestamps.
There's no good way to include conversions equivalent to toGeoPoint in
FIRTimestamp, so pull out separate conversion functions that match other
similar things.
* Rename nanopb::String to nanopb::ByteString
... and flesh it out.
* Remove const pb_bytes_array* constructor
* Use std:: prefixes
* Pull forward CopyVector
* Simplify nanopb::Reader/Writer construction
* Reuse ByteString construction in serializer
* Add nanopb_testing.h
* Make QueryData.resume_token a ByteString
* Use ByteString as FieldValue::blob_value
* Migrate FSTBlobValue to FSTDelegateValue
* Rework the ByteString API
* Make data(), begin(), and end() never return nullptr
* Make copies of pb_bytes_array_t* more obvious (also avoids ambiguity
with the private constructor).
* Remove constructors that duplicate absl::string_view
* Make ByteString::Copy just a constructor
* Remove EncodeBytes/DecodeBytes
These duplicate ByteString constructors
* Overhaul ByteString and users
* Remove most conversions from ByteString
* Put remaining conversions in nanopb_util as free functions
* Make ByteStringWriter accumulate in a pb_bytes_array_t*
* Have ProtobufSerialize use ByteStringWriter
* Avoid reserving/writing if we're not asked to append data
* Ensure ByteStringWriter initializes/frees
* Make copies explicit
* Make Reserve match std::vector::reserve
* Add comments, assertions, and tests
* Migrate FSTNullValue to FSTDelegateValue
* Migrate FSTIntegerValue to FSTDelegateValue
* Migrate FSTDoubleValue to FSTDelegateValue
* Migrate FSTGeoPointValue to FSTDelegateValue
* Remove stale references to DatabaseId
* Have Firestore take the DatabaseId directly
* Allow tests to default the database implicitly
* Have FSTSerializerBeta take DatabaseId by value
* Have FSTUserDataConverter take DatabaseId by value
* Make FIRFirestore.databaseID a const reference
* Make FSTFirestoreClient.databaseID a const reference
* Have FSTReferenceValue take DatabaseId by value
* Have DatabaseInfo take DatabaseId by value
* Have Serializer take DatabaseId by value
* Fix C++ ReferenceValue
* Take DatabaseId by value
* Reverse order to match Android
* Rename `reference` to `key`
* Make disabling GC prevent even scheduling it
Make the linkage of kFIRFirestoreCacheSizeUnlimited explicitly
extern "C". This previously had no fixed linkage in the header and must
have accidentally worked because the implementation had C++ linkage.
Move internal CacheSizeUnlimited to api::Settings and the
definition of kFIRFirestoreCacheSizeUnlimited into the Objective-C
language binding.
Migrate settings defaults to C++ settings
Ensure that all defaults are compiler initialized to ensure there are no
initialization order problems.
* Create api::WriteBatch "port" of FIRWriteBatch.
* Make FIRWriteBatch a wrapper around an api::WriteBatch (and a FSTUserDataConverter for parsing input).
I think the intention was that the user_data.h types should be used as the representation of parsed user data that can be passed down from the public API to the api:: layer, so this PR "fixes" api::DocumentReference to accept ParsedSetData and ParsedUserData in SetData() / UpdateData() instead of taking the list of mutations. This is consistent with the approach I took in the api::WriteBatch port.
Side note: Prior to this change, SetData() / UpdateData() were actually identical methods just with different names.
* Make error_apple definitions out-of-line
* Add util::MakeCallback
Translates between API completion handlers that take just an NSError and
the equivalent std::function that accepts util::Status.
* Port DocumentReference::Completion to a std::function callback
* Port Firestore::ErrorCompletions to StatusCallback
* Port transaction-related completions to C++
* Remove now-unused FSTVoidIDErrorBlock
* Fix tunneling of Firestore-generated NSErrors.
Remove MakeStatus(NSError*) because it has different results from
Status::FromNSError. Ensure that user-supplied errors created in
transactions tunnel through correctly.
This is safer and better matches our design (and the other platforms), since
classes like api::DocumentReference will have references to api::Firsetore but
the lifetime is controlled by the developer, not us.
* Creates a C++ api::Settings class as a container for the settings we pass
into the core client.
* Adds [FIRFirestoreSettings internalSettings] to convert from public API
settings to api::Settings.
Input validation, etc. still happens in FIRFirestoreSettings.
use namespace aliases instead.
This makes the Objective-C code much more like what it's going to end up
being like when translated to C++: headers will include classes declared
in a namespace relative to firebase::firestore so everything else will
be named relative to firebase::firestore.
Meanwhile the using statements in the headers were causing us to miss
adding using statements in source files which was moving us away from
where we wanted to be.
* Tunnel underlying NSErrors through Status
* Make FIRFirestoreErrorDomain available to CMake builds
The prior state was actually semi-broken. The
firebase_credentials_provider_apple definition wasn't extern "C" so it
was defining the value in addition to whatever FIRFirestore was doing.
FIRFirestore's value isn't available to straight C++ though, so this
change pushes the definition down into error_apple.mm so that it can be
shared by the Objective-C API and MakeNSError.
Pushing MakeNSError up into the API layer isn't practical yet so this
change is a compromise that makes things work
Note:
* This includes a partial port of array-contains for Filters because
this silenced a warning about an unhandled case
* There's some sensitivity to the order of the cases that I didn't
bother to figure out; instead I just made it match what came before.
* Fix a couple small issues I tripped over today.
1. Fix primeBackend so it uses an isolated FIRFirestore* instance. I ran into
an issue where tests that try to change .settings would fail if they were the
very first test run, since primeBackend had already configured the client and
so settings could no longer be changed.
2. Remove FIRFirestore.client and make api::Firestore.client() assert client is configured.
* Fix FSTFieldValue instanceof check to use FSTFieldValue.type
Missed in the previous PR because this gets the class via [value class]
rather than [value isKindOfClass].
* Add FSTDelegateValue which delegates to model::FieldValue
Also migrates FSTBooleanValue to FSTDelegateValue as a proof-of-concept.
Other FSTXValues still TODO.
* Create C++ api::DocumentChange class.
* Make FIRDocumentChange a wrapper over api::DocumentChange.
* Moved documentChangesForSnapshot helper from FIRDocumentChange to
where it's used in QuerySnapshot. I think this is cleaner.
Previously, we checked for FSTFieldValue subtypes via:
`[value isKindOfClass:[FSTStringValue class]]`
Now, we check via a new type parameter on FSTFieldValue, i.e.:
`value.type == firebase::firestore::model::FieldValue::Type::String`
Or with the appropriate using declaration:
`value.type == FieldValue::Type::String`
This should enable easier transition to C++.
* Test that shows a leak.
* Add EventListener to match Android.
* Use AsyncEventListener in FSTQueryListenerTests
* Remove FSTAsyncQueryListener
* Use EventListener throughout
* Replace FSTDocumentSet's guts with immutable::SortedSet.
* Port FSTDocumentSet to C++ DocumentSet.
* Replace implementation of FSTDocumentSet with C++ DocumentSet
* Update all usages of FSTDocumentSet
* Remove FSTDocumentSet
* Add Objective-C++ guard
* Use absl::c_equal instead of hand-rolling it.
* Split SortedContainer out of SortedMapBase
... and use it
* Fix NSNotFound -> npos
* Remove = default constructors that aren't true.
These are implicitly deleted because DocumentSet is a member and isn't
default constructible.
* Fix usage of FSTQuery.limit