diff --git a/packages/realm_dart/lib/src/handles/native/realm_bindings.dart b/packages/realm_dart/lib/src/handles/native/realm_bindings.dart index a1e58c3c1..df6e90c38 100644 --- a/packages/realm_dart/lib/src/handles/native/realm_bindings.dart +++ b/packages/realm_dart/lib/src/handles/native/realm_bindings.dart @@ -124,10968 +124,6294 @@ class RealmLibrary { ffi.Pointer, realm_free_userdata_func_t)>(); - /// Run a named MongoDB Realm function. - /// - /// @param serialized_ejson_args The arguments array to invoke the function with, - /// serialized as an Extended JSON string. - /// @param service_name The name of the remote service whose system function to call. Can be null, - /// in which case the called function is expected to be a user function. - /// @return true, if no error occurred. - bool realm_app_call_function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer function_name, - ffi.Pointer serialized_ejson_args, - ffi.Pointer service_name, - realm_return_string_func_t callback, + /// start a new write transaction asynchronously for the realm passed as argument. + bool realm_async_begin_write( + ffi.Pointer realm, + realm_async_begin_write_func_t arg1, ffi.Pointer userdata, realm_free_userdata_func_t userdata_free, + bool notify_only, + ffi.Pointer transaction_id, ) { - return _realm_app_call_function( - arg0, + return _realm_async_begin_write( + realm, arg1, - function_name, - serialized_ejson_args, - service_name, - callback, userdata, userdata_free, + notify_only, + transaction_id, ); } - late final _realm_app_call_functionPtr = _lookup< + late final _realm_async_begin_writePtr = _lookup< ffi.NativeFunction< ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - realm_return_string_func_t, + ffi.Pointer, + realm_async_begin_write_func_t, ffi.Pointer, - realm_free_userdata_func_t)>>('realm_app_call_function'); - late final _realm_app_call_function = _realm_app_call_functionPtr.asFunction< + realm_free_userdata_func_t, + ffi.Bool, + ffi.Pointer)>>('realm_async_begin_write'); + late final _realm_async_begin_write = _realm_async_begin_writePtr.asFunction< bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - realm_return_string_func_t, + ffi.Pointer, + realm_async_begin_write_func_t, ffi.Pointer, - realm_free_userdata_func_t)>(); - - /// If using App Services, the realm_sync_client_config_t instance is part of the - /// realm_app_config_t structure and this function returns a pointer to that - /// member property. The realm_sync_client_config_t reference returned by this - /// function should not be freed using realm_release. - ffi.Pointer - realm_app_config_get_sync_client_config( - ffi.Pointer arg0, - ) { - return _realm_app_config_get_sync_client_config( - arg0, - ); - } - - late final _realm_app_config_get_sync_client_configPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>( - 'realm_app_config_get_sync_client_config'); - late final _realm_app_config_get_sync_client_config = - _realm_app_config_get_sync_client_configPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer)>(); - - /// Create a new app configuration. - /// - /// @param app_id The MongoDB Realm app id. - /// @param http_transport The HTTP transport used to make network calls. - ffi.Pointer realm_app_config_new( - ffi.Pointer app_id, - ffi.Pointer http_transport, - ) { - return _realm_app_config_new( - app_id, - http_transport, - ); - } - - late final _realm_app_config_newPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer)>>('realm_app_config_new'); - late final _realm_app_config_new = _realm_app_config_newPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, ffi.Pointer)>(); + realm_free_userdata_func_t, + bool, + ffi.Pointer)>(); - void realm_app_config_set_base_file_path( - ffi.Pointer arg0, - ffi.Pointer arg1, + /// Cancel the transaction referenced by the token passed as argument and set the optional boolean flag in order to + /// inform the caller if the transaction was cancelled. + bool realm_async_cancel( + ffi.Pointer realm, + int token, + ffi.Pointer cancelled, ) { - return _realm_app_config_set_base_file_path( - arg0, - arg1, + return _realm_async_cancel( + realm, + token, + cancelled, ); } - late final _realm_app_config_set_base_file_pathPtr = _lookup< + late final _realm_async_cancelPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Pointer)>>('realm_app_config_set_base_file_path'); - late final _realm_app_config_set_base_file_path = - _realm_app_config_set_base_file_pathPtr.asFunction< - void Function( - ffi.Pointer, ffi.Pointer)>(); + ffi.Bool Function(ffi.Pointer, ffi.UnsignedInt, + ffi.Pointer)>>('realm_async_cancel'); + late final _realm_async_cancel = _realm_async_cancelPtr.asFunction< + bool Function(ffi.Pointer, int, ffi.Pointer)>(); - void realm_app_config_set_base_url( - ffi.Pointer arg0, - ffi.Pointer arg1, + /// commit a transaction asynchronously for the realm passed as argument. + bool realm_async_commit( + ffi.Pointer realm, + realm_async_commit_func_t arg1, + ffi.Pointer userdata, + realm_free_userdata_func_t userdata_free, + bool allow_grouping, + ffi.Pointer transaction_id, ) { - return _realm_app_config_set_base_url( - arg0, + return _realm_async_commit( + realm, arg1, + userdata, + userdata_free, + allow_grouping, + transaction_id, ); } - late final _realm_app_config_set_base_urlPtr = _lookup< + late final _realm_async_commitPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Pointer)>>('realm_app_config_set_base_url'); - late final _realm_app_config_set_base_url = - _realm_app_config_set_base_urlPtr.asFunction< - void Function( - ffi.Pointer, ffi.Pointer)>(); + ffi.Bool Function( + ffi.Pointer, + realm_async_commit_func_t, + ffi.Pointer, + realm_free_userdata_func_t, + ffi.Bool, + ffi.Pointer)>>('realm_async_commit'); + late final _realm_async_commit = _realm_async_commitPtr.asFunction< + bool Function( + ffi.Pointer, + realm_async_commit_func_t, + ffi.Pointer, + realm_free_userdata_func_t, + bool, + ffi.Pointer)>(); - void realm_app_config_set_bundle_id( - ffi.Pointer config, - ffi.Pointer bundle_id, + /// for debugging only. Enable in realm_dart.cpp + /// RLM_API void realm_dart_gc(); + ffi.Pointer realm_attach_finalizer( + Object handle, + ffi.Pointer realmPtr, + int size, ) { - return _realm_app_config_set_bundle_id( - config, - bundle_id, + return _realm_attach_finalizer( + handle, + realmPtr, + size, ); } - late final _realm_app_config_set_bundle_idPtr = _lookup< + late final _realm_attach_finalizerPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Pointer)>>('realm_app_config_set_bundle_id'); - late final _realm_app_config_set_bundle_id = - _realm_app_config_set_bundle_idPtr.asFunction< - void Function( - ffi.Pointer, ffi.Pointer)>(); + ffi.Pointer Function(ffi.Handle, ffi.Pointer, + ffi.Int)>>('realm_attach_finalizer'); + late final _realm_attach_finalizer = _realm_attach_finalizerPtr.asFunction< + ffi.Pointer Function(Object, ffi.Pointer, int)>(); - void realm_app_config_set_default_request_timeout( - ffi.Pointer arg0, - int ms, + /// Begin a read transaction for the Realm file. + /// + /// @return True if no exception occurred. + bool realm_begin_read( + ffi.Pointer arg0, ) { - return _realm_app_config_set_default_request_timeout( + return _realm_begin_read( arg0, - ms, ); } - late final _realm_app_config_set_default_request_timeoutPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Uint64)>>('realm_app_config_set_default_request_timeout'); - late final _realm_app_config_set_default_request_timeout = - _realm_app_config_set_default_request_timeoutPtr - .asFunction, int)>(); + late final _realm_begin_readPtr = + _lookup)>>( + 'realm_begin_read'); + late final _realm_begin_read = + _realm_begin_readPtr.asFunction)>(); - void realm_app_config_set_device_name( - ffi.Pointer config, - ffi.Pointer device_name, + /// Begin a write transaction for the Realm file. + /// + /// @return True if no exception occurred. + bool realm_begin_write( + ffi.Pointer arg0, ) { - return _realm_app_config_set_device_name( - config, - device_name, + return _realm_begin_write( + arg0, ); } - late final _realm_app_config_set_device_namePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Pointer)>>('realm_app_config_set_device_name'); - late final _realm_app_config_set_device_name = - _realm_app_config_set_device_namePtr.asFunction< - void Function( - ffi.Pointer, ffi.Pointer)>(); + late final _realm_begin_writePtr = + _lookup)>>( + 'realm_begin_write'); + late final _realm_begin_write = + _realm_begin_writePtr.asFunction)>(); - void realm_app_config_set_device_version( - ffi.Pointer config, - ffi.Pointer device_version, - ) { - return _realm_app_config_set_device_version( - config, - device_version, - ); + /// Clear the last error on the calling thread. + /// + /// Use this if the system has recovered from an error, e.g. by closing the + /// offending Realm and reopening it, freeing up resources, or similar. + /// + /// @return True if an error was cleared. + bool realm_clear_last_error() { + return _realm_clear_last_error(); } - late final _realm_app_config_set_device_versionPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Pointer)>>('realm_app_config_set_device_version'); - late final _realm_app_config_set_device_version = - _realm_app_config_set_device_versionPtr.asFunction< - void Function( - ffi.Pointer, ffi.Pointer)>(); + late final _realm_clear_last_errorPtr = + _lookup>( + 'realm_clear_last_error'); + late final _realm_clear_last_error = + _realm_clear_last_errorPtr.asFunction(); - void realm_app_config_set_framework_name( - ffi.Pointer config, - ffi.Pointer framework_name, + /// Clone a Realm C Wrapper object. + /// + /// If the object is not clonable, this function fails with RLM_ERR_NOT_CLONABLE. + /// + /// @return A pointer to an object of the same type as the input, or NULL if + /// cloning failed. + ffi.Pointer realm_clone( + ffi.Pointer arg0, ) { - return _realm_app_config_set_framework_name( - config, - framework_name, + return _realm_clone( + arg0, ); } - late final _realm_app_config_set_framework_namePtr = _lookup< + late final _realm_clonePtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Pointer)>>('realm_app_config_set_framework_name'); - late final _realm_app_config_set_framework_name = - _realm_app_config_set_framework_namePtr.asFunction< - void Function( - ffi.Pointer, ffi.Pointer)>(); - - void realm_app_config_set_framework_version( - ffi.Pointer config, - ffi.Pointer framework_version, - ) { - return _realm_app_config_set_framework_version( - config, - framework_version, - ); - } - - late final _realm_app_config_set_framework_versionPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, ffi.Pointer)>>( - 'realm_app_config_set_framework_version'); - late final _realm_app_config_set_framework_version = - _realm_app_config_set_framework_versionPtr.asFunction< - void Function( - ffi.Pointer, ffi.Pointer)>(); + ffi.Pointer Function( + ffi.Pointer)>>('realm_clone'); + late final _realm_clone = _realm_clonePtr + .asFunction Function(ffi.Pointer)>(); - void realm_app_config_set_metadata_encryption_key( - ffi.Pointer arg0, - ffi.Pointer arg1, + /// Forcibly close a Realm file. + /// + /// Note that this invalidates all Realm instances for the same path. + /// + /// The Realm will be automatically closed when the last reference is released, + /// including references to objects within the Realm. + /// + /// @return True if no exception occurred. + bool realm_close( + ffi.Pointer arg0, ) { - return _realm_app_config_set_metadata_encryption_key( + return _realm_close( arg0, - arg1, ); } - late final _realm_app_config_set_metadata_encryption_keyPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, ffi.Pointer)>>( - 'realm_app_config_set_metadata_encryption_key'); - late final _realm_app_config_set_metadata_encryption_key = - _realm_app_config_set_metadata_encryption_keyPtr.asFunction< - void Function( - ffi.Pointer, ffi.Pointer)>(); + late final _realm_closePtr = + _lookup)>>( + 'realm_close'); + late final _realm_close = + _realm_closePtr.asFunction)>(); - void realm_app_config_set_metadata_mode( - ffi.Pointer arg0, - realm_sync_client_metadata_mode arg1, + /// Get the indices of changes in a collection notification. + /// + /// Note: For moves, every `from` index will also be present among deletions, and + /// every `to` index will also be present among insertions. + /// + /// This function cannot fail. + /// + /// @param out_deletion_indices Where to put the indices of deleted elements + /// (*before* the deletion happened). May be NULL. + /// @param max_deletion_indices The max number of indices to write to @a + /// out_deletion_indices. + /// @param out_insertion_indices Where the put the indices of inserted elements + /// (*after* the insertion happened). May be NULL. + /// @param max_insertion_indices The max number of indices to write to @a + /// out_insertion_indices. + /// @param out_modification_indices Where to put the indices of modified elements + /// (*before* any insertions or deletions of + /// other elements). May be NULL. + /// @param max_modification_indices The max number of indices to write to @a + /// out_modification_indices. + /// @param out_modification_indices_after Where to put the indices of modified + /// elements (*after* any insertions or + /// deletions of other elements). May be + /// NULL. + /// @param max_modification_indices_after The max number of indices to write to + /// @a out_modification_indices_after. + /// @param out_moves Where to put the pairs of indices of moved elements. May be + /// NULL. + /// @param max_moves The max number of pairs to write to @a out_moves. + void realm_collection_changes_get_changes( + ffi.Pointer arg0, + ffi.Pointer out_deletion_indices, + int max_deletion_indices, + ffi.Pointer out_insertion_indices, + int max_insertion_indices, + ffi.Pointer out_modification_indices, + int max_modification_indices, + ffi.Pointer out_modification_indices_after, + int max_modification_indices_after, + ffi.Pointer out_moves, + int max_moves, ) { - return _realm_app_config_set_metadata_mode( + return _realm_collection_changes_get_changes( arg0, - arg1.value, + out_deletion_indices, + max_deletion_indices, + out_insertion_indices, + max_insertion_indices, + out_modification_indices, + max_modification_indices, + out_modification_indices_after, + max_modification_indices_after, + out_moves, + max_moves, ); } - late final _realm_app_config_set_metadata_modePtr = _lookup< + late final _realm_collection_changes_get_changesPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.UnsignedInt)>>('realm_app_config_set_metadata_mode'); - late final _realm_app_config_set_metadata_mode = - _realm_app_config_set_metadata_modePtr - .asFunction, int)>(); + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Size, + ffi.Pointer, + ffi.Size, + ffi.Pointer, + ffi.Size, + ffi.Pointer, + ffi.Size, + ffi.Pointer, + ffi.Size)>>('realm_collection_changes_get_changes'); + late final _realm_collection_changes_get_changes = + _realm_collection_changes_get_changesPtr.asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer, + int, + ffi.Pointer, + int, + ffi.Pointer, + int, + ffi.Pointer, + int)>(); - void realm_app_config_set_platform_version( - ffi.Pointer arg0, - ffi.Pointer arg1, + /// Get the number of various types of changes in a collection notification. + /// + /// @param out_num_deletions The number of deletions. May be NULL. + /// @param out_num_insertions The number of insertions. May be NULL. + /// @param out_num_modifications The number of modifications. May be NULL. + /// @param out_num_moves The number of moved elements. May be NULL. + /// @param out_collection_was_cleared a flag to signal if the collection has been cleared. May be NULL + /// @param out_collection_was_deleted a flag to signal if the collection has been deleted. May be NULL + void realm_collection_changes_get_num_changes( + ffi.Pointer arg0, + ffi.Pointer out_num_deletions, + ffi.Pointer out_num_insertions, + ffi.Pointer out_num_modifications, + ffi.Pointer out_num_moves, + ffi.Pointer out_collection_was_cleared, + ffi.Pointer out_collection_was_deleted, ) { - return _realm_app_config_set_platform_version( + return _realm_collection_changes_get_num_changes( arg0, - arg1, + out_num_deletions, + out_num_insertions, + out_num_modifications, + out_num_moves, + out_collection_was_cleared, + out_collection_was_deleted, ); } - late final _realm_app_config_set_platform_versionPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Pointer)>>('realm_app_config_set_platform_version'); - late final _realm_app_config_set_platform_version = - _realm_app_config_set_platform_versionPtr.asFunction< + late final _realm_collection_changes_get_num_changesPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>( + 'realm_collection_changes_get_num_changes'); + late final _realm_collection_changes_get_num_changes = + _realm_collection_changes_get_num_changesPtr.asFunction< void Function( - ffi.Pointer, ffi.Pointer)>(); + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); - void realm_app_config_set_sdk( - ffi.Pointer config, - ffi.Pointer sdk, + /// Get the number of various types of changes in a collection notification, + /// suitable for acquiring the change indices as ranges, which is much more + /// compact in memory than getting the individual indices when multiple adjacent + /// elements have been modified. + /// + /// @param out_num_deletion_ranges The number of deleted ranges. May be NULL. + /// @param out_num_insertion_ranges The number of inserted ranges. May be NULL. + /// @param out_num_modification_ranges The number of modified ranges. May be + /// NULL. + /// @param out_num_moves The number of moved elements. May be NULL. + void realm_collection_changes_get_num_ranges( + ffi.Pointer arg0, + ffi.Pointer out_num_deletion_ranges, + ffi.Pointer out_num_insertion_ranges, + ffi.Pointer out_num_modification_ranges, + ffi.Pointer out_num_moves, ) { - return _realm_app_config_set_sdk( - config, - sdk, + return _realm_collection_changes_get_num_ranges( + arg0, + out_num_deletion_ranges, + out_num_insertion_ranges, + out_num_modification_ranges, + out_num_moves, ); } - late final _realm_app_config_set_sdkPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Pointer)>>('realm_app_config_set_sdk'); - late final _realm_app_config_set_sdk = - _realm_app_config_set_sdkPtr.asFunction< + late final _realm_collection_changes_get_num_rangesPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>( + 'realm_collection_changes_get_num_ranges'); + late final _realm_collection_changes_get_num_ranges = + _realm_collection_changes_get_num_rangesPtr.asFunction< void Function( - ffi.Pointer, ffi.Pointer)>(); + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); - void realm_app_config_set_sdk_version( - ffi.Pointer arg0, - ffi.Pointer arg1, + void realm_collection_changes_get_ranges( + ffi.Pointer arg0, + ffi.Pointer out_deletion_ranges, + int max_deletion_ranges, + ffi.Pointer out_insertion_ranges, + int max_insertion_ranges, + ffi.Pointer out_modification_ranges, + int max_modification_ranges, + ffi.Pointer out_modification_ranges_after, + int max_modification_ranges_after, + ffi.Pointer out_moves, + int max_moves, ) { - return _realm_app_config_set_sdk_version( + return _realm_collection_changes_get_ranges( arg0, - arg1, + out_deletion_ranges, + max_deletion_ranges, + out_insertion_ranges, + max_insertion_ranges, + out_modification_ranges, + max_modification_ranges, + out_modification_ranges_after, + max_modification_ranges_after, + out_moves, + max_moves, ); } - late final _realm_app_config_set_sdk_versionPtr = _lookup< + late final _realm_collection_changes_get_rangesPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Pointer)>>('realm_app_config_set_sdk_version'); - late final _realm_app_config_set_sdk_version = - _realm_app_config_set_sdk_versionPtr.asFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Size, + ffi.Pointer, + ffi.Size, + ffi.Pointer, + ffi.Size, + ffi.Pointer, + ffi.Size, + ffi.Pointer, + ffi.Size)>>('realm_collection_changes_get_ranges'); + late final _realm_collection_changes_get_ranges = + _realm_collection_changes_get_rangesPtr.asFunction< void Function( - ffi.Pointer, ffi.Pointer)>(); + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer, + int, + ffi.Pointer, + int, + ffi.Pointer, + int, + ffi.Pointer, + int)>(); - void realm_app_config_set_security_access_group( - ffi.Pointer arg0, - ffi.Pointer arg1, + /// Commit a write transaction. + /// + /// @return True if the commit succeeded and no exceptions were thrown. + bool realm_commit( + ffi.Pointer arg0, ) { - return _realm_app_config_set_security_access_group( + return _realm_commit( arg0, - arg1, ); } - late final _realm_app_config_set_security_access_groupPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, ffi.Pointer)>>( - 'realm_app_config_set_security_access_group'); - late final _realm_app_config_set_security_access_group = - _realm_app_config_set_security_access_groupPtr.asFunction< - void Function( - ffi.Pointer, ffi.Pointer)>(); + late final _realm_commitPtr = + _lookup)>>( + 'realm_commit'); + late final _realm_commit = + _realm_commitPtr.asFunction)>(); - /// Create realm_app_t* instance given a valid realm app configuration. + /// Vacuum the free space from the realm file, reducing its file size. /// - /// @return A non-null pointer if no error occurred. - ffi.Pointer realm_app_create( - ffi.Pointer arg0, + /// @return True if no exceptions are thrown, false otherwise. + bool realm_compact( + ffi.Pointer arg0, + ffi.Pointer did_compact, ) { - return _realm_app_create( + return _realm_compact( arg0, + did_compact, ); } - late final _realm_app_createPtr = _lookup< + late final _realm_compactPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_app_create'); - late final _realm_app_create = _realm_app_createPtr.asFunction< - ffi.Pointer Function(ffi.Pointer)>(); + ffi.Bool Function( + ffi.Pointer, ffi.Pointer)>>('realm_compact'); + late final _realm_compact = _realm_compactPtr + .asFunction, ffi.Pointer)>(); - /// Create cached realm_app_t* instance given a valid realm app configuration. + /// True if automatic change notifications should be generated. /// - /// @return A non-null pointer if no error occurred. - ffi.Pointer realm_app_create_cached( - ffi.Pointer arg0, + /// This function cannot fail. + bool realm_config_get_automatic_change_notifications( + ffi.Pointer arg0, ) { - return _realm_app_create_cached( + return _realm_config_get_automatic_change_notifications( arg0, ); } - late final _realm_app_create_cachedPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_app_create_cached'); - late final _realm_app_create_cached = _realm_app_create_cachedPtr.asFunction< - ffi.Pointer Function(ffi.Pointer)>(); + late final _realm_config_get_automatic_change_notificationsPtr = _lookup< + ffi.NativeFunction)>>( + 'realm_config_get_automatic_change_notifications'); + late final _realm_config_get_automatic_change_notifications = + _realm_config_get_automatic_change_notificationsPtr + .asFunction)>(); - ffi.Pointer realm_app_credentials_new_anonymous( - bool reuse_credentials, + /// Check if realms are cached + bool realm_config_get_cached( + ffi.Pointer arg0, ) { - return _realm_app_credentials_new_anonymous( - reuse_credentials, + return _realm_config_get_cached( + arg0, ); } - late final _realm_app_credentials_new_anonymousPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Bool)>>('realm_app_credentials_new_anonymous'); - late final _realm_app_credentials_new_anonymous = - _realm_app_credentials_new_anonymousPtr - .asFunction Function(bool)>(); + late final _realm_config_get_cachedPtr = _lookup< + ffi.NativeFunction)>>( + 'realm_config_get_cached'); + late final _realm_config_get_cached = _realm_config_get_cachedPtr + .asFunction)>(); - ffi.Pointer realm_app_credentials_new_api_key( - ffi.Pointer api_key, + /// True if file format upgrades on open are disabled. + /// + /// This function cannot fail. + bool realm_config_get_disable_format_upgrade( + ffi.Pointer arg0, ) { - return _realm_app_credentials_new_api_key( - api_key, + return _realm_config_get_disable_format_upgrade( + arg0, ); } - late final _realm_app_credentials_new_api_keyPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_app_credentials_new_api_key'); - late final _realm_app_credentials_new_api_key = - _realm_app_credentials_new_api_keyPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer)>(); + late final _realm_config_get_disable_format_upgradePtr = _lookup< + ffi.NativeFunction)>>( + 'realm_config_get_disable_format_upgrade'); + late final _realm_config_get_disable_format_upgrade = + _realm_config_get_disable_format_upgradePtr + .asFunction)>(); - ffi.Pointer realm_app_credentials_new_apple( - ffi.Pointer id_token, + /// Get the encryption key for the realm. + /// + /// The output buffer must be at least 64 bytes. + /// + /// @returns The length of the encryption key (0 or 64) + int realm_config_get_encryption_key( + ffi.Pointer arg0, + ffi.Pointer out_key, ) { - return _realm_app_credentials_new_apple( - id_token, + return _realm_config_get_encryption_key( + arg0, + out_key, ); } - late final _realm_app_credentials_new_applePtr = _lookup< + late final _realm_config_get_encryption_keyPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_app_credentials_new_apple'); - late final _realm_app_credentials_new_apple = - _realm_app_credentials_new_applePtr.asFunction< - ffi.Pointer Function( - ffi.Pointer)>(); + ffi.Size Function(ffi.Pointer, + ffi.Pointer)>>('realm_config_get_encryption_key'); + late final _realm_config_get_encryption_key = + _realm_config_get_encryption_keyPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer)>(); - ffi.Pointer realm_app_credentials_new_email_password( - ffi.Pointer email, - realm_string_t password, + /// Check realm FIFO path + ffi.Pointer realm_config_get_fifo_path( + ffi.Pointer arg0, ) { - return _realm_app_credentials_new_email_password( - email, - password, + return _realm_config_get_fifo_path( + arg0, ); } - late final _realm_app_credentials_new_email_passwordPtr = _lookup< + late final _realm_config_get_fifo_pathPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - realm_string_t)>>('realm_app_credentials_new_email_password'); - late final _realm_app_credentials_new_email_password = - _realm_app_credentials_new_email_passwordPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, realm_string_t)>(); - - ffi.Pointer realm_app_credentials_new_facebook( - ffi.Pointer access_token, + ffi.Pointer Function( + ffi.Pointer)>>('realm_config_get_fifo_path'); + late final _realm_config_get_fifo_path = + _realm_config_get_fifo_pathPtr.asFunction< + ffi.Pointer Function(ffi.Pointer)>(); + + /// Check if realm is configured in memory + bool realm_config_get_in_memory( + ffi.Pointer arg0, ) { - return _realm_app_credentials_new_facebook( - access_token, + return _realm_config_get_in_memory( + arg0, ); } - late final _realm_app_credentials_new_facebookPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_app_credentials_new_facebook'); - late final _realm_app_credentials_new_facebook = - _realm_app_credentials_new_facebookPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer)>(); + late final _realm_config_get_in_memoryPtr = _lookup< + ffi.NativeFunction)>>( + 'realm_config_get_in_memory'); + late final _realm_config_get_in_memory = _realm_config_get_in_memoryPtr + .asFunction)>(); - /// Create Custom Function authentication app credentials. + /// Get maximum number of active versions in the realm file allowed before an + /// exception is thrown. /// - /// @param serialized_ejson_payload The arguments array to invoke the function with, - /// serialized as an Extended JSON string. - /// @return null, if an error occurred. - ffi.Pointer realm_app_credentials_new_function( - ffi.Pointer serialized_ejson_payload, + /// This function cannot fail. + int realm_config_get_max_number_of_active_versions( + ffi.Pointer arg0, ) { - return _realm_app_credentials_new_function( - serialized_ejson_payload, + return _realm_config_get_max_number_of_active_versions( + arg0, ); } - late final _realm_app_credentials_new_functionPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_app_credentials_new_function'); - late final _realm_app_credentials_new_function = - _realm_app_credentials_new_functionPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer)>(); + late final _realm_config_get_max_number_of_active_versionsPtr = _lookup< + ffi.NativeFunction)>>( + 'realm_config_get_max_number_of_active_versions'); + late final _realm_config_get_max_number_of_active_versions = + _realm_config_get_max_number_of_active_versionsPtr + .asFunction)>(); - ffi.Pointer - realm_app_credentials_new_google_auth_code( - ffi.Pointer auth_code, + /// Get the path of the realm being opened. + /// + /// This function cannot fail. + ffi.Pointer realm_config_get_path( + ffi.Pointer arg0, ) { - return _realm_app_credentials_new_google_auth_code( - auth_code, + return _realm_config_get_path( + arg0, ); } - late final _realm_app_credentials_new_google_auth_codePtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>( - 'realm_app_credentials_new_google_auth_code'); - late final _realm_app_credentials_new_google_auth_code = - _realm_app_credentials_new_google_auth_codePtr.asFunction< - ffi.Pointer Function( - ffi.Pointer)>(); + late final _realm_config_get_pathPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer)>>('realm_config_get_path'); + late final _realm_config_get_path = _realm_config_get_pathPtr.asFunction< + ffi.Pointer Function(ffi.Pointer)>(); - ffi.Pointer - realm_app_credentials_new_google_id_token( - ffi.Pointer id_token, + /// Get the schema for this realm. + /// + /// Note: The caller obtains ownership of the returned value, and must manually + /// free it by calling `realm_release()`. + /// + /// @return A schema object, or NULL if the schema is not set (empty). + ffi.Pointer realm_config_get_schema( + ffi.Pointer arg0, ) { - return _realm_app_credentials_new_google_id_token( - id_token, + return _realm_config_get_schema( + arg0, ); } - late final _realm_app_credentials_new_google_id_tokenPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>( - 'realm_app_credentials_new_google_id_token'); - late final _realm_app_credentials_new_google_id_token = - _realm_app_credentials_new_google_id_tokenPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer)>(); + late final _realm_config_get_schemaPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer)>>('realm_config_get_schema'); + late final _realm_config_get_schema = _realm_config_get_schemaPtr.asFunction< + ffi.Pointer Function(ffi.Pointer)>(); - ffi.Pointer realm_app_credentials_new_jwt( - ffi.Pointer jwt_token, + /// Get the schema mode. + /// + /// This function cannot fail. + realm_schema_mode realm_config_get_schema_mode( + ffi.Pointer arg0, ) { - return _realm_app_credentials_new_jwt( - jwt_token, - ); + return realm_schema_mode.fromValue(_realm_config_get_schema_mode( + arg0, + )); } - late final _realm_app_credentials_new_jwtPtr = _lookup< + late final _realm_config_get_schema_modePtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_app_credentials_new_jwt'); - late final _realm_app_credentials_new_jwt = - _realm_app_credentials_new_jwtPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer)>(); + ffi.UnsignedInt Function( + ffi.Pointer)>>('realm_config_get_schema_mode'); + late final _realm_config_get_schema_mode = _realm_config_get_schema_modePtr + .asFunction)>(); - /// Get an existing @a realm_app_credentials_t and return it's json representation - /// Note: the caller must delete the pointer to the string via realm_release + /// Get the subset schema mode. /// - /// @return: a non-null ptr to the string representing the json configuration. - ffi.Pointer realm_app_credentials_serialize_as_json( - ffi.Pointer arg0, + /// This function cannot fail. + realm_schema_subset_mode realm_config_get_schema_subset_mode( + ffi.Pointer arg0, ) { - return _realm_app_credentials_serialize_as_json( + return realm_schema_subset_mode + .fromValue(_realm_config_get_schema_subset_mode( arg0, - ); + )); } - late final _realm_app_credentials_serialize_as_jsonPtr = _lookup< + late final _realm_config_get_schema_subset_modePtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>( - 'realm_app_credentials_serialize_as_json'); - late final _realm_app_credentials_serialize_as_json = - _realm_app_credentials_serialize_as_jsonPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer)>(); - - /// Deletes a user and all its data from the server. - /// @param app ptr to realm_app - /// @param user ptr to the user to delete - /// @param callback invoked once operation has completed - /// @return True if no error has been recorded, False otherwise - bool realm_app_delete_user( - ffi.Pointer app, - ffi.Pointer user, - realm_app_void_completion_func_t callback, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, + ffi.UnsignedInt Function(ffi.Pointer)>>( + 'realm_config_get_schema_subset_mode'); + late final _realm_config_get_schema_subset_mode = + _realm_config_get_schema_subset_modePtr + .asFunction)>(); + + /// Get the schema version of the schema. + /// + /// This function cannot fail. + int realm_config_get_schema_version( + ffi.Pointer arg0, ) { - return _realm_app_delete_user( - app, - user, - callback, - userdata, - userdata_free, + return _realm_config_get_schema_version( + arg0, ); } - late final _realm_app_delete_userPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>('realm_app_delete_user'); - late final _realm_app_delete_user = _realm_app_delete_userPtr.asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); + late final _realm_config_get_schema_versionPtr = _lookup< + ffi.NativeFunction)>>( + 'realm_config_get_schema_version'); + late final _realm_config_get_schema_version = + _realm_config_get_schema_versionPtr + .asFunction)>(); - /// Run the Email/Password Authentication provider's password reset function. - /// - /// @param serialized_ejson_payload The arguments array to invoke the function with, - /// serialized as an Extended JSON string. - /// @return true, if no error occurred. - bool realm_app_email_password_provider_client_call_reset_password_function( - ffi.Pointer arg0, - ffi.Pointer email, - realm_string_t password, - ffi.Pointer serialized_ejson_payload, - realm_app_void_completion_func_t callback, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, + /// True if you can open the file without a file_format_upgrade + bool realm_config_needs_file_format_upgrade( + ffi.Pointer arg0, ) { - return _realm_app_email_password_provider_client_call_reset_password_function( + return _realm_config_needs_file_format_upgrade( arg0, - email, - password, - serialized_ejson_payload, - callback, - userdata, - userdata_free, ); } - late final _realm_app_email_password_provider_client_call_reset_password_functionPtr = - _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - realm_string_t, - ffi.Pointer, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_app_email_password_provider_client_call_reset_password_function'); - late final _realm_app_email_password_provider_client_call_reset_password_function = - _realm_app_email_password_provider_client_call_reset_password_functionPtr - .asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - realm_string_t, - ffi.Pointer, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); - - /// Confirms an email identity with the username/password provider. - /// @param app ptr to realm_app - /// @param token string emailed - /// @param token_id string emailed - /// @param callback invoked once operation has completed - /// @return True if no error has been recorded, False otherwise - bool realm_app_email_password_provider_client_confirm_user( - ffi.Pointer app, - ffi.Pointer token, - ffi.Pointer token_id, - realm_app_void_completion_func_t callback, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, - ) { - return _realm_app_email_password_provider_client_confirm_user( - app, - token, - token_id, - callback, - userdata, - userdata_free, - ); + late final _realm_config_needs_file_format_upgradePtr = _lookup< + ffi.NativeFunction)>>( + 'realm_config_needs_file_format_upgrade'); + late final _realm_config_needs_file_format_upgrade = + _realm_config_needs_file_format_upgradePtr + .asFunction)>(); + + /// Allocate a new configuration with default options. + ffi.Pointer realm_config_new() { + return _realm_config_new(); } - late final _realm_app_email_password_provider_client_confirm_userPtr = - _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_app_email_password_provider_client_confirm_user'); - late final _realm_app_email_password_provider_client_confirm_user = - _realm_app_email_password_provider_client_confirm_userPtr.asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); + late final _realm_config_newPtr = + _lookup Function()>>( + 'realm_config_new'); + late final _realm_config_new = + _realm_config_newPtr.asFunction Function()>(); - /// Registers a new email identity with the username/password provider and send confirmation email. - /// @param app ptr to realm_app - /// @param email identity email - /// @param password associated to the identity - /// @param callback invoked once operation has completed - /// @return True if no error has been recorded, False otherwise - bool realm_app_email_password_provider_client_register_email( - ffi.Pointer app, - ffi.Pointer email, - realm_string_t password, - realm_app_void_completion_func_t callback, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, + /// Allow realm to manage automatically embedded objects when a migration from TopLevel to Embedded takes place. + void realm_config_set_automatic_backlink_handling( + ffi.Pointer arg0, + bool arg1, ) { - return _realm_app_email_password_provider_client_register_email( - app, - email, - password, - callback, - userdata, - userdata_free, + return _realm_config_set_automatic_backlink_handling( + arg0, + arg1, ); } - late final _realm_app_email_password_provider_client_register_emailPtr = - _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - realm_string_t, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_app_email_password_provider_client_register_email'); - late final _realm_app_email_password_provider_client_register_email = - _realm_app_email_password_provider_client_register_emailPtr.asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - realm_string_t, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); + late final _realm_config_set_automatic_backlink_handlingPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, + ffi.Bool)>>('realm_config_set_automatic_backlink_handling'); + late final _realm_config_set_automatic_backlink_handling = + _realm_config_set_automatic_backlink_handlingPtr + .asFunction, bool)>(); - /// Re-sends a confirmation email to a user that has registered but not yet confirmed their email address. - /// @param app ptr to realm_app - /// @param email to use - /// @param callback invoked once operation has completed - /// @return True if no error has been recorded, False otherwise - bool realm_app_email_password_provider_client_resend_confirmation_email( - ffi.Pointer app, - ffi.Pointer email, - realm_app_void_completion_func_t callback, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, + /// Automatically generated change notifications (default: true). + /// + /// This function cannot fail. + void realm_config_set_automatic_change_notifications( + ffi.Pointer arg0, + bool arg1, ) { - return _realm_app_email_password_provider_client_resend_confirmation_email( - app, - email, - callback, - userdata, - userdata_free, + return _realm_config_set_automatic_change_notifications( + arg0, + arg1, ); } - late final _realm_app_email_password_provider_client_resend_confirmation_emailPtr = - _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_app_email_password_provider_client_resend_confirmation_email'); - late final _realm_app_email_password_provider_client_resend_confirmation_email = - _realm_app_email_password_provider_client_resend_confirmation_emailPtr - .asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); - - /// Resets the password of an email identity using the password reset token emailed to a user. - /// @param app ptr to realm_app - /// @param password new password to set - /// @param token ptr to token string emailed to the user - /// @param token_id ptr to token_id emailed to the user - /// @return True if no error has been recorded, False otherwise - bool realm_app_email_password_provider_client_reset_password( - ffi.Pointer app, - realm_string_t password, - ffi.Pointer token, - ffi.Pointer token_id, - realm_app_void_completion_func_t callback, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, + late final _realm_config_set_automatic_change_notificationsPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, + ffi.Bool)>>('realm_config_set_automatic_change_notifications'); + late final _realm_config_set_automatic_change_notifications = + _realm_config_set_automatic_change_notificationsPtr + .asFunction, bool)>(); + + /// If 'cached' is false, always return a new Realm instance. + void realm_config_set_cached( + ffi.Pointer arg0, + bool cached, ) { - return _realm_app_email_password_provider_client_reset_password( - app, - password, - token, - token_id, - callback, - userdata, - userdata_free, + return _realm_config_set_cached( + arg0, + cached, ); } - late final _realm_app_email_password_provider_client_reset_passwordPtr = - _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - realm_string_t, - ffi.Pointer, - ffi.Pointer, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_app_email_password_provider_client_reset_password'); - late final _realm_app_email_password_provider_client_reset_password = - _realm_app_email_password_provider_client_reset_passwordPtr.asFunction< - bool Function( - ffi.Pointer, - realm_string_t, - ffi.Pointer, - ffi.Pointer, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); + late final _realm_config_set_cachedPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, + ffi.Bool)>>('realm_config_set_cached'); + late final _realm_config_set_cached = _realm_config_set_cachedPtr + .asFunction, bool)>(); - /// Retries the custom confirmation function on a user for a given email. - /// @param app ptr to realm_app - /// @param email email for the user - /// @param callback invoked once operation has completed - /// @return True if no error has been recorded, False otherwise - bool realm_app_email_password_provider_client_retry_custom_confirmation( - ffi.Pointer app, - ffi.Pointer email, - realm_app_void_completion_func_t callback, + /// Set the data initialization function. + /// + /// The callback is invoked the first time the schema is created, such that the + /// user can perform one-time initialization of the data in the realm. + /// + /// The realm instance passed to the callback is in a write transaction. + /// + /// This function cannot fail. + void realm_config_set_data_initialization_function( + ffi.Pointer arg0, + realm_data_initialization_func_t arg1, ffi.Pointer userdata, realm_free_userdata_func_t userdata_free, ) { - return _realm_app_email_password_provider_client_retry_custom_confirmation( - app, - email, - callback, + return _realm_config_set_data_initialization_function( + arg0, + arg1, userdata, userdata_free, ); } - late final _realm_app_email_password_provider_client_retry_custom_confirmationPtr = - _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_app_email_password_provider_client_retry_custom_confirmation'); - late final _realm_app_email_password_provider_client_retry_custom_confirmation = - _realm_app_email_password_provider_client_retry_custom_confirmationPtr - .asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - realm_app_void_completion_func_t, + late final _realm_config_set_data_initialization_functionPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + realm_data_initialization_func_t, ffi.Pointer, - realm_free_userdata_func_t)>(); - - /// Send reset password to the email specified in the parameter passed to the function. - /// @param app ptr to realm_app - /// @param email where to send the reset instructions - /// @param callback invoked once operation has completed - /// @return True if no error has been recorded, False otherwise - bool realm_app_email_password_provider_client_send_reset_password_email( - ffi.Pointer app, - ffi.Pointer email, - realm_app_void_completion_func_t callback, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, - ) { - return _realm_app_email_password_provider_client_send_reset_password_email( - app, - email, - callback, - userdata, - userdata_free, - ); - } - - late final _realm_app_email_password_provider_client_send_reset_password_emailPtr = - _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_app_email_password_provider_client_send_reset_password_email'); - late final _realm_app_email_password_provider_client_send_reset_password_email = - _realm_app_email_password_provider_client_send_reset_password_emailPtr - .asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); + realm_free_userdata_func_t)>>( + 'realm_config_set_data_initialization_function'); + late final _realm_config_set_data_initialization_function = + _realm_config_set_data_initialization_functionPtr.asFunction< + void Function( + ffi.Pointer, + realm_data_initialization_func_t, + ffi.Pointer, + realm_free_userdata_func_t)>(); - /// Get the list of active users in this @a app. - /// In case of errors this function will return false (errors to be fetched via `realm_get_last_error()`). - /// If data is not copied the function will return true and set `out_n` with the capacity needed. - /// Data is only copied if the input array has enough capacity, otherwise the needed array capacity will be set. + /// Disable file format upgrade on open (default: false). /// - /// @param out_users A pointer to an array of `realm_user_t*`, which - /// will be populated with the list of active users in the app. - /// Array may be NULL, in this case no data will be copied and `out_n` set if not NULL. - /// @param capacity The maximum number of elements `out_users` can hold. - /// @param out_n The actual number of entries written to `out_users`. - /// May be NULL. - /// @return True if no exception occurred. - bool realm_app_get_all_users( - ffi.Pointer app, - ffi.Pointer> out_users, - int capacity, - ffi.Pointer out_n, - ) { - return _realm_app_get_all_users( - app, - out_users, - capacity, - out_n, - ); - } - - late final _realm_app_get_all_usersPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Size, - ffi.Pointer)>>('realm_app_get_all_users'); - late final _realm_app_get_all_users = _realm_app_get_all_usersPtr.asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer>, - int, - ffi.Pointer)>(); - - ffi.Pointer realm_app_get_app_id( - ffi.Pointer arg0, + /// If a migration is needed to open the realm file with the provided schema, an + /// error is thrown rather than automatically performing the migration. + /// + /// This function cannot fail. + void realm_config_set_disable_format_upgrade( + ffi.Pointer arg0, + bool arg1, ) { - return _realm_app_get_app_id( + return _realm_config_set_disable_format_upgrade( arg0, + arg1, ); } - late final _realm_app_get_app_idPtr = _lookup< + late final _realm_config_set_disable_format_upgradePtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_app_get_app_id'); - late final _realm_app_get_app_id = _realm_app_get_app_idPtr - .asFunction Function(ffi.Pointer)>(); + ffi.Void Function(ffi.Pointer, + ffi.Bool)>>('realm_config_set_disable_format_upgrade'); + late final _realm_config_set_disable_format_upgrade = + _realm_config_set_disable_format_upgradePtr + .asFunction, bool)>(); - /// Return the current base URL value used by the app. If the realm_app_update_base_url() is called, this - /// value will match the base_url value provided to that function when the update is complete. The value - /// provided by this function is undefined if the realm_app_update_base_url() operation is in progress, - /// since it will likely be the base_url value prior to realm_app_update_base_url() being called. + /// Set the encryption key for the realm. /// - /// @param app ptr to realm_app - /// @return The current base URL string used by the app + /// The key must be either 64 bytes long or have length zero (in which case + /// encryption is disabled). /// - /// Return value must be manually released with realm_free(). - ffi.Pointer realm_app_get_base_url( - ffi.Pointer app, + /// This function may fail if the encryption key has the wrong length. + bool realm_config_set_encryption_key( + ffi.Pointer arg0, + ffi.Pointer key, + int key_size, ) { - return _realm_app_get_base_url( - app, + return _realm_config_set_encryption_key( + arg0, + key, + key_size, ); } - late final _realm_app_get_base_urlPtr = _lookup< + late final _realm_config_set_encryption_keyPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_app_get_base_url'); - late final _realm_app_get_base_url = _realm_app_get_base_urlPtr - .asFunction Function(ffi.Pointer)>(); + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Size)>>('realm_config_set_encryption_key'); + late final _realm_config_set_encryption_key = + _realm_config_set_encryption_keyPtr.asFunction< + bool Function( + ffi.Pointer, ffi.Pointer, int)>(); - /// Get a cached realm_app_t* instance given an app id. out_app may be null if the app with this id hasn't been - /// previously cached by calling realm_app_create_cached. - /// - /// @return true if no error occurred. - bool realm_app_get_cached( - ffi.Pointer app_id, - ffi.Pointer base_url, - ffi.Pointer> out_app, + /// Set FIFO path + void realm_config_set_fifo_path( + ffi.Pointer arg0, + ffi.Pointer arg1, ) { - return _realm_app_get_cached( - app_id, - base_url, - out_app, + return _realm_config_set_fifo_path( + arg0, + arg1, ); } - late final _realm_app_get_cachedPtr = _lookup< + late final _realm_config_set_fifo_pathPtr = _lookup< ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer>)>>('realm_app_get_cached'); - late final _realm_app_get_cached = _realm_app_get_cachedPtr.asFunction< - bool Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer>)>(); + ffi.Void Function(ffi.Pointer, + ffi.Pointer)>>('realm_config_set_fifo_path'); + late final _realm_config_set_fifo_path = + _realm_config_set_fifo_pathPtr.asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); - ffi.Pointer realm_app_get_current_user( - ffi.Pointer arg0, + /// Configure realm to be in memory + void realm_config_set_in_memory( + ffi.Pointer arg0, + bool arg1, ) { - return _realm_app_get_current_user( + return _realm_config_set_in_memory( arg0, + arg1, ); } - late final _realm_app_get_current_userPtr = _lookup< + late final _realm_config_set_in_memoryPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_app_get_current_user'); - late final _realm_app_get_current_user = - _realm_app_get_current_userPtr.asFunction< - ffi.Pointer Function(ffi.Pointer)>(); - - ffi.Pointer realm_app_get_default_base_url() { - return _realm_app_get_default_base_url(); - } + ffi.Void Function(ffi.Pointer, + ffi.Bool)>>('realm_config_set_in_memory'); + late final _realm_config_set_in_memory = _realm_config_set_in_memoryPtr + .asFunction, bool)>(); - late final _realm_app_get_default_base_urlPtr = - _lookup Function()>>( - 'realm_app_get_default_base_url'); - late final _realm_app_get_default_base_url = - _realm_app_get_default_base_urlPtr - .asFunction Function()>(); - - /// Links the currently authenticated user with a new identity, where the identity is defined by the credentia - /// specified as a parameter. - /// @param app ptr to realm_app - /// @param user ptr to the user to link - /// @param credentials sync credentials - /// @param callback invoked once operation has completed - /// @param userdata custom userdata ptr - /// @param userdata_free deleter for custom userdata - /// @return True if no error has been recorded, False otherwise - bool realm_app_link_user( - ffi.Pointer app, - ffi.Pointer user, - ffi.Pointer credentials, - realm_app_user_completion_func_t callback, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, + /// Set maximum number of active versions in the realm file allowed before an + /// exception is thrown (default: UINT64_MAX). + /// + /// This function cannot fail. + void realm_config_set_max_number_of_active_versions( + ffi.Pointer arg0, + int arg1, ) { - return _realm_app_link_user( - app, - user, - credentials, - callback, - userdata, - userdata_free, + return _realm_config_set_max_number_of_active_versions( + arg0, + arg1, ); } - late final _realm_app_link_userPtr = _lookup< + late final _realm_config_set_max_number_of_active_versionsPtr = _lookup< ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - realm_app_user_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>('realm_app_link_user'); - late final _realm_app_link_user = _realm_app_link_userPtr.asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - realm_app_user_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); + ffi.Void Function(ffi.Pointer, + ffi.Uint64)>>('realm_config_set_max_number_of_active_versions'); + late final _realm_config_set_max_number_of_active_versions = + _realm_config_set_max_number_of_active_versionsPtr + .asFunction, int)>(); - /// Log in a user and asynchronously retrieve a user object. Inform caller via callback once operation completes. - /// @param app ptr to realm_app - /// @param credentials sync credentials - /// @param callback invoked once operation has completed - /// @return True if no error has been recorded, False otherwise - bool realm_app_log_in_with_credentials( - ffi.Pointer app, - ffi.Pointer credentials, - realm_app_user_completion_func_t callback, + /// Set the migration callback. + /// + /// The migration function is called during a migration for schema modes + /// `RLM_SCHEMA_MODE_AUTOMATIC` and `RLM_SCHEMA_MODE_MANUAL`. The callback is + /// invoked with a realm instance before the migration and the realm instance + /// that is currently performing the migration. + /// + /// This function cannot fail. + void realm_config_set_migration_function( + ffi.Pointer arg0, + realm_migration_func_t arg1, ffi.Pointer userdata, realm_free_userdata_func_t userdata_free, ) { - return _realm_app_log_in_with_credentials( - app, - credentials, - callback, + return _realm_config_set_migration_function( + arg0, + arg1, userdata, userdata_free, ); } - late final _realm_app_log_in_with_credentialsPtr = _lookup< + late final _realm_config_set_migration_functionPtr = _lookup< ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - realm_app_user_completion_func_t, + ffi.Void Function( + ffi.Pointer, + realm_migration_func_t, ffi.Pointer, realm_free_userdata_func_t)>>( - 'realm_app_log_in_with_credentials'); - late final _realm_app_log_in_with_credentials = - _realm_app_log_in_with_credentialsPtr.asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - realm_app_user_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); + 'realm_config_set_migration_function'); + late final _realm_config_set_migration_function = + _realm_config_set_migration_functionPtr.asFunction< + void Function(ffi.Pointer, realm_migration_func_t, + ffi.Pointer, realm_free_userdata_func_t)>(); - /// Log out the given user if they are not already logged out. - /// @param app ptr to realm_app - /// @param user ptr to user - /// @param callback invoked once operation has completed - /// @return True if no error has been recorded, False otherwise - bool realm_app_log_out( - ffi.Pointer app, - ffi.Pointer user, - realm_app_void_completion_func_t callback, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, + /// Set the path of the realm being opened. + /// + /// This function aborts when out of memory, but otherwise cannot fail. + void realm_config_set_path( + ffi.Pointer arg0, + ffi.Pointer path, ) { - return _realm_app_log_out( - app, - user, - callback, - userdata, - userdata_free, + return _realm_config_set_path( + arg0, + path, ); } - late final _realm_app_log_outPtr = _lookup< + late final _realm_config_set_pathPtr = _lookup< ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>('realm_app_log_out'); - late final _realm_app_log_out = _realm_app_log_outPtr.asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); + ffi.Void Function(ffi.Pointer, + ffi.Pointer)>>('realm_config_set_path'); + late final _realm_config_set_path = _realm_config_set_pathPtr.asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); - /// Logout the current user. - /// @param app ptr to realm_app - /// @param callback invoked once operation has completed - /// @param userdata custom userdata ptr - /// @param userdata_free deleter for custom userdata - /// @return True if no error has been recorded, False otherwise - bool realm_app_log_out_current_user( - ffi.Pointer app, - realm_app_void_completion_func_t callback, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, + /// The scheduler which this realm should be bound to (default: NULL). + /// + /// If NULL, the realm will be bound to the default scheduler for the current thread. + /// + /// This function aborts when out of memory, but otherwise cannot fail. + void realm_config_set_scheduler( + ffi.Pointer arg0, + ffi.Pointer arg1, ) { - return _realm_app_log_out_current_user( - app, - callback, - userdata, - userdata_free, + return _realm_config_set_scheduler( + arg0, + arg1, ); } - late final _realm_app_log_out_current_userPtr = _lookup< + late final _realm_config_set_schedulerPtr = _lookup< ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>('realm_app_log_out_current_user'); - late final _realm_app_log_out_current_user = - _realm_app_log_out_current_userPtr.asFunction< - bool Function( - ffi.Pointer, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); + ffi.Void Function(ffi.Pointer, + ffi.Pointer)>>('realm_config_set_scheduler'); + late final _realm_config_set_scheduler = + _realm_config_set_schedulerPtr.asFunction< + void Function( + ffi.Pointer, ffi.Pointer)>(); - /// Deregister a device for push notificatons - /// @return True if no error was recorded. False otherwise - bool realm_app_push_notification_client_deregister_device( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer service_name, - realm_app_void_completion_func_t arg3, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, + /// Set the schema object for this realm. + /// + /// This does not take ownership of the schema object, and it should be released + /// afterwards. + /// + /// This function aborts when out of memory, but otherwise cannot fail. + /// + /// @param schema The schema object. May be NULL, which means an empty schema. + void realm_config_set_schema( + ffi.Pointer arg0, + ffi.Pointer schema, ) { - return _realm_app_push_notification_client_deregister_device( + return _realm_config_set_schema( arg0, - arg1, - service_name, - arg3, - userdata, - userdata_free, + schema, ); } - late final _realm_app_push_notification_client_deregister_devicePtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_app_push_notification_client_deregister_device'); - late final _realm_app_push_notification_client_deregister_device = - _realm_app_push_notification_client_deregister_devicePtr.asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); + late final _realm_config_set_schemaPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, + ffi.Pointer)>>('realm_config_set_schema'); + late final _realm_config_set_schema = _realm_config_set_schemaPtr.asFunction< + void Function( + ffi.Pointer, ffi.Pointer)>(); - /// Register a device for push notifications. - /// @return True if no error was recorded. False otherwise - bool realm_app_push_notification_client_register_device( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer service_name, - ffi.Pointer registration_token, - realm_app_void_completion_func_t arg4, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, + /// Set the schema mode. + /// + /// This function cannot fail. + void realm_config_set_schema_mode( + ffi.Pointer arg0, + realm_schema_mode arg1, ) { - return _realm_app_push_notification_client_register_device( + return _realm_config_set_schema_mode( arg0, - arg1, - service_name, - registration_token, - arg4, - userdata, - userdata_free, + arg1.value, ); } - late final _realm_app_push_notification_client_register_devicePtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_app_push_notification_client_register_device'); - late final _realm_app_push_notification_client_register_device = - _realm_app_push_notification_client_register_devicePtr.asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); + late final _realm_config_set_schema_modePtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, + ffi.UnsignedInt)>>('realm_config_set_schema_mode'); + late final _realm_config_set_schema_mode = _realm_config_set_schema_modePtr + .asFunction, int)>(); - /// Refreshes the custom data for a specified user. - /// @param app ptr to realm_app - /// @param user ptr to user - /// @param callback invoked once operation has completed - /// @return True if no error has been recorded, False otherwise - bool realm_app_refresh_custom_data( - ffi.Pointer app, - ffi.Pointer user, - realm_app_void_completion_func_t callback, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, + /// Set schema subset mode + /// + /// This function cannot fail + void realm_config_set_schema_subset_mode( + ffi.Pointer arg0, + realm_schema_subset_mode arg1, ) { - return _realm_app_refresh_custom_data( - app, - user, - callback, - userdata, - userdata_free, + return _realm_config_set_schema_subset_mode( + arg0, + arg1.value, ); } - late final _realm_app_refresh_custom_dataPtr = _lookup< + late final _realm_config_set_schema_subset_modePtr = _lookup< ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>('realm_app_refresh_custom_data'); - late final _realm_app_refresh_custom_data = - _realm_app_refresh_custom_dataPtr.asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); + ffi.Void Function(ffi.Pointer, + ffi.UnsignedInt)>>('realm_config_set_schema_subset_mode'); + late final _realm_config_set_schema_subset_mode = + _realm_config_set_schema_subset_modePtr + .asFunction, int)>(); + + /// Set the schema version of the schema. + /// + /// This function cannot fail. + void realm_config_set_schema_version( + ffi.Pointer arg0, + int version, + ) { + return _realm_config_set_schema_version( + arg0, + version, + ); + } + + late final _realm_config_set_schema_versionPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, + ffi.Uint64)>>('realm_config_set_schema_version'); + late final _realm_config_set_schema_version = + _realm_config_set_schema_versionPtr + .asFunction, int)>(); - /// Logs out and removes the provided user. - /// @param app ptr to realm_app - /// @param user ptr to the user to remove - /// @param callback invoked once operation has completed - /// @param userdata custom userdata ptr - /// @param userdata_free deleter for custom userdata - /// @return True if no error has been recorded, False otherwise - bool realm_app_remove_user( - ffi.Pointer app, - ffi.Pointer user, - realm_app_void_completion_func_t callback, + /// Set the should-compact-on-launch callback. + /// + /// The callback is invoked the first time a realm file is opened in this process + /// to decide whether the realm file should be compacted. + /// + /// Note: If another process has the realm file open, it will not be compacted. + /// + /// This function cannot fail. + void realm_config_set_should_compact_on_launch_function( + ffi.Pointer arg0, + realm_should_compact_on_launch_func_t arg1, ffi.Pointer userdata, realm_free_userdata_func_t userdata_free, ) { - return _realm_app_remove_user( - app, - user, - callback, + return _realm_config_set_should_compact_on_launch_function( + arg0, + arg1, userdata, userdata_free, ); } - late final _realm_app_remove_userPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - realm_app_void_completion_func_t, + late final _realm_config_set_should_compact_on_launch_functionPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + realm_should_compact_on_launch_func_t, + ffi.Pointer, + realm_free_userdata_func_t)>>( + 'realm_config_set_should_compact_on_launch_function'); + late final _realm_config_set_should_compact_on_launch_function = + _realm_config_set_should_compact_on_launch_functionPtr.asFunction< + void Function( + ffi.Pointer, + realm_should_compact_on_launch_func_t, ffi.Pointer, - realm_free_userdata_func_t)>>('realm_app_remove_user'); - late final _realm_app_remove_user = _realm_app_remove_userPtr.asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); + realm_free_userdata_func_t)>(); - /// Switches the active user with the specified one. The user must exist in the list of all users who have logged into - /// this application. - /// @param app ptr to realm_app - /// @param user ptr to user to set as current. - /// @return True if no error has been recorded, False otherwise - bool realm_app_switch_user( - ffi.Pointer app, - ffi.Pointer user, + /// The overloaded Realm::convert function offers a way to copy and/or convert a realm. + /// + /// The following options are supported: + /// - local -> local (config or path) + /// - local -> sync (config only) + /// - sync -> local (config only) + /// - sync -> sync (config or path) + /// - sync -> bundlable sync (client file identifier removed) + /// + /// Note that for bundled realms it is required that all local changes are synchronized with the + /// server before the copy can be written. This is to be sure that the file can be used as a + /// stating point for a newly installed application. The function will throw if there are + /// pending uploads. + /// / + /// /** + /// Copy or convert a Realm using a config. + /// + /// If the file already exists and merge_with_existing is true, data will be copied over object per object. + /// When merging, all classes must have a pk called '_id" otherwise an exception is thrown. + /// If the file exists and merge_with_existing is false, an exception is thrown. + /// If the file does not exist, the realm file will be exported to the new location and if the + /// configuration object contains a sync part, a sync history will be synthesized. + /// + /// @param config The realm configuration that should be used to create a copy. + /// This can be a local or a synced Realm, encrypted or not. + /// @param merge_with_existing If this is true and the destination file exists, data will be copied over object by + /// object. Otherwise, if this is false and the destination file exists, an exception is thrown. + bool realm_convert_with_config( + ffi.Pointer realm, + ffi.Pointer config, + bool merge_with_existing, ) { - return _realm_app_switch_user( - app, - user, + return _realm_convert_with_config( + realm, + config, + merge_with_existing, ); } - late final _realm_app_switch_userPtr = _lookup< + late final _realm_convert_with_configPtr = _lookup< ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, - ffi.Pointer)>>('realm_app_switch_user'); - late final _realm_app_switch_user = _realm_app_switch_userPtr.asFunction< - bool Function(ffi.Pointer, ffi.Pointer)>(); + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Bool)>>('realm_convert_with_config'); + late final _realm_convert_with_config = + _realm_convert_with_configPtr.asFunction< + bool Function( + ffi.Pointer, ffi.Pointer, bool)>(); - /// Get the default realm file path based on the user and partition value in the config. - /// - /// @param custom_filename custom name for the realm file itself. Can be null, - /// in which case a default name based on the config will be used. + /// Copy a Realm using a path. /// - /// Return value must be manually released with realm_free(). - ffi.Pointer realm_app_sync_client_get_default_file_path_for_realm( - ffi.Pointer arg0, - ffi.Pointer custom_filename, + /// @param path The path the realm should be copied to. Local realms will remain local, synced + /// realms will remain synced realms. + /// @param encryption_key The optional encryption key for the new realm. + /// @param merge_with_existing If this is true and the destination file exists, data will be copied over object by + /// object. + /// Otherwise, if this is false and the destination file exists, an exception is thrown. + bool realm_convert_with_path( + ffi.Pointer realm, + ffi.Pointer path, + realm_binary_t encryption_key, + bool merge_with_existing, ) { - return _realm_app_sync_client_get_default_file_path_for_realm( - arg0, - custom_filename, + return _realm_convert_with_path( + realm, + path, + encryption_key, + merge_with_existing, ); } - late final _realm_app_sync_client_get_default_file_path_for_realmPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer)>>( - 'realm_app_sync_client_get_default_file_path_for_realm'); - late final _realm_app_sync_client_get_default_file_path_for_realm = - _realm_app_sync_client_get_default_file_path_for_realmPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, ffi.Pointer)>(); + late final _realm_convert_with_pathPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + realm_binary_t, ffi.Bool)>>('realm_convert_with_path'); + late final _realm_convert_with_path = _realm_convert_with_pathPtr.asFunction< + bool Function( + ffi.Pointer, ffi.Pointer, realm_binary_t, bool)>(); - /// Get whether there are any active sync sessions for this app. - bool realm_app_sync_client_has_sessions( - ffi.Pointer arg0, + /// Helper method for making it easier to to convert SDK input to the underlying + /// `realm_key_path_array_t`. + /// + /// @return A pointer to the converted key path array. NULL in case of an error. + ffi.Pointer realm_create_key_path_array( + ffi.Pointer realm, + int object_class_key, + int num_key_paths, + ffi.Pointer> user_key_paths, ) { - return _realm_app_sync_client_has_sessions( - arg0, + return _realm_create_key_path_array( + realm, + object_class_key, + num_key_paths, + user_key_paths, ); } - late final _realm_app_sync_client_has_sessionsPtr = - _lookup)>>( - 'realm_app_sync_client_has_sessions'); - late final _realm_app_sync_client_has_sessions = - _realm_app_sync_client_has_sessionsPtr - .asFunction)>(); + late final _realm_create_key_path_arrayPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + realm_class_key_t, + ffi.Size, + ffi.Pointer>)>>( + 'realm_create_key_path_array'); + late final _realm_create_key_path_array = + _realm_create_key_path_arrayPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, + int, int, ffi.Pointer>)>(); - /// Instruct this app's sync client to immediately reconnect. - /// Useful when the device has been offline and then receives a network reachability update. + /// Get a thread-safe reference representing the same underlying object as some + /// API object. + /// + /// The thread safe reference can be passed to a different thread and resolved + /// against a different `realm_t` instance, which succeeds if the underlying + /// object still exists. + /// + /// The following types can produce thread safe references: + /// + /// - `realm_object_t` + /// - `realm_results_t` + /// - `realm_list_t` + /// - `realm_t` + /// + /// This does not assume ownership of the object, except for `realm_t`, where the + /// instance is transferred by value, and must be transferred back to the current + /// thread to be used. Note that the `realm_thread_safe_reference_t` object must + /// still be destroyed after having been converted into a `realm_t` object. /// - /// The sync client will always attempt to reconnect eventually, this is just a hint. - void realm_app_sync_client_reconnect( - ffi.Pointer arg0, + /// @return A non-null pointer if no exception occurred. + ffi.Pointer realm_create_thread_safe_reference( + ffi.Pointer arg0, ) { - return _realm_app_sync_client_reconnect( + return _realm_create_thread_safe_reference( arg0, ); } - late final _realm_app_sync_client_reconnectPtr = - _lookup)>>( - 'realm_app_sync_client_reconnect'); - late final _realm_app_sync_client_reconnect = - _realm_app_sync_client_reconnectPtr - .asFunction)>(); + late final _realm_create_thread_safe_referencePtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer)>>('realm_create_thread_safe_reference'); + late final _realm_create_thread_safe_reference = + _realm_create_thread_safe_referencePtr.asFunction< + ffi.Pointer Function( + ffi.Pointer)>(); - /// Wait until the sync client has terminated all sessions and released all realm files - /// it had open. - /// - /// WARNING: this is a blocking wait. - void realm_app_sync_client_wait_for_sessions_to_terminate( - ffi.Pointer arg0, + void realm_dart_attach_logger( + int port, ) { - return _realm_app_sync_client_wait_for_sessions_to_terminate( - arg0, + return _realm_dart_attach_logger( + port, ); } - late final _realm_app_sync_client_wait_for_sessions_to_terminatePtr = - _lookup)>>( - 'realm_app_sync_client_wait_for_sessions_to_terminate'); - late final _realm_app_sync_client_wait_for_sessions_to_terminate = - _realm_app_sync_client_wait_for_sessions_to_terminatePtr - .asFunction)>(); + late final _realm_dart_attach_loggerPtr = + _lookup>( + 'realm_dart_attach_logger'); + late final _realm_dart_attach_logger = + _realm_dart_attach_loggerPtr.asFunction(); - /// Update the URL used to communicate with the Realm server. This function will update the location - /// information used for http and websocket requests to the server. Once this operation has completed, - /// the new base_url value returned by realm_app_get_base_url() will match the base_url value provided - /// to this function. Any App requests performed while the base URl update is currently in progress - /// will continue to use the original base URL value. - /// - /// @param app ptr to realm_app - /// @param base_url The new base URL value to set as the Realm server URL - a null or empty string will - /// use the default base URL value - /// @param callback invoked once operation has completed - /// @return True if no error has been recorded, False otherwise - bool realm_app_update_base_url( - ffi.Pointer app, - ffi.Pointer base_url, - realm_app_void_completion_func_t callback, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, + ffi.Pointer realm_dart_create_scheduler( + int isolateId, + int port, ) { - return _realm_app_update_base_url( - app, - base_url, - callback, - userdata, - userdata_free, + return _realm_dart_create_scheduler( + isolateId, + port, ); } - late final _realm_app_update_base_urlPtr = _lookup< + late final _realm_dart_create_schedulerPtr = _lookup< ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>('realm_app_update_base_url'); - late final _realm_app_update_base_url = - _realm_app_update_base_urlPtr.asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); - - /// Creates a user API key that can be used to authenticate as the current user. - /// @return True if no error was recorded. False otherwise - bool realm_app_user_apikey_provider_client_create_apikey( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer name, - realm_return_apikey_func_t callback, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, + ffi.Pointer Function( + ffi.Uint64, Dart_Port)>>('realm_dart_create_scheduler'); + late final _realm_dart_create_scheduler = _realm_dart_create_schedulerPtr + .asFunction Function(int, int)>(); + + realm_decimal128_t realm_dart_decimal128_add( + realm_decimal128_t x, + realm_decimal128_t y, ) { - return _realm_app_user_apikey_provider_client_create_apikey( - arg0, - arg1, - name, - callback, - userdata, - userdata_free, + return _realm_dart_decimal128_add( + x, + y, ); } - late final _realm_app_user_apikey_provider_client_create_apikeyPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - realm_return_apikey_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_app_user_apikey_provider_client_create_apikey'); - late final _realm_app_user_apikey_provider_client_create_apikey = - _realm_app_user_apikey_provider_client_create_apikeyPtr.asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - realm_return_apikey_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); + late final _realm_dart_decimal128_addPtr = _lookup< + ffi.NativeFunction< + realm_decimal128_t Function(realm_decimal128_t, + realm_decimal128_t)>>('realm_dart_decimal128_add'); + late final _realm_dart_decimal128_add = + _realm_dart_decimal128_addPtr.asFunction< + realm_decimal128_t Function( + realm_decimal128_t, realm_decimal128_t)>(); - /// Deletes a user API key associated with the current user. - /// @return True if no error was recorded. False otherwise - bool realm_app_user_apikey_provider_client_delete_apikey( - ffi.Pointer arg0, - ffi.Pointer arg1, - realm_object_id_t id, - realm_app_void_completion_func_t callback, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, + int realm_dart_decimal128_compare_to( + realm_decimal128_t x, + realm_decimal128_t y, ) { - return _realm_app_user_apikey_provider_client_delete_apikey( - arg0, - arg1, - id, - callback, - userdata, - userdata_free, + return _realm_dart_decimal128_compare_to( + x, + y, ); } - late final _realm_app_user_apikey_provider_client_delete_apikeyPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - realm_object_id_t, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_app_user_apikey_provider_client_delete_apikey'); - late final _realm_app_user_apikey_provider_client_delete_apikey = - _realm_app_user_apikey_provider_client_delete_apikeyPtr.asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - realm_object_id_t, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); + late final _realm_dart_decimal128_compare_toPtr = _lookup< + ffi.NativeFunction< + ffi.Int Function(realm_decimal128_t, + realm_decimal128_t)>>('realm_dart_decimal128_compare_to'); + late final _realm_dart_decimal128_compare_to = + _realm_dart_decimal128_compare_toPtr + .asFunction(); - /// Disables a user API key associated with the current user. - /// @return True if no error was recorded. False otherwise - bool realm_app_user_apikey_provider_client_disable_apikey( - ffi.Pointer arg0, - ffi.Pointer arg1, - realm_object_id_t id, - realm_app_void_completion_func_t callback, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, + /// work-around for Dart FFI issue + realm_decimal128_t realm_dart_decimal128_copy( + realm_decimal128_t x, ) { - return _realm_app_user_apikey_provider_client_disable_apikey( - arg0, - arg1, - id, - callback, - userdata, - userdata_free, + return _realm_dart_decimal128_copy( + x, ); } - late final _realm_app_user_apikey_provider_client_disable_apikeyPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - realm_object_id_t, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_app_user_apikey_provider_client_disable_apikey'); - late final _realm_app_user_apikey_provider_client_disable_apikey = - _realm_app_user_apikey_provider_client_disable_apikeyPtr.asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - realm_object_id_t, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); + late final _realm_dart_decimal128_copyPtr = _lookup< + ffi.NativeFunction>( + 'realm_dart_decimal128_copy'); + late final _realm_dart_decimal128_copy = _realm_dart_decimal128_copyPtr + .asFunction(); - /// Enables a user API key associated with the current user. - /// @return True if no error was recorded. False otherwise - bool realm_app_user_apikey_provider_client_enable_apikey( - ffi.Pointer arg0, - ffi.Pointer arg1, - realm_object_id_t id, - realm_app_void_completion_func_t callback, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, + realm_decimal128_t realm_dart_decimal128_divide( + realm_decimal128_t x, + realm_decimal128_t y, ) { - return _realm_app_user_apikey_provider_client_enable_apikey( - arg0, - arg1, - id, - callback, - userdata, - userdata_free, + return _realm_dart_decimal128_divide( + x, + y, ); } - late final _realm_app_user_apikey_provider_client_enable_apikeyPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - realm_object_id_t, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_app_user_apikey_provider_client_enable_apikey'); - late final _realm_app_user_apikey_provider_client_enable_apikey = - _realm_app_user_apikey_provider_client_enable_apikeyPtr.asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - realm_object_id_t, - realm_app_void_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); + late final _realm_dart_decimal128_dividePtr = _lookup< + ffi.NativeFunction< + realm_decimal128_t Function(realm_decimal128_t, + realm_decimal128_t)>>('realm_dart_decimal128_divide'); + late final _realm_dart_decimal128_divide = + _realm_dart_decimal128_dividePtr.asFunction< + realm_decimal128_t Function( + realm_decimal128_t, realm_decimal128_t)>(); - /// Fetches a user API key associated with the current user. - /// @return True if no error was recorded. False otherwise - bool realm_app_user_apikey_provider_client_fetch_apikey( - ffi.Pointer arg0, - ffi.Pointer arg1, - realm_object_id_t id, - realm_return_apikey_func_t callback, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, + bool realm_dart_decimal128_equal( + realm_decimal128_t x, + realm_decimal128_t y, ) { - return _realm_app_user_apikey_provider_client_fetch_apikey( - arg0, - arg1, - id, - callback, - userdata, - userdata_free, + return _realm_dart_decimal128_equal( + x, + y, ); } - late final _realm_app_user_apikey_provider_client_fetch_apikeyPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - realm_object_id_t, - realm_return_apikey_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_app_user_apikey_provider_client_fetch_apikey'); - late final _realm_app_user_apikey_provider_client_fetch_apikey = - _realm_app_user_apikey_provider_client_fetch_apikeyPtr.asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - realm_object_id_t, - realm_return_apikey_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); + late final _realm_dart_decimal128_equalPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(realm_decimal128_t, + realm_decimal128_t)>>('realm_dart_decimal128_equal'); + late final _realm_dart_decimal128_equal = _realm_dart_decimal128_equalPtr + .asFunction(); - /// Fetches the user API keys associated with the current user. - /// @return True if no error was recorded. False otherwise - bool realm_app_user_apikey_provider_client_fetch_apikeys( - ffi.Pointer arg0, - ffi.Pointer arg1, - realm_return_apikey_list_func_t callback, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, + realm_decimal128_t realm_dart_decimal128_from_int64( + int low, ) { - return _realm_app_user_apikey_provider_client_fetch_apikeys( - arg0, - arg1, - callback, - userdata, - userdata_free, + return _realm_dart_decimal128_from_int64( + low, ); } - late final _realm_app_user_apikey_provider_client_fetch_apikeysPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - realm_return_apikey_list_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_app_user_apikey_provider_client_fetch_apikeys'); - late final _realm_app_user_apikey_provider_client_fetch_apikeys = - _realm_app_user_apikey_provider_client_fetch_apikeysPtr.asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - realm_return_apikey_list_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); + late final _realm_dart_decimal128_from_int64Ptr = + _lookup>( + 'realm_dart_decimal128_from_int64'); + late final _realm_dart_decimal128_from_int64 = + _realm_dart_decimal128_from_int64Ptr + .asFunction(); - /// start a new write transaction asynchronously for the realm passed as argument. - bool realm_async_begin_write( - ffi.Pointer realm, - realm_async_begin_write_func_t arg1, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, - bool notify_only, - ffi.Pointer transaction_id, + realm_decimal128_t realm_dart_decimal128_from_string( + ffi.Pointer string, ) { - return _realm_async_begin_write( - realm, - arg1, - userdata, - userdata_free, - notify_only, - transaction_id, + return _realm_dart_decimal128_from_string( + string, ); } - late final _realm_async_begin_writePtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - realm_async_begin_write_func_t, - ffi.Pointer, - realm_free_userdata_func_t, - ffi.Bool, - ffi.Pointer)>>('realm_async_begin_write'); - late final _realm_async_begin_write = _realm_async_begin_writePtr.asFunction< - bool Function( - ffi.Pointer, - realm_async_begin_write_func_t, - ffi.Pointer, - realm_free_userdata_func_t, - bool, - ffi.Pointer)>(); + late final _realm_dart_decimal128_from_stringPtr = _lookup< + ffi + .NativeFunction)>>( + 'realm_dart_decimal128_from_string'); + late final _realm_dart_decimal128_from_string = + _realm_dart_decimal128_from_stringPtr + .asFunction)>(); - /// Cancel the transaction referenced by the token passed as argument and set the optional boolean flag in order to - /// inform the caller if the transaction was cancelled. - bool realm_async_cancel( - ffi.Pointer realm, - int token, - ffi.Pointer cancelled, + bool realm_dart_decimal128_greater_than( + realm_decimal128_t x, + realm_decimal128_t y, ) { - return _realm_async_cancel( - realm, - token, - cancelled, + return _realm_dart_decimal128_greater_than( + x, + y, ); } - late final _realm_async_cancelPtr = _lookup< + late final _realm_dart_decimal128_greater_thanPtr = _lookup< ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, ffi.UnsignedInt, - ffi.Pointer)>>('realm_async_cancel'); - late final _realm_async_cancel = _realm_async_cancelPtr.asFunction< - bool Function(ffi.Pointer, int, ffi.Pointer)>(); + ffi.Bool Function(realm_decimal128_t, + realm_decimal128_t)>>('realm_dart_decimal128_greater_than'); + late final _realm_dart_decimal128_greater_than = + _realm_dart_decimal128_greater_thanPtr + .asFunction(); - /// commit a transaction asynchronously for the realm passed as argument. - bool realm_async_commit( - ffi.Pointer realm, - realm_async_commit_func_t arg1, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, - bool allow_grouping, - ffi.Pointer transaction_id, + bool realm_dart_decimal128_is_nan( + realm_decimal128_t x, ) { - return _realm_async_commit( - realm, - arg1, - userdata, - userdata_free, - allow_grouping, - transaction_id, + return _realm_dart_decimal128_is_nan( + x, ); } - late final _realm_async_commitPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - realm_async_commit_func_t, - ffi.Pointer, - realm_free_userdata_func_t, - ffi.Bool, - ffi.Pointer)>>('realm_async_commit'); - late final _realm_async_commit = _realm_async_commitPtr.asFunction< - bool Function( - ffi.Pointer, - realm_async_commit_func_t, - ffi.Pointer, - realm_free_userdata_func_t, - bool, - ffi.Pointer)>(); + late final _realm_dart_decimal128_is_nanPtr = + _lookup>( + 'realm_dart_decimal128_is_nan'); + late final _realm_dart_decimal128_is_nan = _realm_dart_decimal128_is_nanPtr + .asFunction(); - void realm_async_open_task_cancel( - ffi.Pointer arg0, + bool realm_dart_decimal128_less_than( + realm_decimal128_t x, + realm_decimal128_t y, ) { - return _realm_async_open_task_cancel( - arg0, + return _realm_dart_decimal128_less_than( + x, + y, ); } - late final _realm_async_open_task_cancelPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer)>>( - 'realm_async_open_task_cancel'); - late final _realm_async_open_task_cancel = _realm_async_open_task_cancelPtr - .asFunction)>(); - - ffi.Pointer - realm_async_open_task_register_download_progress_notifier( - ffi.Pointer arg0, - realm_sync_progress_func_t arg1, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, + late final _realm_dart_decimal128_less_thanPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(realm_decimal128_t, + realm_decimal128_t)>>('realm_dart_decimal128_less_than'); + late final _realm_dart_decimal128_less_than = + _realm_dart_decimal128_less_thanPtr + .asFunction(); + + realm_decimal128_t realm_dart_decimal128_multiply( + realm_decimal128_t x, + realm_decimal128_t y, ) { - return _realm_async_open_task_register_download_progress_notifier( - arg0, - arg1, - userdata, - userdata_free, + return _realm_dart_decimal128_multiply( + x, + y, ); } - late final _realm_async_open_task_register_download_progress_notifierPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - realm_sync_progress_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_async_open_task_register_download_progress_notifier'); - late final _realm_async_open_task_register_download_progress_notifier = - _realm_async_open_task_register_download_progress_notifierPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, - realm_sync_progress_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); + late final _realm_dart_decimal128_multiplyPtr = _lookup< + ffi.NativeFunction< + realm_decimal128_t Function(realm_decimal128_t, + realm_decimal128_t)>>('realm_dart_decimal128_multiply'); + late final _realm_dart_decimal128_multiply = + _realm_dart_decimal128_multiplyPtr.asFunction< + realm_decimal128_t Function( + realm_decimal128_t, realm_decimal128_t)>(); - void realm_async_open_task_start( - ffi.Pointer arg0, - realm_async_open_task_completion_func_t arg1, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, + realm_decimal128_t realm_dart_decimal128_nan() { + return _realm_dart_decimal128_nan(); + } + + late final _realm_dart_decimal128_nanPtr = + _lookup>( + 'realm_dart_decimal128_nan'); + late final _realm_dart_decimal128_nan = + _realm_dart_decimal128_nanPtr.asFunction(); + + realm_decimal128_t realm_dart_decimal128_negate( + realm_decimal128_t x, ) { - return _realm_async_open_task_start( - arg0, - arg1, - userdata, - userdata_free, + return _realm_dart_decimal128_negate( + x, ); } - late final _realm_async_open_task_startPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - realm_async_open_task_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>('realm_async_open_task_start'); - late final _realm_async_open_task_start = - _realm_async_open_task_startPtr.asFunction< - void Function( - ffi.Pointer, - realm_async_open_task_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); + late final _realm_dart_decimal128_negatePtr = _lookup< + ffi.NativeFunction>( + 'realm_dart_decimal128_negate'); + late final _realm_dart_decimal128_negate = _realm_dart_decimal128_negatePtr + .asFunction(); - /// for debugging only. Enable in realm_dart.cpp - /// RLM_API void realm_dart_gc(); - ffi.Pointer realm_attach_finalizer( - Object handle, - ffi.Pointer realmPtr, - int size, + realm_decimal128_t realm_dart_decimal128_subtract( + realm_decimal128_t x, + realm_decimal128_t y, ) { - return _realm_attach_finalizer( - handle, - realmPtr, - size, + return _realm_dart_decimal128_subtract( + x, + y, ); } - late final _realm_attach_finalizerPtr = _lookup< + late final _realm_dart_decimal128_subtractPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Handle, ffi.Pointer, - ffi.Int)>>('realm_attach_finalizer'); - late final _realm_attach_finalizer = _realm_attach_finalizerPtr.asFunction< - ffi.Pointer Function(Object, ffi.Pointer, int)>(); + realm_decimal128_t Function(realm_decimal128_t, + realm_decimal128_t)>>('realm_dart_decimal128_subtract'); + late final _realm_dart_decimal128_subtract = + _realm_dart_decimal128_subtractPtr.asFunction< + realm_decimal128_t Function( + realm_decimal128_t, realm_decimal128_t)>(); - realm_auth_provider realm_auth_credentials_get_provider( - ffi.Pointer arg0, + int realm_dart_decimal128_to_int64( + realm_decimal128_t x, ) { - return realm_auth_provider.fromValue(_realm_auth_credentials_get_provider( - arg0, - )); + return _realm_dart_decimal128_to_int64( + x, + ); } - late final _realm_auth_credentials_get_providerPtr = _lookup< - ffi.NativeFunction< - ffi.UnsignedInt Function(ffi.Pointer)>>( - 'realm_auth_credentials_get_provider'); - late final _realm_auth_credentials_get_provider = - _realm_auth_credentials_get_providerPtr - .asFunction)>(); + late final _realm_dart_decimal128_to_int64Ptr = + _lookup>( + 'realm_dart_decimal128_to_int64'); + late final _realm_dart_decimal128_to_int64 = + _realm_dart_decimal128_to_int64Ptr + .asFunction(); - /// Begin a read transaction for the Realm file. - /// - /// @return True if no exception occurred. - bool realm_begin_read( - ffi.Pointer arg0, + realm_string_t realm_dart_decimal128_to_string( + realm_decimal128_t x, ) { - return _realm_begin_read( - arg0, + return _realm_dart_decimal128_to_string( + x, ); } - late final _realm_begin_readPtr = - _lookup)>>( - 'realm_begin_read'); - late final _realm_begin_read = - _realm_begin_readPtr.asFunction)>(); + late final _realm_dart_decimal128_to_stringPtr = + _lookup>( + 'realm_dart_decimal128_to_string'); + late final _realm_dart_decimal128_to_string = + _realm_dart_decimal128_to_stringPtr + .asFunction(); - /// Begin a write transaction for the Realm file. - /// - /// @return True if no exception occurred. - bool realm_begin_write( - ffi.Pointer arg0, + void realm_dart_delete_persistent_handle( + ffi.Pointer handle, ) { - return _realm_begin_write( - arg0, + return _realm_dart_delete_persistent_handle( + handle, ); } - late final _realm_begin_writePtr = - _lookup)>>( - 'realm_begin_write'); - late final _realm_begin_write = - _realm_begin_writePtr.asFunction)>(); + late final _realm_dart_delete_persistent_handlePtr = + _lookup)>>( + 'realm_dart_delete_persistent_handle'); + late final _realm_dart_delete_persistent_handle = + _realm_dart_delete_persistent_handlePtr + .asFunction)>(); - /// Clear all the cached @a realm_app_t* instances in the process. - /// - /// @a realm_app_t* instances will need to be disposed with realm_release() - /// for them to be fully destroyed after the cache is cleared. - void realm_clear_cached_apps() { - return _realm_clear_cached_apps(); + void realm_dart_detach_logger( + int port, + ) { + return _realm_dart_detach_logger( + port, + ); } - late final _realm_clear_cached_appsPtr = - _lookup>( - 'realm_clear_cached_apps'); - late final _realm_clear_cached_apps = - _realm_clear_cached_appsPtr.asFunction(); + late final _realm_dart_detach_loggerPtr = + _lookup>( + 'realm_dart_detach_logger'); + late final _realm_dart_detach_logger = + _realm_dart_detach_loggerPtr.asFunction(); - /// Clear the last error on the calling thread. - /// - /// Use this if the system has recovered from an error, e.g. by closing the - /// offending Realm and reopening it, freeing up resources, or similar. - /// - /// @return True if an error was cleared. - bool realm_clear_last_error() { - return _realm_clear_last_error(); + /// implemented for Android only + ffi.Pointer realm_dart_get_bundle_id() { + return _realm_dart_get_bundle_id(); } - late final _realm_clear_last_errorPtr = - _lookup>( - 'realm_clear_last_error'); - late final _realm_clear_last_error = - _realm_clear_last_errorPtr.asFunction(); + late final _realm_dart_get_bundle_idPtr = + _lookup Function()>>( + 'realm_dart_get_bundle_id'); + late final _realm_dart_get_bundle_id = _realm_dart_get_bundle_idPtr + .asFunction Function()>(); - /// Clone a Realm C Wrapper object. - /// - /// If the object is not clonable, this function fails with RLM_ERR_NOT_CLONABLE. - /// - /// @return A pointer to an object of the same type as the input, or NULL if - /// cloning failed. - ffi.Pointer realm_clone( - ffi.Pointer arg0, - ) { - return _realm_clone( - arg0, - ); + ffi.Pointer realm_dart_get_device_name() { + return _realm_dart_get_device_name(); } - late final _realm_clonePtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_clone'); - late final _realm_clone = _realm_clonePtr - .asFunction Function(ffi.Pointer)>(); + late final _realm_dart_get_device_namePtr = + _lookup Function()>>( + 'realm_dart_get_device_name'); + late final _realm_dart_get_device_name = _realm_dart_get_device_namePtr + .asFunction Function()>(); - /// Forcibly close a Realm file. - /// - /// Note that this invalidates all Realm instances for the same path. - /// - /// The Realm will be automatically closed when the last reference is released, - /// including references to objects within the Realm. - /// - /// @return True if no exception occurred. - bool realm_close( - ffi.Pointer arg0, - ) { - return _realm_close( - arg0, - ); + ffi.Pointer realm_dart_get_device_version() { + return _realm_dart_get_device_version(); } - late final _realm_closePtr = - _lookup)>>( - 'realm_close'); - late final _realm_close = - _realm_closePtr.asFunction)>(); - - /// Get the indices of changes in a collection notification. - /// - /// Note: For moves, every `from` index will also be present among deletions, and - /// every `to` index will also be present among insertions. - /// - /// This function cannot fail. - /// - /// @param out_deletion_indices Where to put the indices of deleted elements - /// (*before* the deletion happened). May be NULL. - /// @param max_deletion_indices The max number of indices to write to @a - /// out_deletion_indices. - /// @param out_insertion_indices Where the put the indices of inserted elements - /// (*after* the insertion happened). May be NULL. - /// @param max_insertion_indices The max number of indices to write to @a - /// out_insertion_indices. - /// @param out_modification_indices Where to put the indices of modified elements - /// (*before* any insertions or deletions of - /// other elements). May be NULL. - /// @param max_modification_indices The max number of indices to write to @a - /// out_modification_indices. - /// @param out_modification_indices_after Where to put the indices of modified - /// elements (*after* any insertions or - /// deletions of other elements). May be - /// NULL. - /// @param max_modification_indices_after The max number of indices to write to - /// @a out_modification_indices_after. - /// @param out_moves Where to put the pairs of indices of moved elements. May be - /// NULL. - /// @param max_moves The max number of pairs to write to @a out_moves. - void realm_collection_changes_get_changes( - ffi.Pointer arg0, - ffi.Pointer out_deletion_indices, - int max_deletion_indices, - ffi.Pointer out_insertion_indices, - int max_insertion_indices, - ffi.Pointer out_modification_indices, - int max_modification_indices, - ffi.Pointer out_modification_indices_after, - int max_modification_indices_after, - ffi.Pointer out_moves, - int max_moves, - ) { - return _realm_collection_changes_get_changes( - arg0, - out_deletion_indices, - max_deletion_indices, - out_insertion_indices, - max_insertion_indices, - out_modification_indices, - max_modification_indices, - out_modification_indices_after, - max_modification_indices_after, - out_moves, - max_moves, - ); - } - - late final _realm_collection_changes_get_changesPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ffi.Pointer, - ffi.Size, - ffi.Pointer, - ffi.Size, - ffi.Pointer, - ffi.Size, - ffi.Pointer, - ffi.Size)>>('realm_collection_changes_get_changes'); - late final _realm_collection_changes_get_changes = - _realm_collection_changes_get_changesPtr.asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer, - int, - ffi.Pointer, - int, - ffi.Pointer, - int, - ffi.Pointer, - int)>(); - - /// Get the number of various types of changes in a collection notification. - /// - /// @param out_num_deletions The number of deletions. May be NULL. - /// @param out_num_insertions The number of insertions. May be NULL. - /// @param out_num_modifications The number of modifications. May be NULL. - /// @param out_num_moves The number of moved elements. May be NULL. - /// @param out_collection_was_cleared a flag to signal if the collection has been cleared. May be NULL - /// @param out_collection_was_deleted a flag to signal if the collection has been deleted. May be NULL - void realm_collection_changes_get_num_changes( - ffi.Pointer arg0, - ffi.Pointer out_num_deletions, - ffi.Pointer out_num_insertions, - ffi.Pointer out_num_modifications, - ffi.Pointer out_num_moves, - ffi.Pointer out_collection_was_cleared, - ffi.Pointer out_collection_was_deleted, - ) { - return _realm_collection_changes_get_num_changes( - arg0, - out_num_deletions, - out_num_insertions, - out_num_modifications, - out_num_moves, - out_collection_was_cleared, - out_collection_was_deleted, - ); - } - - late final _realm_collection_changes_get_num_changesPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>>( - 'realm_collection_changes_get_num_changes'); - late final _realm_collection_changes_get_num_changes = - _realm_collection_changes_get_num_changesPtr.asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>(); - - /// Get the number of various types of changes in a collection notification, - /// suitable for acquiring the change indices as ranges, which is much more - /// compact in memory than getting the individual indices when multiple adjacent - /// elements have been modified. - /// - /// @param out_num_deletion_ranges The number of deleted ranges. May be NULL. - /// @param out_num_insertion_ranges The number of inserted ranges. May be NULL. - /// @param out_num_modification_ranges The number of modified ranges. May be - /// NULL. - /// @param out_num_moves The number of moved elements. May be NULL. - void realm_collection_changes_get_num_ranges( - ffi.Pointer arg0, - ffi.Pointer out_num_deletion_ranges, - ffi.Pointer out_num_insertion_ranges, - ffi.Pointer out_num_modification_ranges, - ffi.Pointer out_num_moves, - ) { - return _realm_collection_changes_get_num_ranges( - arg0, - out_num_deletion_ranges, - out_num_insertion_ranges, - out_num_modification_ranges, - out_num_moves, - ); - } - - late final _realm_collection_changes_get_num_rangesPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>>( - 'realm_collection_changes_get_num_ranges'); - late final _realm_collection_changes_get_num_ranges = - _realm_collection_changes_get_num_rangesPtr.asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>(); - - void realm_collection_changes_get_ranges( - ffi.Pointer arg0, - ffi.Pointer out_deletion_ranges, - int max_deletion_ranges, - ffi.Pointer out_insertion_ranges, - int max_insertion_ranges, - ffi.Pointer out_modification_ranges, - int max_modification_ranges, - ffi.Pointer out_modification_ranges_after, - int max_modification_ranges_after, - ffi.Pointer out_moves, - int max_moves, - ) { - return _realm_collection_changes_get_ranges( - arg0, - out_deletion_ranges, - max_deletion_ranges, - out_insertion_ranges, - max_insertion_ranges, - out_modification_ranges, - max_modification_ranges, - out_modification_ranges_after, - max_modification_ranges_after, - out_moves, - max_moves, - ); - } - - late final _realm_collection_changes_get_rangesPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ffi.Pointer, - ffi.Size, - ffi.Pointer, - ffi.Size, - ffi.Pointer, - ffi.Size, - ffi.Pointer, - ffi.Size)>>('realm_collection_changes_get_ranges'); - late final _realm_collection_changes_get_ranges = - _realm_collection_changes_get_rangesPtr.asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer, - int, - ffi.Pointer, - int, - ffi.Pointer, - int, - ffi.Pointer, - int)>(); - - /// Commit a write transaction. - /// - /// @return True if the commit succeeded and no exceptions were thrown. - bool realm_commit( - ffi.Pointer arg0, - ) { - return _realm_commit( - arg0, - ); - } - - late final _realm_commitPtr = - _lookup)>>( - 'realm_commit'); - late final _realm_commit = - _realm_commitPtr.asFunction)>(); - - /// Vacuum the free space from the realm file, reducing its file size. - /// - /// @return True if no exceptions are thrown, false otherwise. - bool realm_compact( - ffi.Pointer arg0, - ffi.Pointer did_compact, - ) { - return _realm_compact( - arg0, - did_compact, - ); - } - - late final _realm_compactPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, ffi.Pointer)>>('realm_compact'); - late final _realm_compact = _realm_compactPtr - .asFunction, ffi.Pointer)>(); - - /// True if automatic change notifications should be generated. - /// - /// This function cannot fail. - bool realm_config_get_automatic_change_notifications( - ffi.Pointer arg0, - ) { - return _realm_config_get_automatic_change_notifications( - arg0, - ); - } - - late final _realm_config_get_automatic_change_notificationsPtr = _lookup< - ffi.NativeFunction)>>( - 'realm_config_get_automatic_change_notifications'); - late final _realm_config_get_automatic_change_notifications = - _realm_config_get_automatic_change_notificationsPtr - .asFunction)>(); - - /// Check if realms are cached - bool realm_config_get_cached( - ffi.Pointer arg0, - ) { - return _realm_config_get_cached( - arg0, - ); - } - - late final _realm_config_get_cachedPtr = _lookup< - ffi.NativeFunction)>>( - 'realm_config_get_cached'); - late final _realm_config_get_cached = _realm_config_get_cachedPtr - .asFunction)>(); - - /// True if file format upgrades on open are disabled. - /// - /// This function cannot fail. - bool realm_config_get_disable_format_upgrade( - ffi.Pointer arg0, - ) { - return _realm_config_get_disable_format_upgrade( - arg0, - ); - } - - late final _realm_config_get_disable_format_upgradePtr = _lookup< - ffi.NativeFunction)>>( - 'realm_config_get_disable_format_upgrade'); - late final _realm_config_get_disable_format_upgrade = - _realm_config_get_disable_format_upgradePtr - .asFunction)>(); - - /// Get the encryption key for the realm. - /// - /// The output buffer must be at least 64 bytes. - /// - /// @returns The length of the encryption key (0 or 64) - int realm_config_get_encryption_key( - ffi.Pointer arg0, - ffi.Pointer out_key, - ) { - return _realm_config_get_encryption_key( - arg0, - out_key, - ); - } - - late final _realm_config_get_encryption_keyPtr = _lookup< - ffi.NativeFunction< - ffi.Size Function(ffi.Pointer, - ffi.Pointer)>>('realm_config_get_encryption_key'); - late final _realm_config_get_encryption_key = - _realm_config_get_encryption_keyPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer)>(); - - /// Check realm FIFO path - ffi.Pointer realm_config_get_fifo_path( - ffi.Pointer arg0, - ) { - return _realm_config_get_fifo_path( - arg0, - ); - } - - late final _realm_config_get_fifo_pathPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_config_get_fifo_path'); - late final _realm_config_get_fifo_path = - _realm_config_get_fifo_pathPtr.asFunction< - ffi.Pointer Function(ffi.Pointer)>(); - - /// Get whether the realm file should be forcibly initialized as a synchronized. - /// - /// This function cannot fail. - bool realm_config_get_force_sync_history( - ffi.Pointer arg0, - ) { - return _realm_config_get_force_sync_history( - arg0, - ); - } - - late final _realm_config_get_force_sync_historyPtr = _lookup< - ffi.NativeFunction)>>( - 'realm_config_get_force_sync_history'); - late final _realm_config_get_force_sync_history = - _realm_config_get_force_sync_historyPtr - .asFunction)>(); - - /// Check if realm is configured in memory - bool realm_config_get_in_memory( - ffi.Pointer arg0, - ) { - return _realm_config_get_in_memory( - arg0, - ); - } - - late final _realm_config_get_in_memoryPtr = _lookup< - ffi.NativeFunction)>>( - 'realm_config_get_in_memory'); - late final _realm_config_get_in_memory = _realm_config_get_in_memoryPtr - .asFunction)>(); - - /// Get maximum number of active versions in the realm file allowed before an - /// exception is thrown. - /// - /// This function cannot fail. - int realm_config_get_max_number_of_active_versions( - ffi.Pointer arg0, - ) { - return _realm_config_get_max_number_of_active_versions( - arg0, - ); - } - - late final _realm_config_get_max_number_of_active_versionsPtr = _lookup< - ffi.NativeFunction)>>( - 'realm_config_get_max_number_of_active_versions'); - late final _realm_config_get_max_number_of_active_versions = - _realm_config_get_max_number_of_active_versionsPtr - .asFunction)>(); - - /// Get the path of the realm being opened. - /// - /// This function cannot fail. - ffi.Pointer realm_config_get_path( - ffi.Pointer arg0, - ) { - return _realm_config_get_path( - arg0, - ); - } - - late final _realm_config_get_pathPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_config_get_path'); - late final _realm_config_get_path = _realm_config_get_pathPtr.asFunction< - ffi.Pointer Function(ffi.Pointer)>(); - - /// Get the schema for this realm. - /// - /// Note: The caller obtains ownership of the returned value, and must manually - /// free it by calling `realm_release()`. - /// - /// @return A schema object, or NULL if the schema is not set (empty). - ffi.Pointer realm_config_get_schema( - ffi.Pointer arg0, - ) { - return _realm_config_get_schema( - arg0, - ); - } - - late final _realm_config_get_schemaPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_config_get_schema'); - late final _realm_config_get_schema = _realm_config_get_schemaPtr.asFunction< - ffi.Pointer Function(ffi.Pointer)>(); - - /// Get the schema mode. - /// - /// This function cannot fail. - realm_schema_mode realm_config_get_schema_mode( - ffi.Pointer arg0, - ) { - return realm_schema_mode.fromValue(_realm_config_get_schema_mode( - arg0, - )); - } - - late final _realm_config_get_schema_modePtr = _lookup< - ffi.NativeFunction< - ffi.UnsignedInt Function( - ffi.Pointer)>>('realm_config_get_schema_mode'); - late final _realm_config_get_schema_mode = _realm_config_get_schema_modePtr - .asFunction)>(); - - /// Get the subset schema mode. - /// - /// This function cannot fail. - realm_schema_subset_mode realm_config_get_schema_subset_mode( - ffi.Pointer arg0, - ) { - return realm_schema_subset_mode - .fromValue(_realm_config_get_schema_subset_mode( - arg0, - )); - } - - late final _realm_config_get_schema_subset_modePtr = _lookup< - ffi.NativeFunction< - ffi.UnsignedInt Function(ffi.Pointer)>>( - 'realm_config_get_schema_subset_mode'); - late final _realm_config_get_schema_subset_mode = - _realm_config_get_schema_subset_modePtr - .asFunction)>(); - - /// Get the schema version of the schema. - /// - /// This function cannot fail. - int realm_config_get_schema_version( - ffi.Pointer arg0, - ) { - return _realm_config_get_schema_version( - arg0, - ); - } - - late final _realm_config_get_schema_versionPtr = _lookup< - ffi.NativeFunction)>>( - 'realm_config_get_schema_version'); - late final _realm_config_get_schema_version = - _realm_config_get_schema_versionPtr - .asFunction)>(); - - /// True if you can open the file without a file_format_upgrade - bool realm_config_needs_file_format_upgrade( - ffi.Pointer arg0, - ) { - return _realm_config_needs_file_format_upgrade( - arg0, - ); - } - - late final _realm_config_needs_file_format_upgradePtr = _lookup< - ffi.NativeFunction)>>( - 'realm_config_needs_file_format_upgrade'); - late final _realm_config_needs_file_format_upgrade = - _realm_config_needs_file_format_upgradePtr - .asFunction)>(); - - /// Allocate a new configuration with default options. - ffi.Pointer realm_config_new() { - return _realm_config_new(); - } - - late final _realm_config_newPtr = - _lookup Function()>>( - 'realm_config_new'); - late final _realm_config_new = - _realm_config_newPtr.asFunction Function()>(); - - /// Set the audit interface for the realm (unimplemented). - bool realm_config_set_audit_factory( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - return _realm_config_set_audit_factory( - arg0, - arg1, - ); - } - - late final _realm_config_set_audit_factoryPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, - ffi.Pointer)>>('realm_config_set_audit_factory'); - late final _realm_config_set_audit_factory = - _realm_config_set_audit_factoryPtr.asFunction< - bool Function(ffi.Pointer, ffi.Pointer)>(); - - /// Allow realm to manage automatically embedded objects when a migration from TopLevel to Embedded takes place. - void realm_config_set_automatic_backlink_handling( - ffi.Pointer arg0, - bool arg1, - ) { - return _realm_config_set_automatic_backlink_handling( - arg0, - arg1, - ); - } - - late final _realm_config_set_automatic_backlink_handlingPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Bool)>>('realm_config_set_automatic_backlink_handling'); - late final _realm_config_set_automatic_backlink_handling = - _realm_config_set_automatic_backlink_handlingPtr - .asFunction, bool)>(); - - /// Automatically generated change notifications (default: true). - /// - /// This function cannot fail. - void realm_config_set_automatic_change_notifications( - ffi.Pointer arg0, - bool arg1, - ) { - return _realm_config_set_automatic_change_notifications( - arg0, - arg1, - ); - } - - late final _realm_config_set_automatic_change_notificationsPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Bool)>>('realm_config_set_automatic_change_notifications'); - late final _realm_config_set_automatic_change_notifications = - _realm_config_set_automatic_change_notificationsPtr - .asFunction, bool)>(); - - /// If 'cached' is false, always return a new Realm instance. - void realm_config_set_cached( - ffi.Pointer arg0, - bool cached, - ) { - return _realm_config_set_cached( - arg0, - cached, - ); - } - - late final _realm_config_set_cachedPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Bool)>>('realm_config_set_cached'); - late final _realm_config_set_cached = _realm_config_set_cachedPtr - .asFunction, bool)>(); - - /// Set the data initialization function. - /// - /// The callback is invoked the first time the schema is created, such that the - /// user can perform one-time initialization of the data in the realm. - /// - /// The realm instance passed to the callback is in a write transaction. - /// - /// This function cannot fail. - void realm_config_set_data_initialization_function( - ffi.Pointer arg0, - realm_data_initialization_func_t arg1, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, - ) { - return _realm_config_set_data_initialization_function( - arg0, - arg1, - userdata, - userdata_free, - ); - } - - late final _realm_config_set_data_initialization_functionPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - realm_data_initialization_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_config_set_data_initialization_function'); - late final _realm_config_set_data_initialization_function = - _realm_config_set_data_initialization_functionPtr.asFunction< - void Function( - ffi.Pointer, - realm_data_initialization_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); - - /// Disable file format upgrade on open (default: false). - /// - /// If a migration is needed to open the realm file with the provided schema, an - /// error is thrown rather than automatically performing the migration. - /// - /// This function cannot fail. - void realm_config_set_disable_format_upgrade( - ffi.Pointer arg0, - bool arg1, - ) { - return _realm_config_set_disable_format_upgrade( - arg0, - arg1, - ); - } - - late final _realm_config_set_disable_format_upgradePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Bool)>>('realm_config_set_disable_format_upgrade'); - late final _realm_config_set_disable_format_upgrade = - _realm_config_set_disable_format_upgradePtr - .asFunction, bool)>(); - - /// Set the encryption key for the realm. - /// - /// The key must be either 64 bytes long or have length zero (in which case - /// encryption is disabled). - /// - /// This function may fail if the encryption key has the wrong length. - bool realm_config_set_encryption_key( - ffi.Pointer arg0, - ffi.Pointer key, - int key_size, - ) { - return _realm_config_set_encryption_key( - arg0, - key, - key_size, - ); - } - - late final _realm_config_set_encryption_keyPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, ffi.Pointer, - ffi.Size)>>('realm_config_set_encryption_key'); - late final _realm_config_set_encryption_key = - _realm_config_set_encryption_keyPtr.asFunction< - bool Function( - ffi.Pointer, ffi.Pointer, int)>(); - - /// Set FIFO path - void realm_config_set_fifo_path( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - return _realm_config_set_fifo_path( - arg0, - arg1, - ); - } - - late final _realm_config_set_fifo_pathPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Pointer)>>('realm_config_set_fifo_path'); - late final _realm_config_set_fifo_path = - _realm_config_set_fifo_pathPtr.asFunction< - void Function(ffi.Pointer, ffi.Pointer)>(); - - /// Force the realm file to be initialized as a synchronized realm, even if no - /// sync config is provided (default: false). - /// - /// This function cannot fail. - void realm_config_set_force_sync_history( - ffi.Pointer arg0, - bool arg1, - ) { - return _realm_config_set_force_sync_history( - arg0, - arg1, - ); - } - - late final _realm_config_set_force_sync_historyPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Bool)>>('realm_config_set_force_sync_history'); - late final _realm_config_set_force_sync_history = - _realm_config_set_force_sync_historyPtr - .asFunction, bool)>(); - - /// Configure realm to be in memory - void realm_config_set_in_memory( - ffi.Pointer arg0, - bool arg1, - ) { - return _realm_config_set_in_memory( - arg0, - arg1, - ); - } - - late final _realm_config_set_in_memoryPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Bool)>>('realm_config_set_in_memory'); - late final _realm_config_set_in_memory = _realm_config_set_in_memoryPtr - .asFunction, bool)>(); - - /// Set maximum number of active versions in the realm file allowed before an - /// exception is thrown (default: UINT64_MAX). - /// - /// This function cannot fail. - void realm_config_set_max_number_of_active_versions( - ffi.Pointer arg0, - int arg1, - ) { - return _realm_config_set_max_number_of_active_versions( - arg0, - arg1, - ); - } - - late final _realm_config_set_max_number_of_active_versionsPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Uint64)>>('realm_config_set_max_number_of_active_versions'); - late final _realm_config_set_max_number_of_active_versions = - _realm_config_set_max_number_of_active_versionsPtr - .asFunction, int)>(); - - /// Set the migration callback. - /// - /// The migration function is called during a migration for schema modes - /// `RLM_SCHEMA_MODE_AUTOMATIC` and `RLM_SCHEMA_MODE_MANUAL`. The callback is - /// invoked with a realm instance before the migration and the realm instance - /// that is currently performing the migration. - /// - /// This function cannot fail. - void realm_config_set_migration_function( - ffi.Pointer arg0, - realm_migration_func_t arg1, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, - ) { - return _realm_config_set_migration_function( - arg0, - arg1, - userdata, - userdata_free, - ); - } - - late final _realm_config_set_migration_functionPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - realm_migration_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_config_set_migration_function'); - late final _realm_config_set_migration_function = - _realm_config_set_migration_functionPtr.asFunction< - void Function(ffi.Pointer, realm_migration_func_t, - ffi.Pointer, realm_free_userdata_func_t)>(); - - /// Set the path of the realm being opened. - /// - /// This function aborts when out of memory, but otherwise cannot fail. - void realm_config_set_path( - ffi.Pointer arg0, - ffi.Pointer path, - ) { - return _realm_config_set_path( - arg0, - path, - ); - } - - late final _realm_config_set_pathPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Pointer)>>('realm_config_set_path'); - late final _realm_config_set_path = _realm_config_set_pathPtr.asFunction< - void Function(ffi.Pointer, ffi.Pointer)>(); - - /// The scheduler which this realm should be bound to (default: NULL). - /// - /// If NULL, the realm will be bound to the default scheduler for the current thread. - /// - /// This function aborts when out of memory, but otherwise cannot fail. - void realm_config_set_scheduler( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - return _realm_config_set_scheduler( - arg0, - arg1, - ); - } - - late final _realm_config_set_schedulerPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Pointer)>>('realm_config_set_scheduler'); - late final _realm_config_set_scheduler = - _realm_config_set_schedulerPtr.asFunction< - void Function( - ffi.Pointer, ffi.Pointer)>(); - - /// Set the schema object for this realm. - /// - /// This does not take ownership of the schema object, and it should be released - /// afterwards. - /// - /// This function aborts when out of memory, but otherwise cannot fail. - /// - /// @param schema The schema object. May be NULL, which means an empty schema. - void realm_config_set_schema( - ffi.Pointer arg0, - ffi.Pointer schema, - ) { - return _realm_config_set_schema( - arg0, - schema, - ); - } - - late final _realm_config_set_schemaPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Pointer)>>('realm_config_set_schema'); - late final _realm_config_set_schema = _realm_config_set_schemaPtr.asFunction< - void Function( - ffi.Pointer, ffi.Pointer)>(); - - /// Set the schema mode. - /// - /// This function cannot fail. - void realm_config_set_schema_mode( - ffi.Pointer arg0, - realm_schema_mode arg1, - ) { - return _realm_config_set_schema_mode( - arg0, - arg1.value, - ); - } - - late final _realm_config_set_schema_modePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.UnsignedInt)>>('realm_config_set_schema_mode'); - late final _realm_config_set_schema_mode = _realm_config_set_schema_modePtr - .asFunction, int)>(); - - /// Set schema subset mode - /// - /// This function cannot fail - void realm_config_set_schema_subset_mode( - ffi.Pointer arg0, - realm_schema_subset_mode arg1, - ) { - return _realm_config_set_schema_subset_mode( - arg0, - arg1.value, - ); - } - - late final _realm_config_set_schema_subset_modePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.UnsignedInt)>>('realm_config_set_schema_subset_mode'); - late final _realm_config_set_schema_subset_mode = - _realm_config_set_schema_subset_modePtr - .asFunction, int)>(); - - /// Set the schema version of the schema. - /// - /// This function cannot fail. - void realm_config_set_schema_version( - ffi.Pointer arg0, - int version, - ) { - return _realm_config_set_schema_version( - arg0, - version, - ); - } - - late final _realm_config_set_schema_versionPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Uint64)>>('realm_config_set_schema_version'); - late final _realm_config_set_schema_version = - _realm_config_set_schema_versionPtr - .asFunction, int)>(); - - /// Set the should-compact-on-launch callback. - /// - /// The callback is invoked the first time a realm file is opened in this process - /// to decide whether the realm file should be compacted. - /// - /// Note: If another process has the realm file open, it will not be compacted. - /// - /// This function cannot fail. - void realm_config_set_should_compact_on_launch_function( - ffi.Pointer arg0, - realm_should_compact_on_launch_func_t arg1, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, - ) { - return _realm_config_set_should_compact_on_launch_function( - arg0, - arg1, - userdata, - userdata_free, - ); - } - - late final _realm_config_set_should_compact_on_launch_functionPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - realm_should_compact_on_launch_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_config_set_should_compact_on_launch_function'); - late final _realm_config_set_should_compact_on_launch_function = - _realm_config_set_should_compact_on_launch_functionPtr.asFunction< - void Function( - ffi.Pointer, - realm_should_compact_on_launch_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); - - /// Sync configuration for this realm (default: NULL). - /// - /// This function aborts when out of memory, but otherwise cannot fail. - void realm_config_set_sync_config( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - return _realm_config_set_sync_config( - arg0, - arg1, - ); - } - - late final _realm_config_set_sync_configPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Pointer)>>( - 'realm_config_set_sync_config'); - late final _realm_config_set_sync_config = - _realm_config_set_sync_configPtr.asFunction< - void Function( - ffi.Pointer, ffi.Pointer)>(); - - /// The overloaded Realm::convert function offers a way to copy and/or convert a realm. - /// - /// The following options are supported: - /// - local -> local (config or path) - /// - local -> sync (config only) - /// - sync -> local (config only) - /// - sync -> sync (config or path) - /// - sync -> bundlable sync (client file identifier removed) - /// - /// Note that for bundled realms it is required that all local changes are synchronized with the - /// server before the copy can be written. This is to be sure that the file can be used as a - /// stating point for a newly installed application. The function will throw if there are - /// pending uploads. - /// / - /// /** - /// Copy or convert a Realm using a config. - /// - /// If the file already exists and merge_with_existing is true, data will be copied over object per object. - /// When merging, all classes must have a pk called '_id" otherwise an exception is thrown. - /// If the file exists and merge_with_existing is false, an exception is thrown. - /// If the file does not exist, the realm file will be exported to the new location and if the - /// configuration object contains a sync part, a sync history will be synthesized. - /// - /// @param config The realm configuration that should be used to create a copy. - /// This can be a local or a synced Realm, encrypted or not. - /// @param merge_with_existing If this is true and the destination file exists, data will be copied over object by - /// object. Otherwise, if this is false and the destination file exists, an exception is thrown. - bool realm_convert_with_config( - ffi.Pointer realm, - ffi.Pointer config, - bool merge_with_existing, - ) { - return _realm_convert_with_config( - realm, - config, - merge_with_existing, - ); - } - - late final _realm_convert_with_configPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, ffi.Pointer, - ffi.Bool)>>('realm_convert_with_config'); - late final _realm_convert_with_config = - _realm_convert_with_configPtr.asFunction< - bool Function( - ffi.Pointer, ffi.Pointer, bool)>(); - - /// Copy a Realm using a path. - /// - /// @param path The path the realm should be copied to. Local realms will remain local, synced - /// realms will remain synced realms. - /// @param encryption_key The optional encryption key for the new realm. - /// @param merge_with_existing If this is true and the destination file exists, data will be copied over object by - /// object. - /// Otherwise, if this is false and the destination file exists, an exception is thrown. - bool realm_convert_with_path( - ffi.Pointer realm, - ffi.Pointer path, - realm_binary_t encryption_key, - bool merge_with_existing, - ) { - return _realm_convert_with_path( - realm, - path, - encryption_key, - merge_with_existing, - ); - } - - late final _realm_convert_with_pathPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, ffi.Pointer, - realm_binary_t, ffi.Bool)>>('realm_convert_with_path'); - late final _realm_convert_with_path = _realm_convert_with_pathPtr.asFunction< - bool Function( - ffi.Pointer, ffi.Pointer, realm_binary_t, bool)>(); - - /// Helper method for making it easier to to convert SDK input to the underlying - /// `realm_key_path_array_t`. - /// - /// @return A pointer to the converted key path array. NULL in case of an error. - ffi.Pointer realm_create_key_path_array( - ffi.Pointer realm, - int object_class_key, - int num_key_paths, - ffi.Pointer> user_key_paths, - ) { - return _realm_create_key_path_array( - realm, - object_class_key, - num_key_paths, - user_key_paths, - ); - } - - late final _realm_create_key_path_arrayPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - realm_class_key_t, - ffi.Size, - ffi.Pointer>)>>( - 'realm_create_key_path_array'); - late final _realm_create_key_path_array = - _realm_create_key_path_arrayPtr.asFunction< - ffi.Pointer Function(ffi.Pointer, - int, int, ffi.Pointer>)>(); - - /// Get a thread-safe reference representing the same underlying object as some - /// API object. - /// - /// The thread safe reference can be passed to a different thread and resolved - /// against a different `realm_t` instance, which succeeds if the underlying - /// object still exists. - /// - /// The following types can produce thread safe references: - /// - /// - `realm_object_t` - /// - `realm_results_t` - /// - `realm_list_t` - /// - `realm_t` - /// - /// This does not assume ownership of the object, except for `realm_t`, where the - /// instance is transferred by value, and must be transferred back to the current - /// thread to be used. Note that the `realm_thread_safe_reference_t` object must - /// still be destroyed after having been converted into a `realm_t` object. - /// - /// @return A non-null pointer if no exception occurred. - ffi.Pointer realm_create_thread_safe_reference( - ffi.Pointer arg0, - ) { - return _realm_create_thread_safe_reference( - arg0, - ); - } - - late final _realm_create_thread_safe_referencePtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_create_thread_safe_reference'); - late final _realm_create_thread_safe_reference = - _realm_create_thread_safe_referencePtr.asFunction< - ffi.Pointer Function( - ffi.Pointer)>(); - - void realm_dart_attach_logger( - int port, - ) { - return _realm_dart_attach_logger( - port, - ); - } - - late final _realm_dart_attach_loggerPtr = - _lookup>( - 'realm_dart_attach_logger'); - late final _realm_dart_attach_logger = - _realm_dart_attach_loggerPtr.asFunction(); - - ffi.Pointer realm_dart_create_scheduler( - int isolateId, - int port, - ) { - return _realm_dart_create_scheduler( - isolateId, - port, - ); - } - - late final _realm_dart_create_schedulerPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Uint64, Dart_Port)>>('realm_dart_create_scheduler'); - late final _realm_dart_create_scheduler = _realm_dart_create_schedulerPtr - .asFunction Function(int, int)>(); - - realm_decimal128_t realm_dart_decimal128_add( - realm_decimal128_t x, - realm_decimal128_t y, - ) { - return _realm_dart_decimal128_add( - x, - y, - ); - } - - late final _realm_dart_decimal128_addPtr = _lookup< - ffi.NativeFunction< - realm_decimal128_t Function(realm_decimal128_t, - realm_decimal128_t)>>('realm_dart_decimal128_add'); - late final _realm_dart_decimal128_add = - _realm_dart_decimal128_addPtr.asFunction< - realm_decimal128_t Function( - realm_decimal128_t, realm_decimal128_t)>(); - - int realm_dart_decimal128_compare_to( - realm_decimal128_t x, - realm_decimal128_t y, - ) { - return _realm_dart_decimal128_compare_to( - x, - y, - ); - } - - late final _realm_dart_decimal128_compare_toPtr = _lookup< - ffi.NativeFunction< - ffi.Int Function(realm_decimal128_t, - realm_decimal128_t)>>('realm_dart_decimal128_compare_to'); - late final _realm_dart_decimal128_compare_to = - _realm_dart_decimal128_compare_toPtr - .asFunction(); - - /// work-around for Dart FFI issue - realm_decimal128_t realm_dart_decimal128_copy( - realm_decimal128_t x, - ) { - return _realm_dart_decimal128_copy( - x, - ); - } - - late final _realm_dart_decimal128_copyPtr = _lookup< - ffi.NativeFunction>( - 'realm_dart_decimal128_copy'); - late final _realm_dart_decimal128_copy = _realm_dart_decimal128_copyPtr - .asFunction(); - - realm_decimal128_t realm_dart_decimal128_divide( - realm_decimal128_t x, - realm_decimal128_t y, - ) { - return _realm_dart_decimal128_divide( - x, - y, - ); - } - - late final _realm_dart_decimal128_dividePtr = _lookup< - ffi.NativeFunction< - realm_decimal128_t Function(realm_decimal128_t, - realm_decimal128_t)>>('realm_dart_decimal128_divide'); - late final _realm_dart_decimal128_divide = - _realm_dart_decimal128_dividePtr.asFunction< - realm_decimal128_t Function( - realm_decimal128_t, realm_decimal128_t)>(); - - bool realm_dart_decimal128_equal( - realm_decimal128_t x, - realm_decimal128_t y, - ) { - return _realm_dart_decimal128_equal( - x, - y, - ); - } - - late final _realm_dart_decimal128_equalPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(realm_decimal128_t, - realm_decimal128_t)>>('realm_dart_decimal128_equal'); - late final _realm_dart_decimal128_equal = _realm_dart_decimal128_equalPtr - .asFunction(); - - realm_decimal128_t realm_dart_decimal128_from_int64( - int low, - ) { - return _realm_dart_decimal128_from_int64( - low, - ); - } - - late final _realm_dart_decimal128_from_int64Ptr = - _lookup>( - 'realm_dart_decimal128_from_int64'); - late final _realm_dart_decimal128_from_int64 = - _realm_dart_decimal128_from_int64Ptr - .asFunction(); - - realm_decimal128_t realm_dart_decimal128_from_string( - ffi.Pointer string, - ) { - return _realm_dart_decimal128_from_string( - string, - ); - } - - late final _realm_dart_decimal128_from_stringPtr = _lookup< - ffi - .NativeFunction)>>( - 'realm_dart_decimal128_from_string'); - late final _realm_dart_decimal128_from_string = - _realm_dart_decimal128_from_stringPtr - .asFunction)>(); - - bool realm_dart_decimal128_greater_than( - realm_decimal128_t x, - realm_decimal128_t y, - ) { - return _realm_dart_decimal128_greater_than( - x, - y, - ); - } - - late final _realm_dart_decimal128_greater_thanPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(realm_decimal128_t, - realm_decimal128_t)>>('realm_dart_decimal128_greater_than'); - late final _realm_dart_decimal128_greater_than = - _realm_dart_decimal128_greater_thanPtr - .asFunction(); - - bool realm_dart_decimal128_is_nan( - realm_decimal128_t x, - ) { - return _realm_dart_decimal128_is_nan( - x, - ); - } - - late final _realm_dart_decimal128_is_nanPtr = - _lookup>( - 'realm_dart_decimal128_is_nan'); - late final _realm_dart_decimal128_is_nan = _realm_dart_decimal128_is_nanPtr - .asFunction(); - - bool realm_dart_decimal128_less_than( - realm_decimal128_t x, - realm_decimal128_t y, - ) { - return _realm_dart_decimal128_less_than( - x, - y, - ); - } - - late final _realm_dart_decimal128_less_thanPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(realm_decimal128_t, - realm_decimal128_t)>>('realm_dart_decimal128_less_than'); - late final _realm_dart_decimal128_less_than = - _realm_dart_decimal128_less_thanPtr - .asFunction(); - - realm_decimal128_t realm_dart_decimal128_multiply( - realm_decimal128_t x, - realm_decimal128_t y, - ) { - return _realm_dart_decimal128_multiply( - x, - y, - ); - } - - late final _realm_dart_decimal128_multiplyPtr = _lookup< - ffi.NativeFunction< - realm_decimal128_t Function(realm_decimal128_t, - realm_decimal128_t)>>('realm_dart_decimal128_multiply'); - late final _realm_dart_decimal128_multiply = - _realm_dart_decimal128_multiplyPtr.asFunction< - realm_decimal128_t Function( - realm_decimal128_t, realm_decimal128_t)>(); - - realm_decimal128_t realm_dart_decimal128_nan() { - return _realm_dart_decimal128_nan(); - } - - late final _realm_dart_decimal128_nanPtr = - _lookup>( - 'realm_dart_decimal128_nan'); - late final _realm_dart_decimal128_nan = - _realm_dart_decimal128_nanPtr.asFunction(); - - realm_decimal128_t realm_dart_decimal128_negate( - realm_decimal128_t x, - ) { - return _realm_dart_decimal128_negate( - x, - ); - } - - late final _realm_dart_decimal128_negatePtr = _lookup< - ffi.NativeFunction>( - 'realm_dart_decimal128_negate'); - late final _realm_dart_decimal128_negate = _realm_dart_decimal128_negatePtr - .asFunction(); - - realm_decimal128_t realm_dart_decimal128_subtract( - realm_decimal128_t x, - realm_decimal128_t y, - ) { - return _realm_dart_decimal128_subtract( - x, - y, - ); - } - - late final _realm_dart_decimal128_subtractPtr = _lookup< - ffi.NativeFunction< - realm_decimal128_t Function(realm_decimal128_t, - realm_decimal128_t)>>('realm_dart_decimal128_subtract'); - late final _realm_dart_decimal128_subtract = - _realm_dart_decimal128_subtractPtr.asFunction< - realm_decimal128_t Function( - realm_decimal128_t, realm_decimal128_t)>(); - - int realm_dart_decimal128_to_int64( - realm_decimal128_t x, - ) { - return _realm_dart_decimal128_to_int64( - x, - ); - } - - late final _realm_dart_decimal128_to_int64Ptr = - _lookup>( - 'realm_dart_decimal128_to_int64'); - late final _realm_dart_decimal128_to_int64 = - _realm_dart_decimal128_to_int64Ptr - .asFunction(); - - realm_string_t realm_dart_decimal128_to_string( - realm_decimal128_t x, - ) { - return _realm_dart_decimal128_to_string( - x, - ); - } - - late final _realm_dart_decimal128_to_stringPtr = - _lookup>( - 'realm_dart_decimal128_to_string'); - late final _realm_dart_decimal128_to_string = - _realm_dart_decimal128_to_stringPtr - .asFunction(); - - void realm_dart_delete_persistent_handle( - ffi.Pointer handle, - ) { - return _realm_dart_delete_persistent_handle( - handle, - ); - } - - late final _realm_dart_delete_persistent_handlePtr = - _lookup)>>( - 'realm_dart_delete_persistent_handle'); - late final _realm_dart_delete_persistent_handle = - _realm_dart_delete_persistent_handlePtr - .asFunction)>(); - - void realm_dart_detach_logger( - int port, - ) { - return _realm_dart_detach_logger( - port, - ); - } - - late final _realm_dart_detach_loggerPtr = - _lookup>( - 'realm_dart_detach_logger'); - late final _realm_dart_detach_logger = - _realm_dart_detach_loggerPtr.asFunction(); - - /// implemented for Android only - ffi.Pointer realm_dart_get_bundle_id() { - return _realm_dart_get_bundle_id(); - } - - late final _realm_dart_get_bundle_idPtr = - _lookup Function()>>( - 'realm_dart_get_bundle_id'); - late final _realm_dart_get_bundle_id = _realm_dart_get_bundle_idPtr - .asFunction Function()>(); - - ffi.Pointer realm_dart_get_device_name() { - return _realm_dart_get_device_name(); - } - - late final _realm_dart_get_device_namePtr = - _lookup Function()>>( - 'realm_dart_get_device_name'); - late final _realm_dart_get_device_name = _realm_dart_get_device_namePtr - .asFunction Function()>(); - - ffi.Pointer realm_dart_get_device_version() { - return _realm_dart_get_device_version(); - } - - late final _realm_dart_get_device_versionPtr = - _lookup Function()>>( - 'realm_dart_get_device_version'); - late final _realm_dart_get_device_version = _realm_dart_get_device_versionPtr - .asFunction Function()>(); - - /// implemented for iOS and Android only - ffi.Pointer realm_dart_get_files_path() { - return _realm_dart_get_files_path(); - } - - late final _realm_dart_get_files_pathPtr = - _lookup Function()>>( - 'realm_dart_get_files_path'); - late final _realm_dart_get_files_path = _realm_dart_get_files_pathPtr - .asFunction Function()>(); - - int realm_dart_get_thread_id() { - return _realm_dart_get_thread_id(); - } - - late final _realm_dart_get_thread_idPtr = - _lookup>( - 'realm_dart_get_thread_id'); - late final _realm_dart_get_thread_id = - _realm_dart_get_thread_idPtr.asFunction(); - - void realm_dart_init_debug_logger() { - return _realm_dart_init_debug_logger(); - } - - late final _realm_dart_init_debug_loggerPtr = - _lookup>( - 'realm_dart_init_debug_logger'); - late final _realm_dart_init_debug_logger = - _realm_dart_init_debug_loggerPtr.asFunction(); - - void realm_dart_initializeDartApiDL( - ffi.Pointer data, - ) { - return _realm_dart_initializeDartApiDL( - data, - ); - } - - late final _realm_dart_initializeDartApiDLPtr = - _lookup)>>( - 'realm_dart_initializeDartApiDL'); - late final _realm_dart_initializeDartApiDL = - _realm_dart_initializeDartApiDLPtr - .asFunction)>(); - - void realm_dart_invoke_unlock_callback( - ffi.Pointer error, - ffi.Pointer unlockFunc, - ) { - return _realm_dart_invoke_unlock_callback( - error, - unlockFunc, - ); - } - - late final _realm_dart_invoke_unlock_callbackPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Pointer)>>('realm_dart_invoke_unlock_callback'); - late final _realm_dart_invoke_unlock_callback = - _realm_dart_invoke_unlock_callbackPtr.asFunction< - void Function(ffi.Pointer, ffi.Pointer)>(); - - ffi.Pointer realm_dart_library_version() { - return _realm_dart_library_version(); - } - - late final _realm_dart_library_versionPtr = - _lookup Function()>>( - 'realm_dart_library_version'); - late final _realm_dart_library_version = _realm_dart_library_versionPtr - .asFunction Function()>(); - - void realm_dart_log( - realm_log_level level, - ffi.Pointer category, - ffi.Pointer message, - ) { - return _realm_dart_log( - level.value, - category, - message, - ); - } - - late final _realm_dart_logPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.UnsignedInt, ffi.Pointer, - ffi.Pointer)>>('realm_dart_log'); - late final _realm_dart_log = _realm_dart_logPtr.asFunction< - void Function(int, ffi.Pointer, ffi.Pointer)>(); - - ffi.Pointer realm_dart_object_to_persistent_handle( - Object handle, - ) { - return _realm_dart_object_to_persistent_handle( - handle, - ); - } - - late final _realm_dart_object_to_persistent_handlePtr = - _lookup Function(ffi.Handle)>>( - 'realm_dart_object_to_persistent_handle'); - late final _realm_dart_object_to_persistent_handle = - _realm_dart_object_to_persistent_handlePtr - .asFunction Function(Object)>(); - - Object realm_dart_persistent_handle_to_object( - ffi.Pointer handle, - ) { - return _realm_dart_persistent_handle_to_object( - handle, - ); - } - - late final _realm_dart_persistent_handle_to_objectPtr = - _lookup)>>( - 'realm_dart_persistent_handle_to_object'); - late final _realm_dart_persistent_handle_to_object = - _realm_dart_persistent_handle_to_objectPtr - .asFunction)>(); - - void realm_dart_scheduler_invoke( - int isolateId, - ffi.Pointer userData, - ) { - return _realm_dart_scheduler_invoke( - isolateId, - userData, - ); - } - - late final _realm_dart_scheduler_invokePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Uint64, - ffi.Pointer)>>('realm_dart_scheduler_invoke'); - late final _realm_dart_scheduler_invoke = _realm_dart_scheduler_invokePtr - .asFunction)>(); - - /// implemented for iOS only (for now - valid for all posix) - /// /** - /// * Set the soft limit on number of open files - /// * @param limit The requested limit. If less than zero no attempt is made. - /// * @param[out] out_limit The actual limit set. - /// * - /// * @return true if no error occurred. - /// * - /// * @throws RLM_ERR_FILE_PERMISSION_DENIED if the operation was not permitted. - /// */ - bool realm_dart_set_and_get_rlimit( - int limit, - ffi.Pointer out_limit, - ) { - return _realm_dart_set_and_get_rlimit( - limit, - out_limit, - ); - } - - late final _realm_dart_set_and_get_rlimitPtr = _lookup< - ffi - .NativeFunction)>>( - 'realm_dart_set_and_get_rlimit'); - late final _realm_dart_set_and_get_rlimit = _realm_dart_set_and_get_rlimitPtr - .asFunction)>(); - - void realm_dart_userdata_async_free( - ffi.Pointer userdata, - ) { - return _realm_dart_userdata_async_free( - userdata, - ); - } - - late final _realm_dart_userdata_async_freePtr = - _lookup)>>( - 'realm_dart_userdata_async_free'); - late final _realm_dart_userdata_async_free = - _realm_dart_userdata_async_freePtr - .asFunction)>(); - - realm_dart_userdata_async_t realm_dart_userdata_async_new( - Object handle, - ffi.Pointer callback, - ffi.Pointer scheduler, - ) { - return _realm_dart_userdata_async_new( - handle, - callback, - scheduler, - ); - } - - late final _realm_dart_userdata_async_newPtr = _lookup< - ffi.NativeFunction< - realm_dart_userdata_async_t Function(ffi.Handle, - ffi.Pointer, ffi.Pointer)>>( - 'realm_dart_userdata_async_new'); - late final _realm_dart_userdata_async_new = - _realm_dart_userdata_async_newPtr.asFunction< - realm_dart_userdata_async_t Function( - Object, ffi.Pointer, ffi.Pointer)>(); - - /// Deletes the following files for the given `realm_file_path` if they exist: - /// - the Realm file itself - /// - the .management folder - /// - the .note file - /// - the .log file - /// - /// The .lock file for this Realm cannot and will not be deleted as this is unsafe. - /// If a different process / thread is accessing the Realm at the same time a corrupt state - /// could be the result and checking for a single process state is not possible here. - /// - /// @param realm_file_path The path to the Realm file. All files will be derived from this. - /// @param[out] did_delete_realm If non-null, set to true if the primary Realm file was deleted. - /// Discard value if the function returns an error. - /// - /// @return true if no error occurred. - /// - /// @throws RLM_ERR_FILE_PERMISSION_DENIED if the operation was not permitted. - /// @throws RLM_ERR_FILE_ACCESS_ERROR for any other error while trying to delete the file or folder. - /// @throws RLM_ERR_DELETE_OPENED_REALM if the function was called on an open Realm. - bool realm_delete_files( - ffi.Pointer realm_file_path, - ffi.Pointer did_delete_realm, - ) { - return _realm_delete_files( - realm_file_path, - did_delete_realm, - ); - } - - late final _realm_delete_filesPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, - ffi.Pointer)>>('realm_delete_files'); - late final _realm_delete_files = _realm_delete_filesPtr.asFunction< - bool Function(ffi.Pointer, ffi.Pointer)>(); - - void realm_detach_finalizer( - ffi.Pointer finalizableHandle, - Object handle, - ) { - return _realm_detach_finalizer( - finalizableHandle, - handle, - ); - } - - late final _realm_detach_finalizerPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, ffi.Handle)>>('realm_detach_finalizer'); - late final _realm_detach_finalizer = _realm_detach_finalizerPtr - .asFunction, Object)>(); - - /// Subscribe to notifications for this object. - /// - /// @return A non-null pointer if no exception occurred. - ffi.Pointer - realm_dictionary_add_notification_callback( - ffi.Pointer arg0, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, - ffi.Pointer key_path_array, - realm_on_dictionary_change_func_t on_change, - ) { - return _realm_dictionary_add_notification_callback( - arg0, - userdata, - userdata_free, - key_path_array, - on_change, - ); - } - - late final _realm_dictionary_add_notification_callbackPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - realm_free_userdata_func_t, - ffi.Pointer, - realm_on_dictionary_change_func_t)>>( - 'realm_dictionary_add_notification_callback'); - late final _realm_dictionary_add_notification_callback = - _realm_dictionary_add_notification_callbackPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - realm_free_userdata_func_t, - ffi.Pointer, - realm_on_dictionary_change_func_t)>(); - - /// Clear a dictionary. - /// - /// @return True if no exception occurred. - bool realm_dictionary_clear( - ffi.Pointer arg0, - ) { - return _realm_dictionary_clear( - arg0, - ); - } - - late final _realm_dictionary_clearPtr = _lookup< - ffi - .NativeFunction)>>( - 'realm_dictionary_clear'); - late final _realm_dictionary_clear = _realm_dictionary_clearPtr - .asFunction)>(); - - /// Check if the dictionary contains a certain key - /// - /// @param key to search in the dictionary - /// @param found True if the such key exists - /// @return True if no exception occurred - bool realm_dictionary_contains_key( - ffi.Pointer arg0, - realm_value_t key, - ffi.Pointer found, - ) { - return _realm_dictionary_contains_key( - arg0, - key, - found, - ); - } - - late final _realm_dictionary_contains_keyPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, realm_value_t, - ffi.Pointer)>>('realm_dictionary_contains_key'); - late final _realm_dictionary_contains_key = - _realm_dictionary_contains_keyPtr.asFunction< - bool Function(ffi.Pointer, realm_value_t, - ffi.Pointer)>(); - - /// Check if the dictionary contains a certain value - /// - /// @param value to search in the dictionary - /// @param index the index of the value in the dictionry if such value exists - /// @return True if no exception occurred - bool realm_dictionary_contains_value( - ffi.Pointer arg0, - realm_value_t value, - ffi.Pointer index, - ) { - return _realm_dictionary_contains_value( - arg0, - value, - index, - ); - } - - late final _realm_dictionary_contains_valuePtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, realm_value_t, - ffi.Pointer)>>('realm_dictionary_contains_value'); - late final _realm_dictionary_contains_value = - _realm_dictionary_contains_valuePtr.asFunction< - bool Function(ffi.Pointer, realm_value_t, - ffi.Pointer)>(); - - /// Erase a dictionary element. - /// - /// @param key The key of the element to erase. - /// @param out_erased If non-null, will be set to true if the element was found - /// and erased. - /// @return True if no exception occurred. - bool realm_dictionary_erase( - ffi.Pointer arg0, - realm_value_t key, - ffi.Pointer out_erased, - ) { - return _realm_dictionary_erase( - arg0, - key, - out_erased, - ); - } - - late final _realm_dictionary_erasePtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, realm_value_t, - ffi.Pointer)>>('realm_dictionary_erase'); - late final _realm_dictionary_erase = _realm_dictionary_erasePtr.asFunction< - bool Function(ffi.Pointer, realm_value_t, - ffi.Pointer)>(); - - /// Find an element in a dictionary. - /// - /// @param key The key to look for. - /// @param out_value If non-null, the value for the corresponding key. - /// @param out_found If non-null, will be set to true if the dictionary contained the key. - /// @return True if no exception occurred. - bool realm_dictionary_find( - ffi.Pointer arg0, - realm_value_t key, - ffi.Pointer out_value, - ffi.Pointer out_found, - ) { - return _realm_dictionary_find( - arg0, - key, - out_value, - out_found, - ); - } - - late final _realm_dictionary_findPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - realm_value_t, - ffi.Pointer, - ffi.Pointer)>>('realm_dictionary_find'); - late final _realm_dictionary_find = _realm_dictionary_findPtr.asFunction< - bool Function(ffi.Pointer, realm_value_t, - ffi.Pointer, ffi.Pointer)>(); - - /// Get an dictionary from a thread-safe reference, potentially originating in a - /// different `realm_t` instance - ffi.Pointer realm_dictionary_from_thread_safe_reference( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - return _realm_dictionary_from_thread_safe_reference( - arg0, - arg1, - ); - } - - late final _realm_dictionary_from_thread_safe_referencePtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer)>>( - 'realm_dictionary_from_thread_safe_reference'); - late final _realm_dictionary_from_thread_safe_reference = - _realm_dictionary_from_thread_safe_referencePtr.asFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer)>(); - - /// Get the key-value pair at @a index. - /// - /// Note that the indices of elements in the dictionary move around as other - /// elements are inserted/removed. - /// - /// @param index The index in the dictionary. - /// @param out_key If non-null, will be set to the key at the corresponding index. - /// @param out_value If non-null, will be set to the value at the corresponding index. - /// @return True if no exception occurred. - bool realm_dictionary_get( - ffi.Pointer arg0, - int index, - ffi.Pointer out_key, - ffi.Pointer out_value, - ) { - return _realm_dictionary_get( - arg0, - index, - out_key, - out_value, - ); - } - - late final _realm_dictionary_getPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Size, - ffi.Pointer, - ffi.Pointer)>>('realm_dictionary_get'); - late final _realm_dictionary_get = _realm_dictionary_getPtr.asFunction< - bool Function(ffi.Pointer, int, - ffi.Pointer, ffi.Pointer)>(); - - /// Returns the list of keys changed for the dictionary passed as argument. - /// The user must assure that there is enough memory to accomodate all the keys - /// calling `realm_dictionary_get_changes` before. - /// - /// @param changes valid ptr to the dictionary changes structure - /// @param deletions list of deleted keys - /// @param deletions_size size of the list of deleted keys - /// @param insertions list of inserted keys - /// @param insertions_size size of the list of inserted keys - /// @param modifications list of modified keys - /// @param modification_size size of the list of modified keys - /// @param collection_was_cleared whether or not the collection was cleared - void realm_dictionary_get_changed_keys( - ffi.Pointer changes, - ffi.Pointer deletions, - ffi.Pointer deletions_size, - ffi.Pointer insertions, - ffi.Pointer insertions_size, - ffi.Pointer modifications, - ffi.Pointer modification_size, - ffi.Pointer collection_was_cleared, - ) { - return _realm_dictionary_get_changed_keys( - changes, - deletions, - deletions_size, - insertions, - insertions_size, - modifications, - modification_size, - collection_was_cleared, - ); - } - - late final _realm_dictionary_get_changed_keysPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>>('realm_dictionary_get_changed_keys'); - late final _realm_dictionary_get_changed_keys = - _realm_dictionary_get_changed_keysPtr.asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>(); - - /// Returns the number of changes occurred to the dictionary passed as argument - /// - /// @param changes valid ptr to the dictionary changes structure - /// @param out_deletions_size number of deletions - /// @param out_insertion_size number of insertions - /// @param out_modification_size number of modifications - /// @param out_was_deleted a flag to signal if the dictionary has been deleted. - void realm_dictionary_get_changes( - ffi.Pointer changes, - ffi.Pointer out_deletions_size, - ffi.Pointer out_insertion_size, - ffi.Pointer out_modification_size, - ffi.Pointer out_was_deleted, - ) { - return _realm_dictionary_get_changes( - changes, - out_deletions_size, - out_insertion_size, - out_modification_size, - out_was_deleted, - ); - } - - late final _realm_dictionary_get_changesPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>>('realm_dictionary_get_changes'); - late final _realm_dictionary_get_changes = - _realm_dictionary_get_changesPtr.asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>(); - - /// Fetch a dictioanry from a dictionary. - /// @return a valid dictionary that needs to be deleted by the caller or nullptr in case of an error. - ffi.Pointer realm_dictionary_get_dictionary( - ffi.Pointer dictionary, - realm_value_t key, - ) { - return _realm_dictionary_get_dictionary( - dictionary, - key, - ); - } - - late final _realm_dictionary_get_dictionaryPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - realm_value_t)>>('realm_dictionary_get_dictionary'); - late final _realm_dictionary_get_dictionary = - _realm_dictionary_get_dictionaryPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, realm_value_t)>(); - - /// Return the list of keys stored in the dictionary - /// - /// @param out_size number of keys - /// @param out_keys the list of keys in the dictionary, the memory has to be released once it is no longer used. - /// @return True if no exception occurred. - bool realm_dictionary_get_keys( - ffi.Pointer arg0, - ffi.Pointer out_size, - ffi.Pointer> out_keys, - ) { - return _realm_dictionary_get_keys( - arg0, - out_size, - out_keys, - ); - } - - late final _realm_dictionary_get_keysPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>)>>( - 'realm_dictionary_get_keys'); - late final _realm_dictionary_get_keys = - _realm_dictionary_get_keysPtr.asFunction< - bool Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer>)>(); - - /// Get object identified by key - /// - /// @return A non-NULL pointer if the value associated with key is an object. - ffi.Pointer realm_dictionary_get_linked_object( - ffi.Pointer arg0, - realm_value_t key, - ) { - return _realm_dictionary_get_linked_object( - arg0, - key, - ); - } - - late final _realm_dictionary_get_linked_objectPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - realm_value_t)>>('realm_dictionary_get_linked_object'); - late final _realm_dictionary_get_linked_object = - _realm_dictionary_get_linked_objectPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, realm_value_t)>(); - - /// Fetch a list from a dictionary. - /// @return a valid list that needs to be deleted by the caller or nullptr in case of an error. - ffi.Pointer realm_dictionary_get_list( - ffi.Pointer dictionary, - realm_value_t key, - ) { - return _realm_dictionary_get_list( - dictionary, - key, - ); - } - - late final _realm_dictionary_get_listPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - realm_value_t)>>('realm_dictionary_get_list'); - late final _realm_dictionary_get_list = - _realm_dictionary_get_listPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, realm_value_t)>(); - - /// Get the property that this dictionary came from. - /// - /// @return True if no exception occurred. - bool realm_dictionary_get_property( - ffi.Pointer arg0, - ffi.Pointer out_info, - ) { - return _realm_dictionary_get_property( - arg0, - out_info, - ); - } - - late final _realm_dictionary_get_propertyPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, - ffi.Pointer)>>( - 'realm_dictionary_get_property'); - late final _realm_dictionary_get_property = - _realm_dictionary_get_propertyPtr.asFunction< - bool Function(ffi.Pointer, - ffi.Pointer)>(); - - /// Insert or update an element in a dictionary. - /// - /// If the key already exists, the value will be overwritten. - /// - /// @param key The lookup key. - /// @param value The value to insert. - /// @param out_index If non-null, will be set to the index of the element after - /// insertion/update. - /// @param out_inserted If non-null, will be set to true if the key did not - /// already exist. - /// @return True if no exception occurred. - bool realm_dictionary_insert( - ffi.Pointer arg0, - realm_value_t key, - realm_value_t value, - ffi.Pointer out_index, - ffi.Pointer out_inserted, - ) { - return _realm_dictionary_insert( - arg0, - key, - value, - out_index, - out_inserted, - ); - } - - late final _realm_dictionary_insertPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - realm_value_t, - realm_value_t, - ffi.Pointer, - ffi.Pointer)>>('realm_dictionary_insert'); - late final _realm_dictionary_insert = _realm_dictionary_insertPtr.asFunction< - bool Function(ffi.Pointer, realm_value_t, - realm_value_t, ffi.Pointer, ffi.Pointer)>(); - - ffi.Pointer realm_dictionary_insert_dictionary( - ffi.Pointer arg0, - realm_value_t arg1, - ) { - return _realm_dictionary_insert_dictionary( - arg0, - arg1, - ); - } - - late final _realm_dictionary_insert_dictionaryPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - realm_value_t)>>('realm_dictionary_insert_dictionary'); - late final _realm_dictionary_insert_dictionary = - _realm_dictionary_insert_dictionaryPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, realm_value_t)>(); - - /// Insert an embedded object. - /// - /// @return A non-NULL pointer if the object was created successfully. - ffi.Pointer realm_dictionary_insert_embedded( - ffi.Pointer arg0, - realm_value_t key, - ) { - return _realm_dictionary_insert_embedded( - arg0, - key, - ); - } - - late final _realm_dictionary_insert_embeddedPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - realm_value_t)>>('realm_dictionary_insert_embedded'); - late final _realm_dictionary_insert_embedded = - _realm_dictionary_insert_embeddedPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, realm_value_t)>(); - - /// Insert a collection inside a dictionary (only available for mixed types) - /// - /// @param dictionary valid ptr to a dictionary of mixed - /// @param key the mixed representing a key for a dictionary (only string) - /// @return pointer to a valid collection that has been just inserted at the key passed as argument - ffi.Pointer realm_dictionary_insert_list( - ffi.Pointer dictionary, - realm_value_t key, - ) { - return _realm_dictionary_insert_list( - dictionary, - key, - ); - } - - late final _realm_dictionary_insert_listPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - realm_value_t)>>('realm_dictionary_insert_list'); - late final _realm_dictionary_insert_list = - _realm_dictionary_insert_listPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, realm_value_t)>(); - - /// Check if a list is valid. - /// - /// @return True if the list is valid. - bool realm_dictionary_is_valid( - ffi.Pointer arg0, - ) { - return _realm_dictionary_is_valid( - arg0, - ); - } - - late final _realm_dictionary_is_validPtr = _lookup< - ffi - .NativeFunction)>>( - 'realm_dictionary_is_valid'); - late final _realm_dictionary_is_valid = _realm_dictionary_is_validPtr - .asFunction)>(); - - /// Resolve the list in the context of a given Realm instance. - /// - /// This is equivalent to producing a thread-safe reference and resolving it in the frozen realm. - /// - /// If resolution is possible, a valid resolved object is produced at '*resolved*'. - /// If resolution is not possible, but no error occurs, '*resolved' is set to NULL - /// - /// @return true if no error occurred. - bool realm_dictionary_resolve_in( - ffi.Pointer list, - ffi.Pointer target_realm, - ffi.Pointer> resolved, - ) { - return _realm_dictionary_resolve_in( - list, - target_realm, - resolved, - ); - } - - late final _realm_dictionary_resolve_inPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>)>>( - 'realm_dictionary_resolve_in'); - late final _realm_dictionary_resolve_in = - _realm_dictionary_resolve_inPtr.asFunction< - bool Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer>)>(); - - /// Get the size of a dictionary (the number of unique keys). - /// - /// This function may fail if the object owning the dictionary has been deleted. - /// - /// @param out_size Where to put the dictionary size. May be NULL. - /// @return True if no exception occurred. - bool realm_dictionary_size( - ffi.Pointer arg0, - ffi.Pointer out_size, - ) { - return _realm_dictionary_size( - arg0, - out_size, - ); - } - - late final _realm_dictionary_sizePtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, - ffi.Pointer)>>('realm_dictionary_size'); - late final _realm_dictionary_size = _realm_dictionary_sizePtr.asFunction< - bool Function(ffi.Pointer, ffi.Pointer)>(); - - /// Convert a dictionary to results. - /// - /// @return A non-null pointer if no exception occurred. - ffi.Pointer realm_dictionary_to_results( - ffi.Pointer arg0, - ) { - return _realm_dictionary_to_results( - arg0, - ); - } - - late final _realm_dictionary_to_resultsPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_dictionary_to_results'); - late final _realm_dictionary_to_results = - _realm_dictionary_to_resultsPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer)>(); - - /// Return true if two API objects refer to the same underlying data. Objects - /// with different types are never equal. - /// - /// Note: This function cannot be used with types that have value semantics, only - /// opaque types that have object semantics. - /// - /// - `realm_t` objects are identical if they represent the same instance (not - /// just if they represent the same file). - /// - `realm_schema_t` objects are equal if the represented schemas are equal. - /// - `realm_config_t` objects are equal if the configurations are equal. - /// - `realm_object_t` objects are identical if they belong to the same realm - /// and class, and have the same object key. - /// - `realm_list_t` and other collection objects are identical if they come - /// from the same object and property. - /// - `realm_query_t` objects are never equal. - /// - `realm_scheduler_t` objects are equal if they represent the same - /// scheduler. - /// - Query descriptor objects are equal if they represent equivalent - /// descriptors. - /// - `realm_async_error_t` objects are equal if they represent the same - /// exception instance. - /// - /// This function cannot fail. - bool realm_equals( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - return _realm_equals( - arg0, - arg1, - ); - } - - late final _realm_equalsPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, ffi.Pointer)>>('realm_equals'); - late final _realm_equals = _realm_equalsPtr.asFunction< - bool Function(ffi.Pointer, ffi.Pointer)>(); - - /// Find a by the name of @a name. - /// - /// @param name The name of the class. - /// @param out_found Set to true if the class was found and no error occurred. - /// Otherwise, false. May not be NULL. - /// @param out_class_info A pointer to a `realm_class_info_t` that will be - /// populated with information about the class. May be - /// NULL. - /// @return True if no exception occurred. - bool realm_find_class( - ffi.Pointer arg0, - ffi.Pointer name, - ffi.Pointer out_found, - ffi.Pointer out_class_info, - ) { - return _realm_find_class( - arg0, - name, - out_found, - out_class_info, - ); - } - - late final _realm_find_classPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>>('realm_find_class'); - late final _realm_find_class = _realm_find_classPtr.asFunction< - bool Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer, ffi.Pointer)>(); - - /// Find the primary key property for a class, if it has one. - /// - /// @param class_key The table key for this class. - /// @param out_found Will be set to true if the property was found. May not be - /// NULL. - /// @param out_property_info A property to a `realm_property_info_t` that will be - /// populated with information about the property, if it - /// was found. May be NULL. - /// @return True if no exception occurred. - bool realm_find_primary_key_property( - ffi.Pointer arg0, - int class_key, - ffi.Pointer out_found, - ffi.Pointer out_property_info, - ) { - return _realm_find_primary_key_property( - arg0, - class_key, - out_found, - out_property_info, - ); - } - - late final _realm_find_primary_key_propertyPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, realm_class_key_t, - ffi.Pointer, ffi.Pointer)>>( - 'realm_find_primary_key_property'); - late final _realm_find_primary_key_property = - _realm_find_primary_key_propertyPtr.asFunction< - bool Function(ffi.Pointer, int, ffi.Pointer, - ffi.Pointer)>(); - - /// Find a property by the internal (non-public) name of @a name. - /// - /// @param class_key The table key for the class. - /// @param name The name of the property. - /// @param out_found Will be set to true if the property was found. May not be - /// NULL. - /// @param out_property_info A pointer to a `realm_property_info_t` that will be - /// populated with information about the property. May - /// be NULL. - /// @return True if no exception occurred. - bool realm_find_property( - ffi.Pointer arg0, - int class_key, - ffi.Pointer name, - ffi.Pointer out_found, - ffi.Pointer out_property_info, - ) { - return _realm_find_property( - arg0, - class_key, - name, - out_found, - out_property_info, - ); - } - - late final _realm_find_propertyPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - realm_class_key_t, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>>('realm_find_property'); - late final _realm_find_property = _realm_find_propertyPtr.asFunction< - bool Function(ffi.Pointer, int, ffi.Pointer, - ffi.Pointer, ffi.Pointer)>(); - - /// Find a property with the public name of @a name. - /// - /// @param class_key The table key for the class. - /// @param public_name The public name of the property. - /// @param out_found Will be set to true if the property was found. May not be - /// NULL. - /// @param out_property_info A pointer to a `realm_property_info_t` that will be - /// populated with information about the property. May - /// be NULL. - /// @return True if no exception occurred. - bool realm_find_property_by_public_name( - ffi.Pointer arg0, - int class_key, - ffi.Pointer public_name, - ffi.Pointer out_found, - ffi.Pointer out_property_info, - ) { - return _realm_find_property_by_public_name( - arg0, - class_key, - public_name, - out_found, - out_property_info, - ); - } - - late final _realm_find_property_by_public_namePtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - realm_class_key_t, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>>( - 'realm_find_property_by_public_name'); - late final _realm_find_property_by_public_name = - _realm_find_property_by_public_namePtr.asFunction< - bool Function(ffi.Pointer, int, ffi.Pointer, - ffi.Pointer, ffi.Pointer)>(); - - ffi.Pointer realm_flx_sync_config_new( - ffi.Pointer arg0, - ) { - return _realm_flx_sync_config_new( - arg0, - ); - } - - late final _realm_flx_sync_config_newPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_flx_sync_config_new'); - late final _realm_flx_sync_config_new = - _realm_flx_sync_config_newPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer)>(); - - /// Free memory allocated by the module this library was linked into. - /// - /// This is needed for raw memory buffers such as string copies or arrays - /// returned from a library function. Realm C Wrapper objects on the other hand - /// should always be freed with realm_release() only. - void realm_free( - ffi.Pointer buffer, - ) { - return _realm_free( - buffer, - ); - } - - late final _realm_freePtr = - _lookup)>>( - 'realm_free'); - late final _realm_free = - _realm_freePtr.asFunction)>(); - - /// Produce a frozen view of this realm. - /// - /// @return A non-NULL realm instance representing the frozen state. - ffi.Pointer realm_freeze( - ffi.Pointer arg0, - ) { - return _realm_freeze( - arg0, - ); - } - - late final _realm_freezePtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer)>>('realm_freeze'); - late final _realm_freeze = _realm_freezePtr - .asFunction Function(ffi.Pointer)>(); - - /// Create a `realm_t` object from a thread-safe reference to the same realm. - /// - /// @param tsr Thread-safe reference object created by calling - /// `realm_get_thread_safe_reference()` with a `realm_t` instance. - /// @param scheduler The scheduler to use for the new `realm_t` instance. May be - /// NULL, in which case the default scheduler for the current - /// thread is used. - /// @return A non-null pointer if no error occurred. - ffi.Pointer realm_from_thread_safe_reference( - ffi.Pointer tsr, - ffi.Pointer scheduler, - ) { - return _realm_from_thread_safe_reference( - tsr, - scheduler, - ); - } - - late final _realm_from_thread_safe_referencePtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer)>>( - 'realm_from_thread_safe_reference'); - late final _realm_from_thread_safe_reference = - _realm_from_thread_safe_referencePtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer)>(); - - /// Get information about an async error, potentially coming from another thread. - /// - /// This function does not allocate any memory. - /// - /// @param err A pointer to a `realm_error_t` struct that will be populated with - /// information about the error. May not be NULL. - /// @return A bool indicating whether or not an error is available to be returned - /// @see realm_get_last_error() - bool realm_get_async_error( - ffi.Pointer err, - ffi.Pointer out_err, - ) { - return _realm_get_async_error( - err, - out_err, - ); - } - - late final _realm_get_async_errorPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, - ffi.Pointer)>>('realm_get_async_error'); - late final _realm_get_async_error = _realm_get_async_errorPtr.asFunction< - bool Function( - ffi.Pointer, ffi.Pointer)>(); - - /// Fetch the backlinks for the object passed as argument. - /// @return a valid ptr to realm results that contains all the backlinks for the object, or null in case of errors. - ffi.Pointer realm_get_backlinks( - ffi.Pointer object, - int source_table_key, - int property_key, - ) { - return _realm_get_backlinks( - object, - source_table_key, - property_key, - ); - } - - late final _realm_get_backlinksPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - realm_class_key_t, realm_property_key_t)>>('realm_get_backlinks'); - late final _realm_get_backlinks = _realm_get_backlinksPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, int, int)>(); - - /// Get the actual log category names (currently 15) - /// @param num_values number of values in the out_values array - /// @param out_values pointer to an array of size num_values - /// @return returns the number of categories returned. If num_values is zero, it will - /// return the total number of categories. - int realm_get_category_names( - int num_values, - ffi.Pointer> out_values, - ) { - return _realm_get_category_names( - num_values, - out_values, - ); - } - - late final _realm_get_category_namesPtr = _lookup< - ffi.NativeFunction< - ffi.Size Function(ffi.Size, - ffi.Pointer>)>>('realm_get_category_names'); - late final _realm_get_category_names = _realm_get_category_namesPtr - .asFunction>)>(); - - /// Get the class with @a key from the schema. - /// - /// Passing an invalid @a key for this schema is considered an error. - /// - /// @param key The key of the class, as discovered by `realm_get_class_keys()`. - /// @param out_class_info A pointer to a `realm_class_info_t` that will be - /// populated with the information of the class. May be - /// NULL, though that's kind of pointless. - /// @return True if no exception occurred. - bool realm_get_class( - ffi.Pointer arg0, - int key, - ffi.Pointer out_class_info, - ) { - return _realm_get_class( - arg0, - key, - out_class_info, - ); - } - - late final _realm_get_classPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, realm_class_key_t, - ffi.Pointer)>>('realm_get_class'); - late final _realm_get_class = _realm_get_classPtr.asFunction< - bool Function( - ffi.Pointer, int, ffi.Pointer)>(); - - /// Get the table keys for classes in the schema. - /// In case of errors this function will return false (errors to be fetched via `realm_get_last_error()`). - /// If data is not copied the function will return true and set `out_n` with the capacity needed. - /// Data is only copied if the input array has enough capacity, otherwise the needed array capacity will be set. - /// - /// @param out_keys An array that will contain the keys of each class in the - /// schema. Array may be NULL, in this case no data will be copied and `out_n` set if not NULL. - /// @param max The maximum number of keys to write to `out_keys`. - /// @param out_n The actual number of classes. May be NULL. - /// @return True if no exception occurred. - bool realm_get_class_keys( - ffi.Pointer arg0, - ffi.Pointer out_keys, - int max, - ffi.Pointer out_n, - ) { - return _realm_get_class_keys( - arg0, - out_keys, - max, - out_n, - ); - } - - late final _realm_get_class_keysPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ffi.Pointer)>>('realm_get_class_keys'); - late final _realm_get_class_keys = _realm_get_class_keysPtr.asFunction< - bool Function(ffi.Pointer, ffi.Pointer, int, - ffi.Pointer)>(); - - /// Get the list of properties for the class with this @a key. - /// In case of errors this function will return false (errors to be fetched via `realm_get_last_error()`). - /// If data is not copied the function will return true and set `out_n` with the capacity needed. - /// Data is only copied if the input array has enough capacity, otherwise the needed array capacity will be set. - /// - /// @param out_properties A pointer to an array of `realm_property_info_t`, which - /// will be populated with the information about the - /// properties. Array may be NULL, in this case no data will be copied and `out_n` set if not - /// NULL. - /// @param max The maximum number of entries to write to `out_properties`. - /// @param out_n The actual number of properties written to `out_properties`. - /// @return True if no exception occurred. - bool realm_get_class_properties( - ffi.Pointer arg0, - int key, - ffi.Pointer out_properties, - int max, - ffi.Pointer out_n, - ) { - return _realm_get_class_properties( - arg0, - key, - out_properties, - max, - out_n, - ); - } - - late final _realm_get_class_propertiesPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - realm_class_key_t, - ffi.Pointer, - ffi.Size, - ffi.Pointer)>>('realm_get_class_properties'); - late final _realm_get_class_properties = - _realm_get_class_propertiesPtr.asFunction< - bool Function( - ffi.Pointer, - int, - ffi.Pointer, - int, - ffi.Pointer)>(); - - /// Get a dictionary instance for the property of an object. - /// - /// Note: It is up to the caller to call `realm_release()` on the returned dictionary. - /// - /// @return A non-null pointer if no exception occurred. - ffi.Pointer realm_get_dictionary( - ffi.Pointer arg0, - int arg1, - ) { - return _realm_get_dictionary( - arg0, - arg1, - ); - } - - late final _realm_get_dictionaryPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - realm_property_key_t)>>('realm_get_dictionary'); - late final _realm_get_dictionary = _realm_get_dictionaryPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, int)>(); - - /// Get the last error that happened on this thread. - /// - /// Errors are thread-local. Getting the error must happen on the same thread as - /// the call that caused the error to occur. The error is specific to the current - /// thread, and not the Realm instance for which the error occurred. - /// - /// Note: The error message in @a err will only be safe to use until the next API - /// call is made on the current thread. - /// - /// Note: The error is not cleared by subsequent successful calls to this - /// function, but it will be overwritten by subsequent failing calls to - /// other library functions. - /// - /// Note: Calling this function does not clear the current last error. - /// - /// This function does not allocate any memory. - /// - /// @param err A pointer to a `realm_error_t` struct that will be populated with - /// information about the last error, if there is one. May be NULL. - /// @return True if an error occurred. - bool realm_get_last_error( - ffi.Pointer err, - ) { - return _realm_get_last_error( - err, - ); - } - - late final _realm_get_last_errorPtr = _lookup< - ffi.NativeFunction)>>( - 'realm_get_last_error'); - late final _realm_get_last_error = _realm_get_last_errorPtr - .asFunction)>(); - - /// Convert the last error to `realm_async_error_t`, which can safely be passed - /// between threads. - /// - /// Note: This function does not clear the last error. - /// - /// @return A non-null pointer if there was an error on this thread. - /// @see realm_get_last_error() - /// @see realm_get_async_error() - /// @see realm_clear_last_error() - ffi.Pointer realm_get_last_error_as_async_error() { - return _realm_get_last_error_as_async_error(); - } - - late final _realm_get_last_error_as_async_errorPtr = - _lookup Function()>>( - 'realm_get_last_error_as_async_error'); - late final _realm_get_last_error_as_async_error = - _realm_get_last_error_as_async_errorPtr - .asFunction Function()>(); - - ffi.Pointer realm_get_library_cpu_arch() { - return _realm_get_library_cpu_arch(); - } - - late final _realm_get_library_cpu_archPtr = - _lookup Function()>>( - 'realm_get_library_cpu_arch'); - late final _realm_get_library_cpu_arch = _realm_get_library_cpu_archPtr - .asFunction Function()>(); - - /// Get a string representing the version number of the Realm library. - /// - /// @return A null-terminated string. - ffi.Pointer realm_get_library_version() { - return _realm_get_library_version(); - } - - late final _realm_get_library_versionPtr = - _lookup Function()>>( - 'realm_get_library_version'); - late final _realm_get_library_version = _realm_get_library_versionPtr - .asFunction Function()>(); - - /// Get individual components of the version number of the Realm library. - /// - /// @param out_major The major version number (X.0.0). - /// @param out_minor The minor version number (0.X.0). - /// @param out_patch The patch version number (0.0.X). - /// @param out_extra The extra version string (0.0.0-X). - void realm_get_library_version_numbers( - ffi.Pointer out_major, - ffi.Pointer out_minor, - ffi.Pointer out_patch, - ffi.Pointer> out_extra, - ) { - return _realm_get_library_version_numbers( - out_major, - out_minor, - out_patch, - out_extra, - ); - } - - late final _realm_get_library_version_numbersPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer, ffi.Pointer>)>>( - 'realm_get_library_version_numbers'); - late final _realm_get_library_version_numbers = - _realm_get_library_version_numbersPtr.asFunction< - void Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer, ffi.Pointer>)>(); - - /// Return the object linked by the given property - /// - /// @return A non-NULL pointer if an object is found. - ffi.Pointer realm_get_linked_object( - ffi.Pointer arg0, - int arg1, - ) { - return _realm_get_linked_object( - arg0, - arg1, - ); - } - - late final _realm_get_linked_objectPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - realm_property_key_t)>>('realm_get_linked_object'); - late final _realm_get_linked_object = _realm_get_linked_objectPtr.asFunction< - ffi.Pointer Function(ffi.Pointer, int)>(); - - /// Get a list instance for the property of an object. - /// - /// Note: It is up to the caller to call `realm_release()` on the returned list. - /// - /// @return A non-null pointer if no exception occurred. - ffi.Pointer realm_get_list( - ffi.Pointer arg0, - int arg1, - ) { - return _realm_get_list( - arg0, - arg1, - ); - } - - late final _realm_get_listPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - realm_property_key_t)>>('realm_get_list'); - late final _realm_get_list = _realm_get_listPtr.asFunction< - ffi.Pointer Function(ffi.Pointer, int)>(); - - /// Get the logging level for given category. - realm_log_level realm_get_log_level_category( - ffi.Pointer arg0, - ) { - return realm_log_level.fromValue(_realm_get_log_level_category( - arg0, - )); - } - - late final _realm_get_log_level_categoryPtr = _lookup< - ffi.NativeFunction)>>( - 'realm_get_log_level_category'); - late final _realm_get_log_level_category = _realm_get_log_level_categoryPtr - .asFunction)>(); - - /// Return the number of classes in the Realm's schema. - /// - /// This cannot fail. - int realm_get_num_classes( - ffi.Pointer arg0, - ) { - return _realm_get_num_classes( - arg0, - ); - } - - late final _realm_get_num_classesPtr = - _lookup)>>( - 'realm_get_num_classes'); - late final _realm_get_num_classes = _realm_get_num_classesPtr - .asFunction)>(); - - /// Get the number of objects in a table (class). - /// - /// @param out_count A pointer to a `size_t` that will contain the number of - /// objects, if successful. - /// @return True if the table key was valid for this realm. - bool realm_get_num_objects( - ffi.Pointer arg0, - int arg1, - ffi.Pointer out_count, - ) { - return _realm_get_num_objects( - arg0, - arg1, - out_count, - ); - } - - late final _realm_get_num_objectsPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, realm_class_key_t, - ffi.Pointer)>>('realm_get_num_objects'); - late final _realm_get_num_objects = _realm_get_num_objectsPtr.asFunction< - bool Function(ffi.Pointer, int, ffi.Pointer)>(); - - /// Get the number of versions found in the Realm file. - /// - /// @param out_versions_count A pointer to a `size_t` that will contain the number of - /// versions, if successful. - /// @return True if no exception occurred. - bool realm_get_num_versions( - ffi.Pointer arg0, - ffi.Pointer out_versions_count, - ) { - return _realm_get_num_versions( - arg0, - out_versions_count, - ); - } - - late final _realm_get_num_versionsPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, - ffi.Pointer)>>('realm_get_num_versions'); - late final _realm_get_num_versions = _realm_get_num_versionsPtr.asFunction< - bool Function(ffi.Pointer, ffi.Pointer)>(); - - /// Get an object with a particular object key. - /// - /// @param class_key The class key. - /// @param obj_key The key to the object. Passing a non-existent key is - /// considered an error. - /// @return A non-NULL pointer if no exception occurred. - ffi.Pointer realm_get_object( - ffi.Pointer arg0, - int class_key, - int obj_key, - ) { - return _realm_get_object( - arg0, - class_key, - obj_key, - ); - } - - late final _realm_get_objectPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - realm_class_key_t, realm_object_key_t)>>('realm_get_object'); - late final _realm_get_object = _realm_get_objectPtr.asFunction< - ffi.Pointer Function(ffi.Pointer, int, int)>(); - - /// Get the schema version for this realm at the path. - int realm_get_persisted_schema_version( - ffi.Pointer config, - ) { - return _realm_get_persisted_schema_version( - config, - ); - } - - late final _realm_get_persisted_schema_versionPtr = _lookup< - ffi.NativeFunction)>>( - 'realm_get_persisted_schema_version'); - late final _realm_get_persisted_schema_version = - _realm_get_persisted_schema_versionPtr - .asFunction)>(); - - /// Find a property by its column key. - /// - /// It is an error to pass a property @a key that is not present in this class. - /// - /// @param class_key The key of the class. - /// @param key The column key for the property. - /// @param out_property_info A pointer to a `realm_property_info_t` that will be - /// populated with information about the property. - /// @return True if no exception occurred. - bool realm_get_property( - ffi.Pointer arg0, - int class_key, - int key, - ffi.Pointer out_property_info, - ) { - return _realm_get_property( - arg0, - class_key, - key, - out_property_info, - ); - } - - late final _realm_get_propertyPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - realm_class_key_t, - realm_property_key_t, - ffi.Pointer)>>('realm_get_property'); - late final _realm_get_property = _realm_get_propertyPtr.asFunction< - bool Function(ffi.Pointer, int, int, - ffi.Pointer)>(); - - /// Get the property keys for the class with this @a key. - /// In case of errors this function will return false (errors to be fetched via `realm_get_last_error()`). - /// If data is not copied the function will return true and set `out_n` with the capacity needed. - /// Data is only copied if the input array has enough capacity, otherwise the needed array capacity will be set. - /// - /// @param key The class key. - /// @param out_col_keys An array of property keys. Array may be NULL, - /// in this case no data will be copied and `out_n` set if not NULL. - /// @param max The maximum number of keys to write to `out_col_keys`. Ignored if - /// `out_col_keys == NULL`. - /// @param out_n The actual number of properties written to `out_col_keys` (if - /// non-NULL), or number of properties in the class. - /// @return True if no exception occurred. - bool realm_get_property_keys( - ffi.Pointer arg0, - int key, - ffi.Pointer out_col_keys, - int max, - ffi.Pointer out_n, - ) { - return _realm_get_property_keys( - arg0, - key, - out_col_keys, - max, - out_n, - ); - } - - late final _realm_get_property_keysPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - realm_class_key_t, - ffi.Pointer, - ffi.Size, - ffi.Pointer)>>('realm_get_property_keys'); - late final _realm_get_property_keys = _realm_get_property_keysPtr.asFunction< - bool Function(ffi.Pointer, int, - ffi.Pointer, int, ffi.Pointer)>(); - - /// Get the schema for this realm. - /// - /// Note: The returned value is allocated by this function, so `realm_release()` - /// must be called on it. - ffi.Pointer realm_get_schema( - ffi.Pointer arg0, - ) { - return _realm_get_schema( - arg0, - ); - } - - late final _realm_get_schemaPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_get_schema'); - late final _realm_get_schema = _realm_get_schemaPtr - .asFunction Function(ffi.Pointer)>(); - - /// Get the schema version for this realm. - /// - /// This function cannot fail. - int realm_get_schema_version( - ffi.Pointer realm, - ) { - return _realm_get_schema_version( - realm, - ); - } - - late final _realm_get_schema_versionPtr = - _lookup)>>( - 'realm_get_schema_version'); - late final _realm_get_schema_version = _realm_get_schema_versionPtr - .asFunction)>(); - - /// Get a set instance for the property of an object. - /// - /// Note: It is up to the caller to call `realm_release()` on the returned set. - /// - /// @return A non-null pointer if no exception occurred. - ffi.Pointer realm_get_set( - ffi.Pointer arg0, - int arg1, - ) { - return _realm_get_set( - arg0, - arg1, - ); - } - - late final _realm_get_setPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - realm_property_key_t)>>('realm_get_set'); - late final _realm_get_set = _realm_get_setPtr.asFunction< - ffi.Pointer Function(ffi.Pointer, int)>(); - - /// Get the value for a property. - /// - /// @return True if no exception occurred. - bool realm_get_value( - ffi.Pointer arg0, - int arg1, - ffi.Pointer out_value, - ) { - return _realm_get_value( - arg0, - arg1, - out_value, - ); - } - - late final _realm_get_valuePtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, realm_property_key_t, - ffi.Pointer)>>('realm_get_value'); - late final _realm_get_value = _realm_get_valuePtr.asFunction< - bool Function( - ffi.Pointer, int, ffi.Pointer)>(); - - /// Get the value for the property at the specified index in the object's schema. - /// @param prop_index The index of the property in the class properties array the realm was opened with. - /// @return True if no exception occurred. - bool realm_get_value_by_property_index( - ffi.Pointer object, - int prop_index, - ffi.Pointer out_value, - ) { - return _realm_get_value_by_property_index( - object, - prop_index, - out_value, - ); - } - - late final _realm_get_value_by_property_indexPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, ffi.Size, - ffi.Pointer)>>( - 'realm_get_value_by_property_index'); - late final _realm_get_value_by_property_index = - _realm_get_value_by_property_indexPtr.asFunction< - bool Function( - ffi.Pointer, int, ffi.Pointer)>(); - - /// Get the values for several properties. - /// - /// This is provided as an alternative to calling `realm_get_value()` multiple - /// times in a row, which is particularly useful for language runtimes where - /// crossing the native bridge is comparatively expensive. In addition, it - /// eliminates some parameter validation that would otherwise be repeated for - /// each call. - /// - /// Example use cases: - /// - /// - Extracting all properties of an object for serialization. - /// - Converting an object to some in-memory representation. - /// - /// @param num_values The number of elements in @a properties and @a out_values. - /// @param properties The keys for the properties to fetch. May not be NULL. - /// @param out_values Where to write the property values. If an error occurs, - /// this array may only be partially initialized. May not be - /// NULL. - /// @return True if no exception occurs. - bool realm_get_values( - ffi.Pointer arg0, - int num_values, - ffi.Pointer properties, - ffi.Pointer out_values, - ) { - return _realm_get_values( - arg0, - num_values, - properties, - out_values, - ); - } - - late final _realm_get_valuesPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Size, - ffi.Pointer, - ffi.Pointer)>>('realm_get_values'); - late final _realm_get_values = _realm_get_valuesPtr.asFunction< - bool Function(ffi.Pointer, int, - ffi.Pointer, ffi.Pointer)>(); - - /// Get the VersionID of the current transaction. - /// - /// @param out_found True if version information is available. This requires an available Read or Write transaction. - /// @param out_version The version of the current transaction. If `out_found` returns False, this returns (0,0). - /// @return True if no exception occurred. - bool realm_get_version_id( - ffi.Pointer arg0, - ffi.Pointer out_found, - ffi.Pointer out_version, - ) { - return _realm_get_version_id( - arg0, - out_found, - out_version, - ); - } - - late final _realm_get_version_idPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>>('realm_get_version_id'); - late final _realm_get_version_id = _realm_get_version_idPtr.asFunction< - bool Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>(); - - /// Complete a HTTP request with the given response. - /// - /// @param request_context Internal state pointer passed by Core when invoking realm_http_request_func_t - /// to start the request. - /// @param response The server response to the HTTP request initiated by Core. - void realm_http_transport_complete_request( - ffi.Pointer request_context, - ffi.Pointer response, - ) { - return _realm_http_transport_complete_request( - request_context, - response, - ); - } - - late final _realm_http_transport_complete_requestPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, ffi.Pointer)>>( - 'realm_http_transport_complete_request'); - late final _realm_http_transport_complete_request = - _realm_http_transport_complete_requestPtr.asFunction< - void Function( - ffi.Pointer, ffi.Pointer)>(); - - /// Create a new HTTP transport with these callbacks implementing its functionality. - ffi.Pointer realm_http_transport_new( - realm_http_request_func_t arg0, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, - ) { - return _realm_http_transport_new( - arg0, - userdata, - userdata_free, - ); - } - - late final _realm_http_transport_newPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - realm_http_request_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>('realm_http_transport_new'); - late final _realm_http_transport_new = - _realm_http_transport_newPtr.asFunction< - ffi.Pointer Function( - realm_http_request_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); - - /// True if the Realm file is closed. - /// - /// This function cannot fail. - bool realm_is_closed( - ffi.Pointer arg0, - ) { - return _realm_is_closed( - arg0, - ); - } - - late final _realm_is_closedPtr = - _lookup)>>( - 'realm_is_closed'); - late final _realm_is_closed = - _realm_is_closedPtr.asFunction)>(); - - /// True if a Realm C Wrapper object is "frozen" (immutable). - /// - /// Objects, collections, and results can be frozen. For all other types, this - /// function always returns false. - bool realm_is_frozen( - ffi.Pointer arg0, - ) { - return _realm_is_frozen( - arg0, - ); - } - - late final _realm_is_frozenPtr = - _lookup)>>( - 'realm_is_frozen'); - late final _realm_is_frozen = - _realm_is_frozenPtr.asFunction)>(); - - /// Return true if the realm is in a write transaction. - /// - /// This function cannot fail. - bool realm_is_writable( - ffi.Pointer arg0, - ) { - return _realm_is_writable( - arg0, - ); - } - - late final _realm_is_writablePtr = - _lookup)>>( - 'realm_is_writable'); - late final _realm_is_writable = - _realm_is_writablePtr.asFunction)>(); - - /// Subscribe to notifications for this object. - /// - /// @return A non-null pointer if no exception occurred. - ffi.Pointer realm_list_add_notification_callback( - ffi.Pointer arg0, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, - ffi.Pointer key_path_array, - realm_on_collection_change_func_t on_change, - ) { - return _realm_list_add_notification_callback( - arg0, - userdata, - userdata_free, - key_path_array, - on_change, - ); - } - - late final _realm_list_add_notification_callbackPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - realm_free_userdata_func_t, - ffi.Pointer, - realm_on_collection_change_func_t)>>( - 'realm_list_add_notification_callback'); - late final _realm_list_add_notification_callback = - _realm_list_add_notification_callbackPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - realm_free_userdata_func_t, - ffi.Pointer, - realm_on_collection_change_func_t)>(); - - /// Clear a list, removing all elements in the list. In a list of links, this - /// does *NOT* delete the target objects. - /// - /// @return True if no exception occurred. - bool realm_list_clear( - ffi.Pointer arg0, - ) { - return _realm_list_clear( - arg0, - ); - } - - late final _realm_list_clearPtr = - _lookup)>>( - 'realm_list_clear'); - late final _realm_list_clear = _realm_list_clearPtr - .asFunction)>(); - - /// Erase the element at @a index. - /// - /// @return True if no exception occurred. - bool realm_list_erase( - ffi.Pointer arg0, - int index, - ) { - return _realm_list_erase( - arg0, - index, - ); - } - - late final _realm_list_erasePtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, ffi.Size)>>('realm_list_erase'); - late final _realm_list_erase = _realm_list_erasePtr - .asFunction, int)>(); - - /// Find the value in the list passed as parameter. - /// @param value to search in the list - /// @param out_index the index in the list where the value has been found or realm::not_found. - /// @param out_found boolean that indicates whether the value is found or not - /// @return true if no exception occurred. - bool realm_list_find( - ffi.Pointer arg0, - ffi.Pointer value, - ffi.Pointer out_index, - ffi.Pointer out_found, - ) { - return _realm_list_find( - arg0, - value, - out_index, - out_found, - ); - } - - late final _realm_list_findPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>>('realm_list_find'); - late final _realm_list_find = _realm_list_findPtr.asFunction< - bool Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer, ffi.Pointer)>(); - - /// Get an list from a thread-safe reference, potentially originating in a - /// different `realm_t` instance - ffi.Pointer realm_list_from_thread_safe_reference( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - return _realm_list_from_thread_safe_reference( - arg0, - arg1, - ); - } - - late final _realm_list_from_thread_safe_referencePtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer)>>( - 'realm_list_from_thread_safe_reference'); - late final _realm_list_from_thread_safe_reference = - _realm_list_from_thread_safe_referencePtr.asFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer)>(); - - /// Get the value at @a index. - /// - /// @param out_value The resulting value, if no error occurred. May be NULL, - /// though nonsensical. - /// @return True if no exception occurred. - bool realm_list_get( - ffi.Pointer arg0, - int index, - ffi.Pointer out_value, - ) { - return _realm_list_get( - arg0, - index, - out_value, - ); - } - - late final _realm_list_getPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, ffi.Size, - ffi.Pointer)>>('realm_list_get'); - late final _realm_list_get = _realm_list_getPtr.asFunction< - bool Function( - ffi.Pointer, int, ffi.Pointer)>(); + late final _realm_dart_get_device_versionPtr = + _lookup Function()>>( + 'realm_dart_get_device_version'); + late final _realm_dart_get_device_version = _realm_dart_get_device_versionPtr + .asFunction Function()>(); - /// Returns a nested dictionary if such collection exists, NULL otherwise. - /// - /// @param list pointer to the list that containes the nested collection into - /// @param index position of collection in the list - /// @return a pointer to the the nested dictionary found at index passed as argument - ffi.Pointer realm_list_get_dictionary( - ffi.Pointer list, - int index, - ) { - return _realm_list_get_dictionary( - list, - index, - ); + /// implemented for iOS and Android only + ffi.Pointer realm_dart_get_files_path() { + return _realm_dart_get_files_path(); } - late final _realm_list_get_dictionaryPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Size)>>('realm_list_get_dictionary'); - late final _realm_list_get_dictionary = - _realm_list_get_dictionaryPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, int)>(); + late final _realm_dart_get_files_pathPtr = + _lookup Function()>>( + 'realm_dart_get_files_path'); + late final _realm_dart_get_files_path = _realm_dart_get_files_pathPtr + .asFunction Function()>(); - /// Get object identified at index - /// - /// @return A non-NULL pointer if value is an object. - ffi.Pointer realm_list_get_linked_object( - ffi.Pointer arg0, - int index, - ) { - return _realm_list_get_linked_object( - arg0, - index, - ); + int realm_dart_get_thread_id() { + return _realm_dart_get_thread_id(); } - late final _realm_list_get_linked_objectPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Size)>>('realm_list_get_linked_object'); - late final _realm_list_get_linked_object = - _realm_list_get_linked_objectPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, int)>(); + late final _realm_dart_get_thread_idPtr = + _lookup>( + 'realm_dart_get_thread_id'); + late final _realm_dart_get_thread_id = + _realm_dart_get_thread_idPtr.asFunction(); - /// Returns a nested list if such collection exists, NULL otherwise. - /// - /// @param list pointer to the list that containes the nested list - /// @param index index of collection in the list - /// @return a pointer to the the nested list found at the index passed as argument - ffi.Pointer realm_list_get_list( - ffi.Pointer list, - int index, - ) { - return _realm_list_get_list( - list, - index, - ); + void realm_dart_init_debug_logger() { + return _realm_dart_init_debug_logger(); } - late final _realm_list_get_listPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, ffi.Size)>>('realm_list_get_list'); - late final _realm_list_get_list = _realm_list_get_listPtr.asFunction< - ffi.Pointer Function(ffi.Pointer, int)>(); + late final _realm_dart_init_debug_loggerPtr = + _lookup>( + 'realm_dart_init_debug_logger'); + late final _realm_dart_init_debug_logger = + _realm_dart_init_debug_loggerPtr.asFunction(); - /// Get the property that this list came from. - /// - /// @return True if no exception occurred. - bool realm_list_get_property( - ffi.Pointer arg0, - ffi.Pointer out_property_info, + void realm_dart_initializeDartApiDL( + ffi.Pointer data, ) { - return _realm_list_get_property( - arg0, - out_property_info, + return _realm_dart_initializeDartApiDL( + data, ); } - late final _realm_list_get_propertyPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, - ffi.Pointer)>>('realm_list_get_property'); - late final _realm_list_get_property = _realm_list_get_propertyPtr.asFunction< - bool Function( - ffi.Pointer, ffi.Pointer)>(); + late final _realm_dart_initializeDartApiDLPtr = + _lookup)>>( + 'realm_dart_initializeDartApiDL'); + late final _realm_dart_initializeDartApiDL = + _realm_dart_initializeDartApiDLPtr + .asFunction)>(); - /// Insert @a value at @a index. - /// - /// @param value The value to insert. - /// @return True if no exception occurred. - bool realm_list_insert( - ffi.Pointer arg0, - int index, - realm_value_t value, + void realm_dart_invoke_unlock_callback( + ffi.Pointer error, + ffi.Pointer unlockFunc, ) { - return _realm_list_insert( - arg0, - index, - value, + return _realm_dart_invoke_unlock_callback( + error, + unlockFunc, ); } - late final _realm_list_insertPtr = _lookup< + late final _realm_dart_invoke_unlock_callbackPtr = _lookup< ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, ffi.Size, - realm_value_t)>>('realm_list_insert'); - late final _realm_list_insert = _realm_list_insertPtr.asFunction< - bool Function(ffi.Pointer, int, realm_value_t)>(); + ffi.Void Function(ffi.Pointer, + ffi.Pointer)>>('realm_dart_invoke_unlock_callback'); + late final _realm_dart_invoke_unlock_callback = + _realm_dart_invoke_unlock_callbackPtr.asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); - ffi.Pointer realm_list_insert_dictionary( - ffi.Pointer list, - int index, - ) { - return _realm_list_insert_dictionary( - list, - index, - ); + ffi.Pointer realm_dart_library_version() { + return _realm_dart_library_version(); } - late final _realm_list_insert_dictionaryPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Size)>>('realm_list_insert_dictionary'); - late final _realm_list_insert_dictionary = - _realm_list_insert_dictionaryPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, int)>(); + late final _realm_dart_library_versionPtr = + _lookup Function()>>( + 'realm_dart_library_version'); + late final _realm_dart_library_version = _realm_dart_library_versionPtr + .asFunction Function()>(); - /// Insert an embedded object at a given position. - /// - /// @return A non-NULL pointer if the object was created successfully. - ffi.Pointer realm_list_insert_embedded( - ffi.Pointer arg0, - int index, + void realm_dart_log( + realm_log_level level, + ffi.Pointer category, + ffi.Pointer message, ) { - return _realm_list_insert_embedded( - arg0, - index, + return _realm_dart_log( + level.value, + category, + message, ); } - late final _realm_list_insert_embeddedPtr = _lookup< + late final _realm_dart_logPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Size)>>('realm_list_insert_embedded'); - late final _realm_list_insert_embedded = - _realm_list_insert_embeddedPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, int)>(); + ffi.Void Function(ffi.UnsignedInt, ffi.Pointer, + ffi.Pointer)>>('realm_dart_log'); + late final _realm_dart_log = _realm_dart_logPtr.asFunction< + void Function(int, ffi.Pointer, ffi.Pointer)>(); - /// Insert a collection inside a list (only available for mixed types) - /// - /// @param list valid ptr to a list of mixed - /// @param index position in the list where to add the collection - /// @return pointer to a valid collection that has been just inserted at the index passed as argument - ffi.Pointer realm_list_insert_list( - ffi.Pointer list, - int index, + ffi.Pointer realm_dart_object_to_persistent_handle( + Object handle, ) { - return _realm_list_insert_list( - list, - index, + return _realm_dart_object_to_persistent_handle( + handle, ); } - late final _realm_list_insert_listPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, ffi.Size)>>('realm_list_insert_list'); - late final _realm_list_insert_list = _realm_list_insert_listPtr.asFunction< - ffi.Pointer Function(ffi.Pointer, int)>(); + late final _realm_dart_object_to_persistent_handlePtr = + _lookup Function(ffi.Handle)>>( + 'realm_dart_object_to_persistent_handle'); + late final _realm_dart_object_to_persistent_handle = + _realm_dart_object_to_persistent_handlePtr + .asFunction Function(Object)>(); - /// Check if a list is valid. - /// - /// @return True if the list is valid. - bool realm_list_is_valid( - ffi.Pointer arg0, + Object realm_dart_persistent_handle_to_object( + ffi.Pointer handle, ) { - return _realm_list_is_valid( - arg0, + return _realm_dart_persistent_handle_to_object( + handle, ); } - late final _realm_list_is_validPtr = - _lookup)>>( - 'realm_list_is_valid'); - late final _realm_list_is_valid = _realm_list_is_validPtr - .asFunction)>(); + late final _realm_dart_persistent_handle_to_objectPtr = + _lookup)>>( + 'realm_dart_persistent_handle_to_object'); + late final _realm_dart_persistent_handle_to_object = + _realm_dart_persistent_handle_to_objectPtr + .asFunction)>(); - /// Move the element at @a from_index to @a to_index. - /// - /// @param from_index The index of the element to move. - /// @param to_index The index to move the element to. - /// @return True if no exception occurred. - bool realm_list_move( - ffi.Pointer arg0, - int from_index, - int to_index, + void realm_dart_scheduler_invoke( + int isolateId, + ffi.Pointer userData, ) { - return _realm_list_move( - arg0, - from_index, - to_index, + return _realm_dart_scheduler_invoke( + isolateId, + userData, ); } - late final _realm_list_movePtr = _lookup< + late final _realm_dart_scheduler_invokePtr = _lookup< ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, ffi.Size, - ffi.Size)>>('realm_list_move'); - late final _realm_list_move = _realm_list_movePtr - .asFunction, int, int)>(); + ffi.Void Function(ffi.Uint64, + ffi.Pointer)>>('realm_dart_scheduler_invoke'); + late final _realm_dart_scheduler_invoke = _realm_dart_scheduler_invokePtr + .asFunction)>(); - /// In a list of objects, delete all objects in the list and clear the list. In a - /// list of values, clear the list. - /// - /// @return True if no exception occurred. - bool realm_list_remove_all( - ffi.Pointer arg0, + /// implemented for iOS only (for now - valid for all posix) + /// /** + /// * Set the soft limit on number of open files + /// * @param limit The requested limit. If less than zero no attempt is made. + /// * @param[out] out_limit The actual limit set. + /// * + /// * @return true if no error occurred. + /// * + /// * @throws RLM_ERR_FILE_PERMISSION_DENIED if the operation was not permitted. + /// */ + bool realm_dart_set_and_get_rlimit( + int limit, + ffi.Pointer out_limit, ) { - return _realm_list_remove_all( - arg0, + return _realm_dart_set_and_get_rlimit( + limit, + out_limit, ); } - late final _realm_list_remove_allPtr = - _lookup)>>( - 'realm_list_remove_all'); - late final _realm_list_remove_all = _realm_list_remove_allPtr - .asFunction)>(); + late final _realm_dart_set_and_get_rlimitPtr = _lookup< + ffi + .NativeFunction)>>( + 'realm_dart_set_and_get_rlimit'); + late final _realm_dart_set_and_get_rlimit = _realm_dart_set_and_get_rlimitPtr + .asFunction)>(); - /// Resolve the list in the context of a given Realm instance. - /// - /// This is equivalent to producing a thread-safe reference and resolving it in the frozen realm. - /// - /// If resolution is possible, a valid resolved object is produced at '*resolved*'. - /// If resolution is not possible, but no error occurs, '*resolved' is set to NULL - /// - /// @return true if no error occurred. - bool realm_list_resolve_in( - ffi.Pointer list, - ffi.Pointer target_realm, - ffi.Pointer> resolved, + void realm_dart_userdata_async_free( + ffi.Pointer userdata, ) { - return _realm_list_resolve_in( - list, - target_realm, - resolved, + return _realm_dart_userdata_async_free( + userdata, ); } - late final _realm_list_resolve_inPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer>)>>( - 'realm_list_resolve_in'); - late final _realm_list_resolve_in = _realm_list_resolve_inPtr.asFunction< - bool Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer>)>(); + late final _realm_dart_userdata_async_freePtr = + _lookup)>>( + 'realm_dart_userdata_async_free'); + late final _realm_dart_userdata_async_free = + _realm_dart_userdata_async_freePtr + .asFunction)>(); - /// Set the value at @a index. - /// - /// @param value The value to set. - /// @return True if no exception occurred. - bool realm_list_set( - ffi.Pointer arg0, - int index, - realm_value_t value, + realm_dart_userdata_async_t realm_dart_userdata_async_new( + Object handle, + ffi.Pointer callback, + ffi.Pointer scheduler, ) { - return _realm_list_set( - arg0, - index, - value, + return _realm_dart_userdata_async_new( + handle, + callback, + scheduler, ); } - late final _realm_list_setPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, ffi.Size, - realm_value_t)>>('realm_list_set'); - late final _realm_list_set = _realm_list_setPtr.asFunction< - bool Function(ffi.Pointer, int, realm_value_t)>(); + late final _realm_dart_userdata_async_newPtr = _lookup< + ffi.NativeFunction< + realm_dart_userdata_async_t Function(ffi.Handle, + ffi.Pointer, ffi.Pointer)>>( + 'realm_dart_userdata_async_new'); + late final _realm_dart_userdata_async_new = + _realm_dart_userdata_async_newPtr.asFunction< + realm_dart_userdata_async_t Function( + Object, ffi.Pointer, ffi.Pointer)>(); - ffi.Pointer realm_list_set_dictionary( - ffi.Pointer list, - int index, + /// Deletes the following files for the given `realm_file_path` if they exist: + /// - the Realm file itself + /// - the .management folder + /// - the .note file + /// - the .log file + /// + /// The .lock file for this Realm cannot and will not be deleted as this is unsafe. + /// If a different process / thread is accessing the Realm at the same time a corrupt state + /// could be the result and checking for a single process state is not possible here. + /// + /// @param realm_file_path The path to the Realm file. All files will be derived from this. + /// @param[out] did_delete_realm If non-null, set to true if the primary Realm file was deleted. + /// Discard value if the function returns an error. + /// + /// @return true if no error occurred. + /// + /// @throws RLM_ERR_FILE_PERMISSION_DENIED if the operation was not permitted. + /// @throws RLM_ERR_FILE_ACCESS_ERROR for any other error while trying to delete the file or folder. + /// @throws RLM_ERR_DELETE_OPENED_REALM if the function was called on an open Realm. + bool realm_delete_files( + ffi.Pointer realm_file_path, + ffi.Pointer did_delete_realm, ) { - return _realm_list_set_dictionary( - list, - index, + return _realm_delete_files( + realm_file_path, + did_delete_realm, ); } - late final _realm_list_set_dictionaryPtr = _lookup< + late final _realm_delete_filesPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Size)>>('realm_list_set_dictionary'); - late final _realm_list_set_dictionary = - _realm_list_set_dictionaryPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, int)>(); + ffi.Bool Function(ffi.Pointer, + ffi.Pointer)>>('realm_delete_files'); + late final _realm_delete_files = _realm_delete_filesPtr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer)>(); - /// Create an embedded object at a given position. - /// - /// @return A non-NULL pointer if the object was created successfully. - ffi.Pointer realm_list_set_embedded( - ffi.Pointer arg0, - int index, + void realm_detach_finalizer( + ffi.Pointer finalizableHandle, + Object handle, ) { - return _realm_list_set_embedded( - arg0, - index, + return _realm_detach_finalizer( + finalizableHandle, + handle, ); } - late final _realm_list_set_embeddedPtr = _lookup< + late final _realm_detach_finalizerPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, ffi.Size)>>('realm_list_set_embedded'); - late final _realm_list_set_embedded = _realm_list_set_embeddedPtr.asFunction< - ffi.Pointer Function(ffi.Pointer, int)>(); + ffi.Void Function( + ffi.Pointer, ffi.Handle)>>('realm_detach_finalizer'); + late final _realm_detach_finalizer = _realm_detach_finalizerPtr + .asFunction, Object)>(); - /// Set a collection inside a list (only available for mixed types). - /// If the list already contains a collection of the requested type, the - /// operation is idempotent. + /// Subscribe to notifications for this object. /// - /// @param list valid ptr to a list where a nested collection needs to be set - /// @param index position in the list where to set the collection - /// @return a valid ptr representing the collection just set - ffi.Pointer realm_list_set_list( - ffi.Pointer list, - int index, + /// @return A non-null pointer if no exception occurred. + ffi.Pointer + realm_dictionary_add_notification_callback( + ffi.Pointer arg0, + ffi.Pointer userdata, + realm_free_userdata_func_t userdata_free, + ffi.Pointer key_path_array, + realm_on_dictionary_change_func_t on_change, ) { - return _realm_list_set_list( - list, - index, + return _realm_dictionary_add_notification_callback( + arg0, + userdata, + userdata_free, + key_path_array, + on_change, ); } - late final _realm_list_set_listPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, ffi.Size)>>('realm_list_set_list'); - late final _realm_list_set_list = _realm_list_set_listPtr.asFunction< - ffi.Pointer Function(ffi.Pointer, int)>(); + late final _realm_dictionary_add_notification_callbackPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + realm_free_userdata_func_t, + ffi.Pointer, + realm_on_dictionary_change_func_t)>>( + 'realm_dictionary_add_notification_callback'); + late final _realm_dictionary_add_notification_callback = + _realm_dictionary_add_notification_callbackPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + realm_free_userdata_func_t, + ffi.Pointer, + realm_on_dictionary_change_func_t)>(); - /// Get the size of a list, in number of elements. - /// - /// This function may fail if the object owning the list has been deleted. + /// Clear a dictionary. /// - /// @param out_size Where to put the list size. May be NULL. /// @return True if no exception occurred. - bool realm_list_size( - ffi.Pointer arg0, - ffi.Pointer out_size, + bool realm_dictionary_clear( + ffi.Pointer arg0, ) { - return _realm_list_size( + return _realm_dictionary_clear( arg0, - out_size, ); } - late final _realm_list_sizePtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, - ffi.Pointer)>>('realm_list_size'); - late final _realm_list_size = _realm_list_sizePtr.asFunction< - bool Function(ffi.Pointer, ffi.Pointer)>(); + late final _realm_dictionary_clearPtr = _lookup< + ffi + .NativeFunction)>>( + 'realm_dictionary_clear'); + late final _realm_dictionary_clear = _realm_dictionary_clearPtr + .asFunction)>(); - /// Convert a list to results. + /// Check if the dictionary contains a certain key /// - /// @return A non-null pointer if no exception occurred. - ffi.Pointer realm_list_to_results( - ffi.Pointer arg0, + /// @param key to search in the dictionary + /// @param found True if the such key exists + /// @return True if no exception occurred + bool realm_dictionary_contains_key( + ffi.Pointer arg0, + realm_value_t key, + ffi.Pointer found, ) { - return _realm_list_to_results( + return _realm_dictionary_contains_key( arg0, + key, + found, ); } - late final _realm_list_to_resultsPtr = _lookup< + late final _realm_dictionary_contains_keyPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_list_to_results'); - late final _realm_list_to_results = _realm_list_to_resultsPtr.asFunction< - ffi.Pointer Function(ffi.Pointer)>(); + ffi.Bool Function(ffi.Pointer, realm_value_t, + ffi.Pointer)>>('realm_dictionary_contains_key'); + late final _realm_dictionary_contains_key = + _realm_dictionary_contains_keyPtr.asFunction< + bool Function(ffi.Pointer, realm_value_t, + ffi.Pointer)>(); - /// Implement aggregate for mongodb collection - /// @param collection ptr to the collection to fetch from - /// @param filter_ejson extended json string serialization representing the filter to apply to this operation - /// @param data user data to pass down to this function - /// @param delete_data deleter for user data - /// @param callback to invoke with the result - /// @return True if completes successfully, False otherwise - bool realm_mongo_collection_aggregate( - ffi.Pointer collection, - realm_string_t filter_ejson, - ffi.Pointer data, - realm_free_userdata_func_t delete_data, - realm_mongodb_callback_t callback, + /// Check if the dictionary contains a certain value + /// + /// @param value to search in the dictionary + /// @param index the index of the value in the dictionry if such value exists + /// @return True if no exception occurred + bool realm_dictionary_contains_value( + ffi.Pointer arg0, + realm_value_t value, + ffi.Pointer index, ) { - return _realm_mongo_collection_aggregate( - collection, - filter_ejson, - data, - delete_data, - callback, + return _realm_dictionary_contains_value( + arg0, + value, + index, ); } - late final _realm_mongo_collection_aggregatePtr = _lookup< + late final _realm_dictionary_contains_valuePtr = _lookup< ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - realm_string_t, - ffi.Pointer, - realm_free_userdata_func_t, - realm_mongodb_callback_t)>>('realm_mongo_collection_aggregate'); - late final _realm_mongo_collection_aggregate = - _realm_mongo_collection_aggregatePtr.asFunction< - bool Function( - ffi.Pointer, - realm_string_t, - ffi.Pointer, - realm_free_userdata_func_t, - realm_mongodb_callback_t)>(); - - /// Implement count for mongodb collection - /// @param collection ptr to the collection to fetch from - /// @param filter_ejson extended json string serialization representing the filter to apply to this operation - /// @param limit number of collectio - /// @param data user data to pass down to this function - /// @param delete_data deleter for user data - /// @param callback to invoke with the result - /// @return True if completes successfully, False otherwise - bool realm_mongo_collection_count( - ffi.Pointer collection, - realm_string_t filter_ejson, - int limit, - ffi.Pointer data, - realm_free_userdata_func_t delete_data, - realm_mongodb_callback_t callback, - ) { - return _realm_mongo_collection_count( - collection, - filter_ejson, - limit, - data, - delete_data, - callback, - ); - } + ffi.Bool Function(ffi.Pointer, realm_value_t, + ffi.Pointer)>>('realm_dictionary_contains_value'); + late final _realm_dictionary_contains_value = + _realm_dictionary_contains_valuePtr.asFunction< + bool Function(ffi.Pointer, realm_value_t, + ffi.Pointer)>(); - late final _realm_mongo_collection_countPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - realm_string_t, - ffi.Int64, - ffi.Pointer, - realm_free_userdata_func_t, - realm_mongodb_callback_t)>>('realm_mongo_collection_count'); - late final _realm_mongo_collection_count = - _realm_mongo_collection_countPtr.asFunction< - bool Function( - ffi.Pointer, - realm_string_t, - int, - ffi.Pointer, - realm_free_userdata_func_t, - realm_mongodb_callback_t)>(); - - /// Implement delete_many for mongodb collection - /// @param collection name of the collection to fetch from - /// @param filter_ejson extended json string serialization representing the filter to apply to this operation - /// @param data user data to pass down to this function - /// @param delete_data deleter for user data - /// @param callback to invoke with the result - bool realm_mongo_collection_delete_many( - ffi.Pointer collection, - realm_string_t filter_ejson, - ffi.Pointer data, - realm_free_userdata_func_t delete_data, - realm_mongodb_callback_t callback, + /// Erase a dictionary element. + /// + /// @param key The key of the element to erase. + /// @param out_erased If non-null, will be set to true if the element was found + /// and erased. + /// @return True if no exception occurred. + bool realm_dictionary_erase( + ffi.Pointer arg0, + realm_value_t key, + ffi.Pointer out_erased, ) { - return _realm_mongo_collection_delete_many( - collection, - filter_ejson, - data, - delete_data, - callback, + return _realm_dictionary_erase( + arg0, + key, + out_erased, ); } - late final _realm_mongo_collection_delete_manyPtr = _lookup< + late final _realm_dictionary_erasePtr = _lookup< ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - realm_string_t, - ffi.Pointer, - realm_free_userdata_func_t, - realm_mongodb_callback_t)>>('realm_mongo_collection_delete_many'); - late final _realm_mongo_collection_delete_many = - _realm_mongo_collection_delete_manyPtr.asFunction< - bool Function( - ffi.Pointer, - realm_string_t, - ffi.Pointer, - realm_free_userdata_func_t, - realm_mongodb_callback_t)>(); - - /// Implement delete_one for mongodb collection - /// @param collection name of the collection to fetch from - /// @param filter_ejson extended json string serialization representing the filter to apply to this operation - /// @param data user data to pass down to this function - /// @param delete_data deleter for user data - /// @param callback to invoke with the result - /// @return True if completes successfully, False otherwise - bool realm_mongo_collection_delete_one( - ffi.Pointer collection, - realm_string_t filter_ejson, - ffi.Pointer data, - realm_free_userdata_func_t delete_data, - realm_mongodb_callback_t callback, - ) { - return _realm_mongo_collection_delete_one( - collection, - filter_ejson, - data, - delete_data, - callback, - ); - } + ffi.Bool Function(ffi.Pointer, realm_value_t, + ffi.Pointer)>>('realm_dictionary_erase'); + late final _realm_dictionary_erase = _realm_dictionary_erasePtr.asFunction< + bool Function(ffi.Pointer, realm_value_t, + ffi.Pointer)>(); - late final _realm_mongo_collection_delete_onePtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - realm_string_t, - ffi.Pointer, - realm_free_userdata_func_t, - realm_mongodb_callback_t)>>('realm_mongo_collection_delete_one'); - late final _realm_mongo_collection_delete_one = - _realm_mongo_collection_delete_onePtr.asFunction< - bool Function( - ffi.Pointer, - realm_string_t, - ffi.Pointer, - realm_free_userdata_func_t, - realm_mongodb_callback_t)>(); - - /// Implement find for mongodb collection - /// @param collection ptr to the collection to fetch from - /// @param filter_ejson extended json string serialization representing the filter to apply to this operation - /// @param options set of possible options to apply to this operation - /// @param data user data to pass down to this function - /// @param delete_data deleter for user data - /// @param callback to invoke with the result - /// @return True if completes successfully, False otherwise - bool realm_mongo_collection_find( - ffi.Pointer collection, - realm_string_t filter_ejson, - ffi.Pointer options, - ffi.Pointer data, - realm_free_userdata_func_t delete_data, - realm_mongodb_callback_t callback, + /// Find an element in a dictionary. + /// + /// @param key The key to look for. + /// @param out_value If non-null, the value for the corresponding key. + /// @param out_found If non-null, will be set to true if the dictionary contained the key. + /// @return True if no exception occurred. + bool realm_dictionary_find( + ffi.Pointer arg0, + realm_value_t key, + ffi.Pointer out_value, + ffi.Pointer out_found, ) { - return _realm_mongo_collection_find( - collection, - filter_ejson, - options, - data, - delete_data, - callback, + return _realm_dictionary_find( + arg0, + key, + out_value, + out_found, ); } - late final _realm_mongo_collection_findPtr = _lookup< + late final _realm_dictionary_findPtr = _lookup< ffi.NativeFunction< ffi.Bool Function( - ffi.Pointer, - realm_string_t, - ffi.Pointer, - ffi.Pointer, - realm_free_userdata_func_t, - realm_mongodb_callback_t)>>('realm_mongo_collection_find'); - late final _realm_mongo_collection_find = - _realm_mongo_collection_findPtr.asFunction< - bool Function( - ffi.Pointer, - realm_string_t, - ffi.Pointer, - ffi.Pointer, - realm_free_userdata_func_t, - realm_mongodb_callback_t)>(); - - /// Implement find_one for mongodb collection - /// @param collection ptr to the collection to fetch from - /// @param filter_ejson extended json string serialization representing the filter to apply to this operation - /// @param options set of possible options to apply to this operation - /// @param data user data to pass down to this function - /// @param delete_data deleter for user data - /// @param callback to invoke with the result - /// @return True if completes successfully, False otherwise - bool realm_mongo_collection_find_one( - ffi.Pointer collection, - realm_string_t filter_ejson, - ffi.Pointer options, - ffi.Pointer data, - realm_free_userdata_func_t delete_data, - realm_mongodb_callback_t callback, - ) { - return _realm_mongo_collection_find_one( - collection, - filter_ejson, - options, - data, - delete_data, - callback, - ); - } + ffi.Pointer, + realm_value_t, + ffi.Pointer, + ffi.Pointer)>>('realm_dictionary_find'); + late final _realm_dictionary_find = _realm_dictionary_findPtr.asFunction< + bool Function(ffi.Pointer, realm_value_t, + ffi.Pointer, ffi.Pointer)>(); - late final _realm_mongo_collection_find_onePtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - realm_string_t, - ffi.Pointer, - ffi.Pointer, - realm_free_userdata_func_t, - realm_mongodb_callback_t)>>('realm_mongo_collection_find_one'); - late final _realm_mongo_collection_find_one = - _realm_mongo_collection_find_onePtr.asFunction< - bool Function( - ffi.Pointer, - realm_string_t, - ffi.Pointer, - ffi.Pointer, - realm_free_userdata_func_t, - realm_mongodb_callback_t)>(); - - /// Implement find_one and delete for mongodb collection - /// @param collection name of the collection to fetch from - /// @param filter_ejson extended json string serialization representing the filter to apply to this operation - /// @param options set of possible options to apply to this operation - /// @param data user data to pass down to this function - /// @param delete_data deleter for user data - /// @param callback to invoke with the result - /// @return True if completes successfully, False otherwise - bool realm_mongo_collection_find_one_and_delete( - ffi.Pointer collection, - realm_string_t filter_ejson, - ffi.Pointer options, - ffi.Pointer data, - realm_free_userdata_func_t delete_data, - realm_mongodb_callback_t callback, + /// Get an dictionary from a thread-safe reference, potentially originating in a + /// different `realm_t` instance + ffi.Pointer realm_dictionary_from_thread_safe_reference( + ffi.Pointer arg0, + ffi.Pointer arg1, ) { - return _realm_mongo_collection_find_one_and_delete( - collection, - filter_ejson, - options, - data, - delete_data, - callback, + return _realm_dictionary_from_thread_safe_reference( + arg0, + arg1, ); } - late final _realm_mongo_collection_find_one_and_deletePtr = _lookup< + late final _realm_dictionary_from_thread_safe_referencePtr = _lookup< ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - realm_string_t, - ffi.Pointer, - ffi.Pointer, - realm_free_userdata_func_t, - realm_mongodb_callback_t)>>( - 'realm_mongo_collection_find_one_and_delete'); - late final _realm_mongo_collection_find_one_and_delete = - _realm_mongo_collection_find_one_and_deletePtr.asFunction< - bool Function( - ffi.Pointer, - realm_string_t, - ffi.Pointer, - ffi.Pointer, - realm_free_userdata_func_t, - realm_mongodb_callback_t)>(); - - /// Implement find_one and replace for mongodb collection - /// @param collection name of the collection to fetch from - /// @param filter_ejson extended json string serialization representing the filter to apply to this operation - /// @param replacement_ejson extended json string serialization representing the replacement object to apply to this - /// operation - /// @param options set of possible options to apply to this operation - /// @param data user data to pass down to this function - /// @param delete_data deleter for user data - /// @param callback to invoke with the result - /// @return True if completes successfully, False otherwise - bool realm_mongo_collection_find_one_and_replace( - ffi.Pointer collection, - realm_string_t filter_ejson, - realm_string_t replacement_ejson, - ffi.Pointer options, - ffi.Pointer data, - realm_free_userdata_func_t delete_data, - realm_mongodb_callback_t callback, - ) { - return _realm_mongo_collection_find_one_and_replace( - collection, - filter_ejson, - replacement_ejson, - options, - data, - delete_data, - callback, - ); - } + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer)>>( + 'realm_dictionary_from_thread_safe_reference'); + late final _realm_dictionary_from_thread_safe_reference = + _realm_dictionary_from_thread_safe_referencePtr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer)>(); - late final _realm_mongo_collection_find_one_and_replacePtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - realm_string_t, - realm_string_t, - ffi.Pointer, - ffi.Pointer, - realm_free_userdata_func_t, - realm_mongodb_callback_t)>>( - 'realm_mongo_collection_find_one_and_replace'); - late final _realm_mongo_collection_find_one_and_replace = - _realm_mongo_collection_find_one_and_replacePtr.asFunction< - bool Function( - ffi.Pointer, - realm_string_t, - realm_string_t, - ffi.Pointer, - ffi.Pointer, - realm_free_userdata_func_t, - realm_mongodb_callback_t)>(); - - /// Implement find one and update for mongodb collection - /// @param collection name of the collection to fetch from - /// @param filter_ejson extended json string serialization representing the filter to apply to this operation - /// @param update_ejson extended json string serialization representing the update to apply to this operation - /// @param options set of possible options to apply to this operation - /// @param data user data to pass down to this function - /// @param delete_data deleter for user data - /// @param callback to invoke with the result - /// @return True if completes successfully, False otherwise - bool realm_mongo_collection_find_one_and_update( - ffi.Pointer collection, - realm_string_t filter_ejson, - realm_string_t update_ejson, - ffi.Pointer options, - ffi.Pointer data, - realm_free_userdata_func_t delete_data, - realm_mongodb_callback_t callback, - ) { - return _realm_mongo_collection_find_one_and_update( - collection, - filter_ejson, - update_ejson, - options, - data, - delete_data, - callback, + /// Get the key-value pair at @a index. + /// + /// Note that the indices of elements in the dictionary move around as other + /// elements are inserted/removed. + /// + /// @param index The index in the dictionary. + /// @param out_key If non-null, will be set to the key at the corresponding index. + /// @param out_value If non-null, will be set to the value at the corresponding index. + /// @return True if no exception occurred. + bool realm_dictionary_get( + ffi.Pointer arg0, + int index, + ffi.Pointer out_key, + ffi.Pointer out_value, + ) { + return _realm_dictionary_get( + arg0, + index, + out_key, + out_value, ); } - late final _realm_mongo_collection_find_one_and_updatePtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - realm_string_t, - realm_string_t, - ffi.Pointer, - ffi.Pointer, - realm_free_userdata_func_t, - realm_mongodb_callback_t)>>( - 'realm_mongo_collection_find_one_and_update'); - late final _realm_mongo_collection_find_one_and_update = - _realm_mongo_collection_find_one_and_updatePtr.asFunction< - bool Function( - ffi.Pointer, - realm_string_t, - realm_string_t, - ffi.Pointer, - ffi.Pointer, - realm_free_userdata_func_t, - realm_mongodb_callback_t)>(); + late final _realm_dictionary_getPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + ffi.Size, + ffi.Pointer, + ffi.Pointer)>>('realm_dictionary_get'); + late final _realm_dictionary_get = _realm_dictionary_getPtr.asFunction< + bool Function(ffi.Pointer, int, + ffi.Pointer, ffi.Pointer)>(); - /// Get mongo db collection from realm mongo db client - /// @param user ptr to the sync realm user of which we want to retrieve the remote collection for - /// @param service name of the service where the collection will be found - /// @param database name of the database where the collection will be found - /// @param collection name of the collection to fetch - /// @return a ptr to a valid mongodb collection if such collection exists, nullptr otherwise - ffi.Pointer realm_mongo_collection_get( - ffi.Pointer user, - ffi.Pointer service, - ffi.Pointer database, - ffi.Pointer collection, + /// Returns the list of keys changed for the dictionary passed as argument. + /// The user must assure that there is enough memory to accomodate all the keys + /// calling `realm_dictionary_get_changes` before. + /// + /// @param changes valid ptr to the dictionary changes structure + /// @param deletions list of deleted keys + /// @param deletions_size size of the list of deleted keys + /// @param insertions list of inserted keys + /// @param insertions_size size of the list of inserted keys + /// @param modifications list of modified keys + /// @param modification_size size of the list of modified keys + /// @param collection_was_cleared whether or not the collection was cleared + void realm_dictionary_get_changed_keys( + ffi.Pointer changes, + ffi.Pointer deletions, + ffi.Pointer deletions_size, + ffi.Pointer insertions, + ffi.Pointer insertions_size, + ffi.Pointer modifications, + ffi.Pointer modification_size, + ffi.Pointer collection_was_cleared, ) { - return _realm_mongo_collection_get( - user, - service, - database, - collection, + return _realm_dictionary_get_changed_keys( + changes, + deletions, + deletions_size, + insertions, + insertions_size, + modifications, + modification_size, + collection_was_cleared, ); } - late final _realm_mongo_collection_getPtr = _lookup< + late final _realm_dictionary_get_changed_keysPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>>('realm_mongo_collection_get'); - late final _realm_mongo_collection_get = - _realm_mongo_collection_getPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>(); + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('realm_dictionary_get_changed_keys'); + late final _realm_dictionary_get_changed_keys = + _realm_dictionary_get_changed_keysPtr.asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); - /// Implement insert_many for mongodb collection - /// @param collection name of the collection to fetch from - /// @param filter_ejson extended json string serialization representing the filter to apply to this operation - /// @param data user data to pass down to this function - /// @param delete_data deleter for user data - /// @param callback to invoke with the result - /// @return True if completes successfully, False otherwise - bool realm_mongo_collection_insert_many( - ffi.Pointer collection, - realm_string_t filter_ejson, - ffi.Pointer data, - realm_free_userdata_func_t delete_data, - realm_mongodb_callback_t callback, + /// Returns the number of changes occurred to the dictionary passed as argument + /// + /// @param changes valid ptr to the dictionary changes structure + /// @param out_deletions_size number of deletions + /// @param out_insertion_size number of insertions + /// @param out_modification_size number of modifications + /// @param out_was_deleted a flag to signal if the dictionary has been deleted. + void realm_dictionary_get_changes( + ffi.Pointer changes, + ffi.Pointer out_deletions_size, + ffi.Pointer out_insertion_size, + ffi.Pointer out_modification_size, + ffi.Pointer out_was_deleted, ) { - return _realm_mongo_collection_insert_many( - collection, - filter_ejson, - data, - delete_data, - callback, + return _realm_dictionary_get_changes( + changes, + out_deletions_size, + out_insertion_size, + out_modification_size, + out_was_deleted, ); } - late final _realm_mongo_collection_insert_manyPtr = _lookup< + late final _realm_dictionary_get_changesPtr = _lookup< ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - realm_string_t, - ffi.Pointer, - realm_free_userdata_func_t, - realm_mongodb_callback_t)>>('realm_mongo_collection_insert_many'); - late final _realm_mongo_collection_insert_many = - _realm_mongo_collection_insert_manyPtr.asFunction< - bool Function( - ffi.Pointer, - realm_string_t, - ffi.Pointer, - realm_free_userdata_func_t, - realm_mongodb_callback_t)>(); - - /// Implement insert_one for mongodb collection - /// @param collection name of the collection to fetch from - /// @param filter_ejson extended json string serialization representing the filter to apply to this operation - /// @param data user data to pass down to this function - /// @param delete_data deleter for user data - /// @param callback to invoke with the result - /// @return True if completes successfully, False otherwise - bool realm_mongo_collection_insert_one( - ffi.Pointer collection, - realm_string_t filter_ejson, - ffi.Pointer data, - realm_free_userdata_func_t delete_data, - realm_mongodb_callback_t callback, + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('realm_dictionary_get_changes'); + late final _realm_dictionary_get_changes = + _realm_dictionary_get_changesPtr.asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + /// Fetch a dictioanry from a dictionary. + /// @return a valid dictionary that needs to be deleted by the caller or nullptr in case of an error. + ffi.Pointer realm_dictionary_get_dictionary( + ffi.Pointer dictionary, + realm_value_t key, ) { - return _realm_mongo_collection_insert_one( - collection, - filter_ejson, - data, - delete_data, - callback, + return _realm_dictionary_get_dictionary( + dictionary, + key, ); } - late final _realm_mongo_collection_insert_onePtr = _lookup< + late final _realm_dictionary_get_dictionaryPtr = _lookup< ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - realm_string_t, - ffi.Pointer, - realm_free_userdata_func_t, - realm_mongodb_callback_t)>>('realm_mongo_collection_insert_one'); - late final _realm_mongo_collection_insert_one = - _realm_mongo_collection_insert_onePtr.asFunction< - bool Function( - ffi.Pointer, - realm_string_t, - ffi.Pointer, - realm_free_userdata_func_t, - realm_mongodb_callback_t)>(); - - /// Implement update_many for mongodb collection - /// @param collection name of the collection to fetch from - /// @param filter_ejson extended json string serialization representing the filter to apply to this operation - /// @param update_ejson extended json string serialization representing the update to apply to this operation - /// @param upsert boolean flag to set for enable or disable upsert for the collection - /// @param data user data to pass down to this function - /// @param delete_data deleter for user data - /// @param callback to invoke with the result - /// @return True if completes successfully, False otherwise - bool realm_mongo_collection_update_many( - ffi.Pointer collection, - realm_string_t filter_ejson, - realm_string_t update_ejson, - bool upsert, - ffi.Pointer data, - realm_free_userdata_func_t delete_data, - realm_mongodb_callback_t callback, - ) { - return _realm_mongo_collection_update_many( - collection, - filter_ejson, - update_ejson, - upsert, - data, - delete_data, - callback, + ffi.Pointer Function( + ffi.Pointer, + realm_value_t)>>('realm_dictionary_get_dictionary'); + late final _realm_dictionary_get_dictionary = + _realm_dictionary_get_dictionaryPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, realm_value_t)>(); + + /// Return the list of keys stored in the dictionary + /// + /// @param out_size number of keys + /// @param out_keys the list of keys in the dictionary, the memory has to be released once it is no longer used. + /// @return True if no exception occurred. + bool realm_dictionary_get_keys( + ffi.Pointer arg0, + ffi.Pointer out_size, + ffi.Pointer> out_keys, + ) { + return _realm_dictionary_get_keys( + arg0, + out_size, + out_keys, ); } - late final _realm_mongo_collection_update_manyPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - realm_string_t, - realm_string_t, - ffi.Bool, - ffi.Pointer, - realm_free_userdata_func_t, - realm_mongodb_callback_t)>>('realm_mongo_collection_update_many'); - late final _realm_mongo_collection_update_many = - _realm_mongo_collection_update_manyPtr.asFunction< - bool Function( - ffi.Pointer, - realm_string_t, - realm_string_t, - bool, - ffi.Pointer, - realm_free_userdata_func_t, - realm_mongodb_callback_t)>(); - - /// Implement update_one for mongodb collection - /// @param collection name of the collection to fetch from - /// @param filter_ejson extended json string serialization representing the filter to apply to this operation - /// @param update_ejson extended json string serialization representing the update to apply to this operation - /// @param upsert boolean flag to set for enable or disable upsert for the collection - /// @param data user data to pass down to this function - /// @param delete_data deleter for user data - /// @param callback to invoke with the result - /// @return True if completes successfully, False otherwise - bool realm_mongo_collection_update_one( - ffi.Pointer collection, - realm_string_t filter_ejson, - realm_string_t update_ejson, - bool upsert, - ffi.Pointer data, - realm_free_userdata_func_t delete_data, - realm_mongodb_callback_t callback, - ) { - return _realm_mongo_collection_update_one( - collection, - filter_ejson, - update_ejson, - upsert, - data, - delete_data, - callback, + late final _realm_dictionary_get_keysPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>>( + 'realm_dictionary_get_keys'); + late final _realm_dictionary_get_keys = + _realm_dictionary_get_keysPtr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer>)>(); + + /// Get object identified by key + /// + /// @return A non-NULL pointer if the value associated with key is an object. + ffi.Pointer realm_dictionary_get_linked_object( + ffi.Pointer arg0, + realm_value_t key, + ) { + return _realm_dictionary_get_linked_object( + arg0, + key, ); } - late final _realm_mongo_collection_update_onePtr = _lookup< + late final _realm_dictionary_get_linked_objectPtr = _lookup< ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - realm_string_t, - realm_string_t, - ffi.Bool, - ffi.Pointer, - realm_free_userdata_func_t, - realm_mongodb_callback_t)>>('realm_mongo_collection_update_one'); - late final _realm_mongo_collection_update_one = - _realm_mongo_collection_update_onePtr.asFunction< - bool Function( - ffi.Pointer, - realm_string_t, - realm_string_t, - bool, - ffi.Pointer, - realm_free_userdata_func_t, - realm_mongodb_callback_t)>(); + ffi.Pointer Function(ffi.Pointer, + realm_value_t)>>('realm_dictionary_get_linked_object'); + late final _realm_dictionary_get_linked_object = + _realm_dictionary_get_linked_objectPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, realm_value_t)>(); - /// Increment atomically property specified as parameter by value, for the object passed as argument. - /// @param object valid ptr to an object store in the database - /// @param property_key id of the property to change - /// @param value increment for the property passed as argument - /// @return True if not exception occurred. - bool realm_object_add_int( - ffi.Pointer object, - int property_key, - int value, + /// Fetch a list from a dictionary. + /// @return a valid list that needs to be deleted by the caller or nullptr in case of an error. + ffi.Pointer realm_dictionary_get_list( + ffi.Pointer dictionary, + realm_value_t key, ) { - return _realm_object_add_int( - object, - property_key, - value, + return _realm_dictionary_get_list( + dictionary, + key, ); } - late final _realm_object_add_intPtr = _lookup< + late final _realm_dictionary_get_listPtr = _lookup< ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, realm_property_key_t, - ffi.Int64)>>('realm_object_add_int'); - late final _realm_object_add_int = _realm_object_add_intPtr - .asFunction, int, int)>(); + ffi.Pointer Function(ffi.Pointer, + realm_value_t)>>('realm_dictionary_get_list'); + late final _realm_dictionary_get_list = + _realm_dictionary_get_listPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, realm_value_t)>(); - /// Subscribe to notifications for this object. + /// Get the property that this dictionary came from. /// - /// @return A non-null pointer if no exception occurred. - ffi.Pointer - realm_object_add_notification_callback( - ffi.Pointer arg0, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, - ffi.Pointer key_path_array, - realm_on_object_change_func_t on_change, + /// @return True if no exception occurred. + bool realm_dictionary_get_property( + ffi.Pointer arg0, + ffi.Pointer out_info, ) { - return _realm_object_add_notification_callback( + return _realm_dictionary_get_property( arg0, - userdata, - userdata_free, - key_path_array, - on_change, + out_info, ); } - late final _realm_object_add_notification_callbackPtr = _lookup< + late final _realm_dictionary_get_propertyPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - realm_free_userdata_func_t, - ffi.Pointer, - realm_on_object_change_func_t)>>( - 'realm_object_add_notification_callback'); - late final _realm_object_add_notification_callback = - _realm_object_add_notification_callbackPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - realm_free_userdata_func_t, - ffi.Pointer, - realm_on_object_change_func_t)>(); + ffi.Bool Function(ffi.Pointer, + ffi.Pointer)>>( + 'realm_dictionary_get_property'); + late final _realm_dictionary_get_property = + _realm_dictionary_get_propertyPtr.asFunction< + bool Function(ffi.Pointer, + ffi.Pointer)>(); - /// Get a `realm_link_t` representing a link to @a object. + /// Insert or update an element in a dictionary. /// - /// This function cannot fail. - realm_link_t realm_object_as_link( - ffi.Pointer object, + /// If the key already exists, the value will be overwritten. + /// + /// @param key The lookup key. + /// @param value The value to insert. + /// @param out_index If non-null, will be set to the index of the element after + /// insertion/update. + /// @param out_inserted If non-null, will be set to true if the key did not + /// already exist. + /// @return True if no exception occurred. + bool realm_dictionary_insert( + ffi.Pointer arg0, + realm_value_t key, + realm_value_t value, + ffi.Pointer out_index, + ffi.Pointer out_inserted, ) { - return _realm_object_as_link( - object, + return _realm_dictionary_insert( + arg0, + key, + value, + out_index, + out_inserted, ); } - late final _realm_object_as_linkPtr = _lookup< - ffi - .NativeFunction)>>( - 'realm_object_as_link'); - late final _realm_object_as_link = _realm_object_as_linkPtr - .asFunction)>(); + late final _realm_dictionary_insertPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + realm_value_t, + realm_value_t, + ffi.Pointer, + ffi.Pointer)>>('realm_dictionary_insert'); + late final _realm_dictionary_insert = _realm_dictionary_insertPtr.asFunction< + bool Function(ffi.Pointer, realm_value_t, + realm_value_t, ffi.Pointer, ffi.Pointer)>(); - /// Get the column keys for the properties that were modified in an object - /// notification. - /// - /// This function cannot fail. - /// - /// @param out_modified Where the column keys should be written. May be NULL. - /// @param max The maximum number of column keys to write. - /// @return The number of column keys written to @a out_modified, or the number - /// of modified properties if @a out_modified is NULL. - int realm_object_changes_get_modified_properties( - ffi.Pointer arg0, - ffi.Pointer out_modified, - int max, + ffi.Pointer realm_dictionary_insert_dictionary( + ffi.Pointer arg0, + realm_value_t arg1, ) { - return _realm_object_changes_get_modified_properties( + return _realm_dictionary_insert_dictionary( arg0, - out_modified, - max, + arg1, ); } - late final _realm_object_changes_get_modified_propertiesPtr = _lookup< + late final _realm_dictionary_insert_dictionaryPtr = _lookup< ffi.NativeFunction< - ffi.Size Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size)>>('realm_object_changes_get_modified_properties'); - late final _realm_object_changes_get_modified_properties = - _realm_object_changes_get_modified_propertiesPtr.asFunction< - int Function(ffi.Pointer, - ffi.Pointer, int)>(); + ffi.Pointer Function( + ffi.Pointer, + realm_value_t)>>('realm_dictionary_insert_dictionary'); + late final _realm_dictionary_insert_dictionary = + _realm_dictionary_insert_dictionaryPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, realm_value_t)>(); - /// Get the number of properties that were modified in an object notification. + /// Insert an embedded object. /// - /// This function cannot fail. - int realm_object_changes_get_num_modified_properties( - ffi.Pointer arg0, + /// @return A non-NULL pointer if the object was created successfully. + ffi.Pointer realm_dictionary_insert_embedded( + ffi.Pointer arg0, + realm_value_t key, ) { - return _realm_object_changes_get_num_modified_properties( + return _realm_dictionary_insert_embedded( arg0, + key, ); } - late final _realm_object_changes_get_num_modified_propertiesPtr = _lookup< - ffi.NativeFunction< - ffi.Size Function(ffi.Pointer)>>( - 'realm_object_changes_get_num_modified_properties'); - late final _realm_object_changes_get_num_modified_properties = - _realm_object_changes_get_num_modified_propertiesPtr - .asFunction)>(); + late final _realm_dictionary_insert_embeddedPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + realm_value_t)>>('realm_dictionary_insert_embedded'); + late final _realm_dictionary_insert_embedded = + _realm_dictionary_insert_embeddedPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, realm_value_t)>(); + + /// Insert a collection inside a dictionary (only available for mixed types) + /// + /// @param dictionary valid ptr to a dictionary of mixed + /// @param key the mixed representing a key for a dictionary (only string) + /// @return pointer to a valid collection that has been just inserted at the key passed as argument + ffi.Pointer realm_dictionary_insert_list( + ffi.Pointer dictionary, + realm_value_t key, + ) { + return _realm_dictionary_insert_list( + dictionary, + key, + ); + } + + late final _realm_dictionary_insert_listPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + realm_value_t)>>('realm_dictionary_insert_list'); + late final _realm_dictionary_insert_list = + _realm_dictionary_insert_listPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, realm_value_t)>(); - /// True if an object notification indicates that the object was deleted. + /// Check if a list is valid. /// - /// This function cannot fail. - bool realm_object_changes_is_deleted( - ffi.Pointer arg0, + /// @return True if the list is valid. + bool realm_dictionary_is_valid( + ffi.Pointer arg0, ) { - return _realm_object_changes_is_deleted( + return _realm_dictionary_is_valid( arg0, ); } - late final _realm_object_changes_is_deletedPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer)>>( - 'realm_object_changes_is_deleted'); - late final _realm_object_changes_is_deleted = - _realm_object_changes_is_deletedPtr - .asFunction)>(); + late final _realm_dictionary_is_validPtr = _lookup< + ffi + .NativeFunction)>>( + 'realm_dictionary_is_valid'); + late final _realm_dictionary_is_valid = _realm_dictionary_is_validPtr + .asFunction)>(); - /// Create an object in a class without a primary key. + /// Resolve the list in the context of a given Realm instance. /// - /// @return A non-NULL pointer if the object was created successfully. - ffi.Pointer realm_object_create( - ffi.Pointer arg0, - int arg1, + /// This is equivalent to producing a thread-safe reference and resolving it in the frozen realm. + /// + /// If resolution is possible, a valid resolved object is produced at '*resolved*'. + /// If resolution is not possible, but no error occurs, '*resolved' is set to NULL + /// + /// @return true if no error occurred. + bool realm_dictionary_resolve_in( + ffi.Pointer list, + ffi.Pointer target_realm, + ffi.Pointer> resolved, ) { - return _realm_object_create( - arg0, - arg1, + return _realm_dictionary_resolve_in( + list, + target_realm, + resolved, ); } - late final _realm_object_createPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, realm_class_key_t)>>('realm_object_create'); - late final _realm_object_create = _realm_object_createPtr.asFunction< - ffi.Pointer Function(ffi.Pointer, int)>(); + late final _realm_dictionary_resolve_inPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>>( + 'realm_dictionary_resolve_in'); + late final _realm_dictionary_resolve_in = + _realm_dictionary_resolve_inPtr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer>)>(); - /// Create an object in a class with a primary key. Will not succeed if an - /// object with the given primary key value already exists. + /// Get the size of a dictionary (the number of unique keys). /// - /// @return A non-NULL pointer if the object was created successfully. - ffi.Pointer realm_object_create_with_primary_key( - ffi.Pointer arg0, - int arg1, - realm_value_t pk, + /// This function may fail if the object owning the dictionary has been deleted. + /// + /// @param out_size Where to put the dictionary size. May be NULL. + /// @return True if no exception occurred. + bool realm_dictionary_size( + ffi.Pointer arg0, + ffi.Pointer out_size, ) { - return _realm_object_create_with_primary_key( + return _realm_dictionary_size( arg0, - arg1, - pk, + out_size, ); } - late final _realm_object_create_with_primary_keyPtr = _lookup< + late final _realm_dictionary_sizePtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - realm_class_key_t, - realm_value_t)>>('realm_object_create_with_primary_key'); - late final _realm_object_create_with_primary_key = - _realm_object_create_with_primary_keyPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, int, realm_value_t)>(); + ffi.Bool Function(ffi.Pointer, + ffi.Pointer)>>('realm_dictionary_size'); + late final _realm_dictionary_size = _realm_dictionary_sizePtr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer)>(); - /// Delete a realm object. - /// - /// Note: This does not call `realm_release()` on the `realm_object_t` instance. + /// Convert a dictionary to results. /// - /// @return True if no exception occurred. - bool realm_object_delete( - ffi.Pointer arg0, + /// @return A non-null pointer if no exception occurred. + ffi.Pointer realm_dictionary_to_results( + ffi.Pointer arg0, ) { - return _realm_object_delete( + return _realm_dictionary_to_results( arg0, ); } - late final _realm_object_deletePtr = _lookup< - ffi.NativeFunction)>>( - 'realm_object_delete'); - late final _realm_object_delete = _realm_object_deletePtr - .asFunction)>(); + late final _realm_dictionary_to_resultsPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer)>>('realm_dictionary_to_results'); + late final _realm_dictionary_to_results = + _realm_dictionary_to_resultsPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer)>(); - /// Find all objects in class. + /// Return true if two API objects refer to the same underlying data. Objects + /// with different types are never equal. /// - /// Note: This is faster than running a query matching all objects (such as - /// "TRUEPREDICATE"). + /// Note: This function cannot be used with types that have value semantics, only + /// opaque types that have object semantics. /// - /// @return A non-NULL pointer if no exception was thrown. - ffi.Pointer realm_object_find_all( - ffi.Pointer arg0, - int arg1, + /// - `realm_t` objects are identical if they represent the same instance (not + /// just if they represent the same file). + /// - `realm_schema_t` objects are equal if the represented schemas are equal. + /// - `realm_config_t` objects are equal if the configurations are equal. + /// - `realm_object_t` objects are identical if they belong to the same realm + /// and class, and have the same object key. + /// - `realm_list_t` and other collection objects are identical if they come + /// from the same object and property. + /// - `realm_query_t` objects are never equal. + /// - `realm_scheduler_t` objects are equal if they represent the same + /// scheduler. + /// - Query descriptor objects are equal if they represent equivalent + /// descriptors. + /// - `realm_async_error_t` objects are equal if they represent the same + /// exception instance. + /// + /// This function cannot fail. + bool realm_equals( + ffi.Pointer arg0, + ffi.Pointer arg1, ) { - return _realm_object_find_all( + return _realm_equals( arg0, arg1, ); } - late final _realm_object_find_allPtr = _lookup< + late final _realm_equalsPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - realm_class_key_t)>>('realm_object_find_all'); - late final _realm_object_find_all = _realm_object_find_allPtr.asFunction< - ffi.Pointer Function(ffi.Pointer, int)>(); + ffi.Bool Function( + ffi.Pointer, ffi.Pointer)>>('realm_equals'); + late final _realm_equals = _realm_equalsPtr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer)>(); - /// Find an object with a particular primary key value. + /// Find a by the name of @a name. /// - /// @param out_found A pointer to a boolean that will be set to true or false if - /// no error occurred. - /// @return A non-NULL pointer if the object was found and no exception occurred. - ffi.Pointer realm_object_find_with_primary_key( + /// @param name The name of the class. + /// @param out_found Set to true if the class was found and no error occurred. + /// Otherwise, false. May not be NULL. + /// @param out_class_info A pointer to a `realm_class_info_t` that will be + /// populated with information about the class. May be + /// NULL. + /// @return True if no exception occurred. + bool realm_find_class( ffi.Pointer arg0, - int arg1, - realm_value_t pk, + ffi.Pointer name, ffi.Pointer out_found, + ffi.Pointer out_class_info, ) { - return _realm_object_find_with_primary_key( + return _realm_find_class( arg0, - arg1, - pk, + name, out_found, + out_class_info, ); } - late final _realm_object_find_with_primary_keyPtr = _lookup< + late final _realm_find_classPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( + ffi.Bool Function( ffi.Pointer, - realm_class_key_t, - realm_value_t, - ffi.Pointer)>>('realm_object_find_with_primary_key'); - late final _realm_object_find_with_primary_key = - _realm_object_find_with_primary_keyPtr.asFunction< - ffi.Pointer Function(ffi.Pointer, int, - realm_value_t, ffi.Pointer)>(); + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('realm_find_class'); + late final _realm_find_class = _realm_find_classPtr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); - /// Get an object from a thread-safe reference, potentially originating in a - /// different `realm_t` instance - ffi.Pointer realm_object_from_thread_safe_reference( + /// Find the primary key property for a class, if it has one. + /// + /// @param class_key The table key for this class. + /// @param out_found Will be set to true if the property was found. May not be + /// NULL. + /// @param out_property_info A property to a `realm_property_info_t` that will be + /// populated with information about the property, if it + /// was found. May be NULL. + /// @return True if no exception occurred. + bool realm_find_primary_key_property( ffi.Pointer arg0, - ffi.Pointer arg1, + int class_key, + ffi.Pointer out_found, + ffi.Pointer out_property_info, ) { - return _realm_object_from_thread_safe_reference( + return _realm_find_primary_key_property( arg0, - arg1, + class_key, + out_found, + out_property_info, ); } - late final _realm_object_from_thread_safe_referencePtr = _lookup< + late final _realm_find_primary_key_propertyPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer)>>( - 'realm_object_from_thread_safe_reference'); - late final _realm_object_from_thread_safe_reference = - _realm_object_from_thread_safe_referencePtr.asFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer)>(); + ffi.Bool Function(ffi.Pointer, realm_class_key_t, + ffi.Pointer, ffi.Pointer)>>( + 'realm_find_primary_key_property'); + late final _realm_find_primary_key_property = + _realm_find_primary_key_propertyPtr.asFunction< + bool Function(ffi.Pointer, int, ffi.Pointer, + ffi.Pointer)>(); - /// Get the key for this object. + /// Find a property by the internal (non-public) name of @a name. /// - /// This function cannot fail. - int realm_object_get_key( - ffi.Pointer object, + /// @param class_key The table key for the class. + /// @param name The name of the property. + /// @param out_found Will be set to true if the property was found. May not be + /// NULL. + /// @param out_property_info A pointer to a `realm_property_info_t` that will be + /// populated with information about the property. May + /// be NULL. + /// @return True if no exception occurred. + bool realm_find_property( + ffi.Pointer arg0, + int class_key, + ffi.Pointer name, + ffi.Pointer out_found, + ffi.Pointer out_property_info, ) { - return _realm_object_get_key( - object, + return _realm_find_property( + arg0, + class_key, + name, + out_found, + out_property_info, ); } - late final _realm_object_get_keyPtr = _lookup< + late final _realm_find_propertyPtr = _lookup< ffi.NativeFunction< - realm_object_key_t Function( - ffi.Pointer)>>('realm_object_get_key'); - late final _realm_object_get_key = _realm_object_get_keyPtr - .asFunction)>(); + ffi.Bool Function( + ffi.Pointer, + realm_class_key_t, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('realm_find_property'); + late final _realm_find_property = _realm_find_propertyPtr.asFunction< + bool Function(ffi.Pointer, int, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); - /// Create an object in a class with a primary key. If an object with the given - /// primary key value already exists, that object will be returned. + /// Find a property with the public name of @a name. /// - /// @return A non-NULL pointer if the object was found/created successfully. - ffi.Pointer realm_object_get_or_create_with_primary_key( + /// @param class_key The table key for the class. + /// @param public_name The public name of the property. + /// @param out_found Will be set to true if the property was found. May not be + /// NULL. + /// @param out_property_info A pointer to a `realm_property_info_t` that will be + /// populated with information about the property. May + /// be NULL. + /// @return True if no exception occurred. + bool realm_find_property_by_public_name( ffi.Pointer arg0, - int arg1, - realm_value_t pk, - ffi.Pointer did_create, + int class_key, + ffi.Pointer public_name, + ffi.Pointer out_found, + ffi.Pointer out_property_info, ) { - return _realm_object_get_or_create_with_primary_key( + return _realm_find_property_by_public_name( arg0, - arg1, - pk, - did_create, + class_key, + public_name, + out_found, + out_property_info, ); } - late final _realm_object_get_or_create_with_primary_keyPtr = _lookup< + late final _realm_find_property_by_public_namePtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - realm_class_key_t, realm_value_t, ffi.Pointer)>>( - 'realm_object_get_or_create_with_primary_key'); - late final _realm_object_get_or_create_with_primary_key = - _realm_object_get_or_create_with_primary_keyPtr.asFunction< - ffi.Pointer Function(ffi.Pointer, int, - realm_value_t, ffi.Pointer)>(); + ffi.Bool Function( + ffi.Pointer, + realm_class_key_t, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>( + 'realm_find_property_by_public_name'); + late final _realm_find_property_by_public_name = + _realm_find_property_by_public_namePtr.asFunction< + bool Function(ffi.Pointer, int, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); - /// Get the parent object for the object passed as argument. Only works for embedded objects. - /// @return true, if no errors occurred. - bool realm_object_get_parent( - ffi.Pointer object, - ffi.Pointer> parent, - ffi.Pointer class_key, + /// Free memory allocated by the module this library was linked into. + /// + /// This is needed for raw memory buffers such as string copies or arrays + /// returned from a library function. Realm C Wrapper objects on the other hand + /// should always be freed with realm_release() only. + void realm_free( + ffi.Pointer buffer, ) { - return _realm_object_get_parent( - object, - parent, - class_key, + return _realm_free( + buffer, ); } - late final _realm_object_get_parentPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Pointer)>>('realm_object_get_parent'); - late final _realm_object_get_parent = _realm_object_get_parentPtr.asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Pointer)>(); + late final _realm_freePtr = + _lookup)>>( + 'realm_free'); + late final _realm_free = + _realm_freePtr.asFunction)>(); - /// Get the table for this object. + /// Produce a frozen view of this realm. /// - /// This function cannot fail. - int realm_object_get_table( - ffi.Pointer object, + /// @return A non-NULL realm instance representing the frozen state. + ffi.Pointer realm_freeze( + ffi.Pointer arg0, ) { - return _realm_object_get_table( - object, + return _realm_freeze( + arg0, ); } - late final _realm_object_get_tablePtr = _lookup< + late final _realm_freezePtr = _lookup< ffi.NativeFunction< - realm_class_key_t Function( - ffi.Pointer)>>('realm_object_get_table'); - late final _realm_object_get_table = _realm_object_get_tablePtr - .asFunction)>(); + ffi.Pointer Function(ffi.Pointer)>>('realm_freeze'); + late final _realm_freeze = _realm_freezePtr + .asFunction Function(ffi.Pointer)>(); - /// True if this object still exists in the realm. + /// Create a `realm_t` object from a thread-safe reference to the same realm. /// - /// This function cannot fail. - bool realm_object_is_valid( - ffi.Pointer arg0, + /// @param tsr Thread-safe reference object created by calling + /// `realm_get_thread_safe_reference()` with a `realm_t` instance. + /// @param scheduler The scheduler to use for the new `realm_t` instance. May be + /// NULL, in which case the default scheduler for the current + /// thread is used. + /// @return A non-null pointer if no error occurred. + ffi.Pointer realm_from_thread_safe_reference( + ffi.Pointer tsr, + ffi.Pointer scheduler, ) { - return _realm_object_is_valid( - arg0, + return _realm_from_thread_safe_reference( + tsr, + scheduler, ); } - late final _realm_object_is_validPtr = _lookup< - ffi.NativeFunction)>>( - 'realm_object_is_valid'); - late final _realm_object_is_valid = _realm_object_is_validPtr - .asFunction)>(); + late final _realm_from_thread_safe_referencePtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer)>>( + 'realm_from_thread_safe_reference'); + late final _realm_from_thread_safe_reference = + _realm_from_thread_safe_referencePtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer)>(); - /// Resolve the Realm object in the provided Realm. + /// Get information about an async error, potentially coming from another thread. /// - /// This is equivalent to producing a thread-safe reference and resolving it in the target realm. + /// This function does not allocate any memory. /// - /// If the object can be resolved in the target realm, '*resolved' points to the new object - /// If the object cannot be resolved in the target realm, '*resolved' will be null. - /// @return True if no exception occurred (except exceptions that may normally occur if resolution fails) - bool realm_object_resolve_in( - ffi.Pointer live_object, - ffi.Pointer target_realm, - ffi.Pointer> resolved, + /// @param err A pointer to a `realm_error_t` struct that will be populated with + /// information about the error. May not be NULL. + /// @return A bool indicating whether or not an error is available to be returned + /// @see realm_get_last_error() + bool realm_get_async_error( + ffi.Pointer err, + ffi.Pointer out_err, ) { - return _realm_object_resolve_in( - live_object, - target_realm, - resolved, + return _realm_get_async_error( + err, + out_err, ); } - late final _realm_object_resolve_inPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>)>>( - 'realm_object_resolve_in'); - late final _realm_object_resolve_in = _realm_object_resolve_inPtr.asFunction< - bool Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer>)>(); + late final _realm_get_async_errorPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, + ffi.Pointer)>>('realm_get_async_error'); + late final _realm_get_async_error = _realm_get_async_errorPtr.asFunction< + bool Function( + ffi.Pointer, ffi.Pointer)>(); - /// Serializes an object to json and returns it as string. Serializes a single level of properties only. - /// - /// @return a json-serialized representation of the object. - ffi.Pointer realm_object_to_string( - ffi.Pointer arg0, + /// Fetch the backlinks for the object passed as argument. + /// @return a valid ptr to realm results that contains all the backlinks for the object, or null in case of errors. + ffi.Pointer realm_get_backlinks( + ffi.Pointer object, + int source_table_key, + int property_key, ) { - return _realm_object_to_string( - arg0, + return _realm_get_backlinks( + object, + source_table_key, + property_key, ); } - late final _realm_object_to_stringPtr = _lookup< + late final _realm_get_backlinksPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_object_to_string'); - late final _realm_object_to_string = _realm_object_to_stringPtr.asFunction< - ffi.Pointer Function(ffi.Pointer)>(); + ffi.Pointer Function(ffi.Pointer, + realm_class_key_t, realm_property_key_t)>>('realm_get_backlinks'); + late final _realm_get_backlinks = _realm_get_backlinksPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, int, int)>(); - /// Open a Realm file. - /// - /// @param config Realm configuration. If the Realm is already opened on another - /// thread, validate that the given configuration is compatible - /// with the existing one. - /// @return If successful, the Realm object. Otherwise, NULL. - ffi.Pointer realm_open( - ffi.Pointer config, + /// Get the actual log category names (currently 15) + /// @param num_values number of values in the out_values array + /// @param out_values pointer to an array of size num_values + /// @return returns the number of categories returned. If num_values is zero, it will + /// return the total number of categories. + int realm_get_category_names( + int num_values, + ffi.Pointer> out_values, ) { - return _realm_open( - config, + return _realm_get_category_names( + num_values, + out_values, ); } - late final _realm_openPtr = _lookup< + late final _realm_get_category_namesPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_open'); - late final _realm_open = _realm_openPtr - .asFunction Function(ffi.Pointer)>(); + ffi.Size Function(ffi.Size, + ffi.Pointer>)>>('realm_get_category_names'); + late final _realm_get_category_names = _realm_get_category_namesPtr + .asFunction>)>(); - /// Create a task that will open a realm with the specific configuration - /// and also download all changes from the sync server. + /// Get the class with @a key from the schema. /// - /// Use @a realm_async_open_task_start() to start the download process. - ffi.Pointer realm_open_synchronized( - ffi.Pointer arg0, + /// Passing an invalid @a key for this schema is considered an error. + /// + /// @param key The key of the class, as discovered by `realm_get_class_keys()`. + /// @param out_class_info A pointer to a `realm_class_info_t` that will be + /// populated with the information of the class. May be + /// NULL, though that's kind of pointless. + /// @return True if no exception occurred. + bool realm_get_class( + ffi.Pointer arg0, + int key, + ffi.Pointer out_class_info, ) { - return _realm_open_synchronized( + return _realm_get_class( arg0, + key, + out_class_info, ); } - late final _realm_open_synchronizedPtr = _lookup< + late final _realm_get_classPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_open_synchronized'); - late final _realm_open_synchronized = _realm_open_synchronizedPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer)>(); + ffi.Bool Function(ffi.Pointer, realm_class_key_t, + ffi.Pointer)>>('realm_get_class'); + late final _realm_get_class = _realm_get_classPtr.asFunction< + bool Function( + ffi.Pointer, int, ffi.Pointer)>(); - /// Parse a query string and append it to an existing query via logical &&. - /// The query string applies to the same table and Realm as the existing query. - /// - /// If the query failed to parse, the parser error is available from - /// `realm_get_last_error()`. + /// Get the table keys for classes in the schema. + /// In case of errors this function will return false (errors to be fetched via `realm_get_last_error()`). + /// If data is not copied the function will return true and set `out_n` with the capacity needed. + /// Data is only copied if the input array has enough capacity, otherwise the needed array capacity will be set. /// - /// @param query_string A zero-terminated string in the Realm Query Language, - /// optionally containing argument placeholders (`$0`, `$1`, - /// etc.). - /// @param num_args The number of arguments for this query. - /// @param args A pointer to a list of argument values. - /// @return A non-null pointer if the query was successfully parsed and no - /// exception occurred. - ffi.Pointer realm_query_append_query( - ffi.Pointer arg0, - ffi.Pointer query_string, - int num_args, - ffi.Pointer args, + /// @param out_keys An array that will contain the keys of each class in the + /// schema. Array may be NULL, in this case no data will be copied and `out_n` set if not NULL. + /// @param max The maximum number of keys to write to `out_keys`. + /// @param out_n The actual number of classes. May be NULL. + /// @return True if no exception occurred. + bool realm_get_class_keys( + ffi.Pointer arg0, + ffi.Pointer out_keys, + int max, + ffi.Pointer out_n, ) { - return _realm_query_append_query( + return _realm_get_class_keys( arg0, - query_string, - num_args, - args, + out_keys, + max, + out_n, ); } - late final _realm_query_append_queryPtr = _lookup< + late final _realm_get_class_keysPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, ffi.Size, - ffi.Pointer)>>('realm_query_append_query'); - late final _realm_query_append_query = - _realm_query_append_queryPtr.asFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer, int, ffi.Pointer)>(); + ffi.Pointer)>>('realm_get_class_keys'); + late final _realm_get_class_keys = _realm_get_class_keysPtr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, int, + ffi.Pointer)>(); - /// Count the number of objects found by this query. - bool realm_query_count( - ffi.Pointer arg0, - ffi.Pointer out_count, + /// Get the list of properties for the class with this @a key. + /// In case of errors this function will return false (errors to be fetched via `realm_get_last_error()`). + /// If data is not copied the function will return true and set `out_n` with the capacity needed. + /// Data is only copied if the input array has enough capacity, otherwise the needed array capacity will be set. + /// + /// @param out_properties A pointer to an array of `realm_property_info_t`, which + /// will be populated with the information about the + /// properties. Array may be NULL, in this case no data will be copied and `out_n` set if not + /// NULL. + /// @param max The maximum number of entries to write to `out_properties`. + /// @param out_n The actual number of properties written to `out_properties`. + /// @return True if no exception occurred. + bool realm_get_class_properties( + ffi.Pointer arg0, + int key, + ffi.Pointer out_properties, + int max, + ffi.Pointer out_n, ) { - return _realm_query_count( + return _realm_get_class_properties( arg0, - out_count, + key, + out_properties, + max, + out_n, ); } - late final _realm_query_countPtr = _lookup< + late final _realm_get_class_propertiesPtr = _lookup< ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, - ffi.Pointer)>>('realm_query_count'); - late final _realm_query_count = _realm_query_countPtr.asFunction< - bool Function(ffi.Pointer, ffi.Pointer)>(); + ffi.Bool Function( + ffi.Pointer, + realm_class_key_t, + ffi.Pointer, + ffi.Size, + ffi.Pointer)>>('realm_get_class_properties'); + late final _realm_get_class_properties = + _realm_get_class_propertiesPtr.asFunction< + bool Function( + ffi.Pointer, + int, + ffi.Pointer, + int, + ffi.Pointer)>(); - /// Delete all objects matched by a query. - bool realm_query_delete_all( - ffi.Pointer arg0, + /// Get a dictionary instance for the property of an object. + /// + /// Note: It is up to the caller to call `realm_release()` on the returned dictionary. + /// + /// @return A non-null pointer if no exception occurred. + ffi.Pointer realm_get_dictionary( + ffi.Pointer arg0, + int arg1, ) { - return _realm_query_delete_all( + return _realm_get_dictionary( arg0, + arg1, ); } - late final _realm_query_delete_allPtr = _lookup< - ffi.NativeFunction)>>( - 'realm_query_delete_all'); - late final _realm_query_delete_all = _realm_query_delete_allPtr - .asFunction)>(); + late final _realm_get_dictionaryPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + realm_property_key_t)>>('realm_get_dictionary'); + late final _realm_get_dictionary = _realm_get_dictionaryPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, int)>(); - /// Produce a results object for this query. + /// Get the last error that happened on this thread. /// - /// Note: This does not actually run the query until the results are accessed in - /// some way. + /// Errors are thread-local. Getting the error must happen on the same thread as + /// the call that caused the error to occur. The error is specific to the current + /// thread, and not the Realm instance for which the error occurred. /// - /// @return A non-null pointer if no exception occurred. - ffi.Pointer realm_query_find_all( - ffi.Pointer arg0, + /// Note: The error message in @a err will only be safe to use until the next API + /// call is made on the current thread. + /// + /// Note: The error is not cleared by subsequent successful calls to this + /// function, but it will be overwritten by subsequent failing calls to + /// other library functions. + /// + /// Note: Calling this function does not clear the current last error. + /// + /// This function does not allocate any memory. + /// + /// @param err A pointer to a `realm_error_t` struct that will be populated with + /// information about the last error, if there is one. May be NULL. + /// @return True if an error occurred. + bool realm_get_last_error( + ffi.Pointer err, ) { - return _realm_query_find_all( - arg0, + return _realm_get_last_error( + err, ); } - late final _realm_query_find_allPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_query_find_all'); - late final _realm_query_find_all = _realm_query_find_allPtr.asFunction< - ffi.Pointer Function(ffi.Pointer)>(); + late final _realm_get_last_errorPtr = _lookup< + ffi.NativeFunction)>>( + 'realm_get_last_error'); + late final _realm_get_last_error = _realm_get_last_errorPtr + .asFunction)>(); - /// Return the first object matched by this query. + /// Convert the last error to `realm_async_error_t`, which can safely be passed + /// between threads. /// - /// Note: This function can only produce objects, not values. Use the - /// `realm_results_t` returned by `realm_query_find_all()` to retrieve - /// values from a list of primitive values. + /// Note: This function does not clear the last error. /// - /// @param out_value Where to write the result, if any object matched the query. - /// May be NULL. - /// @param out_found Where to write whether the object was found. May be NULL. - /// @return True if no exception occurred. - bool realm_query_find_first( - ffi.Pointer arg0, - ffi.Pointer out_value, - ffi.Pointer out_found, - ) { - return _realm_query_find_first( - arg0, - out_value, - out_found, - ); + /// @return A non-null pointer if there was an error on this thread. + /// @see realm_get_last_error() + /// @see realm_get_async_error() + /// @see realm_clear_last_error() + ffi.Pointer realm_get_last_error_as_async_error() { + return _realm_get_last_error_as_async_error(); } - late final _realm_query_find_firstPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>>('realm_query_find_first'); - late final _realm_query_find_first = _realm_query_find_firstPtr.asFunction< - bool Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>(); + late final _realm_get_last_error_as_async_errorPtr = + _lookup Function()>>( + 'realm_get_last_error_as_async_error'); + late final _realm_get_last_error_as_async_error = + _realm_get_last_error_as_async_errorPtr + .asFunction Function()>(); - /// Get textual representation of query - /// - /// @return a string containing the description. The string memory is managed by the query object. - ffi.Pointer realm_query_get_description( - ffi.Pointer arg0, - ) { - return _realm_query_get_description( - arg0, - ); + ffi.Pointer realm_get_library_cpu_arch() { + return _realm_get_library_cpu_arch(); } - late final _realm_query_get_descriptionPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_query_get_description'); - late final _realm_query_get_description = _realm_query_get_descriptionPtr - .asFunction Function(ffi.Pointer)>(); + late final _realm_get_library_cpu_archPtr = + _lookup Function()>>( + 'realm_get_library_cpu_arch'); + late final _realm_get_library_cpu_arch = _realm_get_library_cpu_archPtr + .asFunction Function()>(); - /// Parse a query string and bind it to a table. + /// Get a string representing the version number of the Realm library. /// - /// If the query failed to parse, the parser error is available from - /// `realm_get_last_error()`. + /// @return A null-terminated string. + ffi.Pointer realm_get_library_version() { + return _realm_get_library_version(); + } + + late final _realm_get_library_versionPtr = + _lookup Function()>>( + 'realm_get_library_version'); + late final _realm_get_library_version = _realm_get_library_versionPtr + .asFunction Function()>(); + + /// Get individual components of the version number of the Realm library. /// - /// @param target_table The table on which to run this query. - /// @param query_string A zero-terminated string in the Realm Query Language, - /// optionally containing argument placeholders (`$0`, `$1`, - /// etc.). - /// @param num_args The number of arguments for this query. - /// @param args A pointer to a list of argument values. - /// @return A non-null pointer if the query was successfully parsed and no - /// exception occurred. - ffi.Pointer realm_query_parse( - ffi.Pointer arg0, - int target_table, - ffi.Pointer query_string, - int num_args, - ffi.Pointer args, + /// @param out_major The major version number (X.0.0). + /// @param out_minor The minor version number (0.X.0). + /// @param out_patch The patch version number (0.0.X). + /// @param out_extra The extra version string (0.0.0-X). + void realm_get_library_version_numbers( + ffi.Pointer out_major, + ffi.Pointer out_minor, + ffi.Pointer out_patch, + ffi.Pointer> out_extra, ) { - return _realm_query_parse( - arg0, - target_table, - query_string, - num_args, - args, + return _realm_get_library_version_numbers( + out_major, + out_minor, + out_patch, + out_extra, ); } - late final _realm_query_parsePtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - realm_class_key_t, - ffi.Pointer, - ffi.Size, - ffi.Pointer)>>('realm_query_parse'); - late final _realm_query_parse = _realm_query_parsePtr.asFunction< - ffi.Pointer Function(ffi.Pointer, int, - ffi.Pointer, int, ffi.Pointer)>(); + late final _realm_get_library_version_numbersPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer>)>>( + 'realm_get_library_version_numbers'); + late final _realm_get_library_version_numbers = + _realm_get_library_version_numbersPtr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer>)>(); - /// Parse a query string and bind it to a list. - /// - /// If the query failed to parse, the parser error is available from - /// `realm_get_last_error()`. + /// Return the object linked by the given property /// - /// @param target_list The list on which to run this query. - /// @param query_string A string in the Realm Query Language, optionally - /// containing argument placeholders (`$0`, `$1`, etc.). - /// @param num_args The number of arguments for this query. - /// @param args A pointer to a list of argument values. - /// @return A non-null pointer if the query was successfully parsed and no - /// exception occurred. - ffi.Pointer realm_query_parse_for_list( - ffi.Pointer target_list, - ffi.Pointer query_string, - int num_args, - ffi.Pointer args, + /// @return A non-NULL pointer if an object is found. + ffi.Pointer realm_get_linked_object( + ffi.Pointer arg0, + int arg1, ) { - return _realm_query_parse_for_list( - target_list, - query_string, - num_args, - args, + return _realm_get_linked_object( + arg0, + arg1, ); } - late final _realm_query_parse_for_listPtr = _lookup< + late final _realm_get_linked_objectPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ffi.Pointer)>>('realm_query_parse_for_list'); - late final _realm_query_parse_for_list = - _realm_query_parse_for_listPtr.asFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer, int, ffi.Pointer)>(); + ffi.Pointer Function(ffi.Pointer, + realm_property_key_t)>>('realm_get_linked_object'); + late final _realm_get_linked_object = _realm_get_linked_objectPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, int)>(); - /// Parse a query string and bind it to another query result. + /// Get a list instance for the property of an object. /// - /// If the query failed to parse, the parser error is available from - /// `realm_get_last_error()`. + /// Note: It is up to the caller to call `realm_release()` on the returned list. /// - /// @param target_results The results on which to run this query. - /// @param query_string A zero-terminated string in the Realm Query Language, - /// optionally containing argument placeholders (`$0`, `$1`, - /// etc.). - /// @param num_args The number of arguments for this query. - /// @param args A pointer to a list of argument values. - /// @return A non-null pointer if the query was successfully parsed and no - /// exception occurred. - ffi.Pointer realm_query_parse_for_results( - ffi.Pointer target_results, - ffi.Pointer query_string, - int num_args, - ffi.Pointer args, + /// @return A non-null pointer if no exception occurred. + ffi.Pointer realm_get_list( + ffi.Pointer arg0, + int arg1, ) { - return _realm_query_parse_for_results( - target_results, - query_string, - num_args, - args, + return _realm_get_list( + arg0, + arg1, ); } - late final _realm_query_parse_for_resultsPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ffi.Pointer)>>( - 'realm_query_parse_for_results'); - late final _realm_query_parse_for_results = - _realm_query_parse_for_resultsPtr.asFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer, int, ffi.Pointer)>(); + late final _realm_get_listPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + realm_property_key_t)>>('realm_get_list'); + late final _realm_get_list = _realm_get_listPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, int)>(); - /// Parse a query string and bind it to a set. - /// - /// If the query failed to parse, the parser error is available from - /// `realm_get_last_error()`. - /// - /// @param target_set The set on which to run this query. - /// @param query_string A string in the Realm Query Language, optionally - /// containing argument placeholders (`$0`, `$1`, etc.). - /// @param num_args The number of arguments for this query. - /// @param args A pointer to a list of argument values. - /// @return A non-null pointer if the query was successfully parsed and no - /// exception occurred. - ffi.Pointer realm_query_parse_for_set( - ffi.Pointer target_set, - ffi.Pointer query_string, - int num_args, - ffi.Pointer args, + /// Get the logging level for given category. + realm_log_level realm_get_log_level_category( + ffi.Pointer arg0, ) { - return _realm_query_parse_for_set( - target_set, - query_string, - num_args, - args, - ); + return realm_log_level.fromValue(_realm_get_log_level_category( + arg0, + )); } - late final _realm_query_parse_for_setPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ffi.Pointer)>>('realm_query_parse_for_set'); - late final _realm_query_parse_for_set = - _realm_query_parse_for_setPtr.asFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer, int, ffi.Pointer)>(); + late final _realm_get_log_level_categoryPtr = _lookup< + ffi.NativeFunction)>>( + 'realm_get_log_level_category'); + late final _realm_get_log_level_category = _realm_get_log_level_categoryPtr + .asFunction)>(); - /// Refresh the view of the realm file. - /// - /// If another process or thread has made changes to the realm file, this causes - /// those changes to become visible in this realm instance. - /// - /// This calls `advance_read()` at the Core layer. + /// Return the number of classes in the Realm's schema. /// - /// @return True if no exceptions are thrown, false otherwise. - bool realm_refresh( + /// This cannot fail. + int realm_get_num_classes( ffi.Pointer arg0, - ffi.Pointer did_refresh, ) { - return _realm_refresh( + return _realm_get_num_classes( arg0, - did_refresh, ); } - late final _realm_refreshPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, ffi.Pointer)>>('realm_refresh'); - late final _realm_refresh = _realm_refreshPtr - .asFunction, ffi.Pointer)>(); + late final _realm_get_num_classesPtr = + _lookup)>>( + 'realm_get_num_classes'); + late final _realm_get_num_classes = _realm_get_num_classesPtr + .asFunction)>(); - /// In case of exception thrown in user code callbacks, this api will allow the sdk to store the user code exception - /// and retrieve a it later via realm_get_last_error. - /// Most importantly the SDK is responsible to handle the memory pointed by user_code_error. - /// @param usercode_error pointer representing whatever object the SDK treats as exception/error. - void realm_register_user_code_callback_error( - ffi.Pointer usercode_error, + /// Get the number of objects in a table (class). + /// + /// @param out_count A pointer to a `size_t` that will contain the number of + /// objects, if successful. + /// @return True if the table key was valid for this realm. + bool realm_get_num_objects( + ffi.Pointer arg0, + int arg1, + ffi.Pointer out_count, ) { - return _realm_register_user_code_callback_error( - usercode_error, + return _realm_get_num_objects( + arg0, + arg1, + out_count, ); } - late final _realm_register_user_code_callback_errorPtr = - _lookup)>>( - 'realm_register_user_code_callback_error'); - late final _realm_register_user_code_callback_error = - _realm_register_user_code_callback_errorPtr - .asFunction)>(); + late final _realm_get_num_objectsPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, realm_class_key_t, + ffi.Pointer)>>('realm_get_num_objects'); + late final _realm_get_num_objects = _realm_get_num_objectsPtr.asFunction< + bool Function(ffi.Pointer, int, ffi.Pointer)>(); - /// Free any Realm C Wrapper object. - /// - /// Note: Any pointer returned from a library function is owned by the caller. - /// The caller is responsible for calling `realm_release()`. The only - /// exception from this is C++ bridge functions that return `void*`, with - /// the prefix `_realm`. - /// - /// Note: C++ destructors are typically `noexcept`, so it is likely that an - /// exception will crash the process. + /// Get the number of versions found in the Realm file. /// - /// @param ptr A pointer to a Realm C Wrapper object. May be NULL. - void realm_release( - ffi.Pointer ptr, + /// @param out_versions_count A pointer to a `size_t` that will contain the number of + /// versions, if successful. + /// @return True if no exception occurred. + bool realm_get_num_versions( + ffi.Pointer arg0, + ffi.Pointer out_versions_count, ) { - return _realm_release( - ptr, + return _realm_get_num_versions( + arg0, + out_versions_count, ); } - late final _realm_releasePtr = - _lookup)>>( - 'realm_release'); - late final _realm_release = - _realm_releasePtr.asFunction)>(); + late final _realm_get_num_versionsPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, + ffi.Pointer)>>('realm_get_num_versions'); + late final _realm_get_num_versions = _realm_get_num_versionsPtr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer)>(); - /// Find and delete the table passed as parementer for the realm instance passed to this function. - /// @param table_name for the table the user wants to delete - /// @param table_deleted in order to indicate if the table was actually deleted from realm - /// @return true if no error has occurred, false otherwise - bool realm_remove_table( + /// Get an object with a particular object key. + /// + /// @param class_key The class key. + /// @param obj_key The key to the object. Passing a non-existent key is + /// considered an error. + /// @return A non-NULL pointer if no exception occurred. + ffi.Pointer realm_get_object( ffi.Pointer arg0, - ffi.Pointer table_name, - ffi.Pointer table_deleted, + int class_key, + int obj_key, ) { - return _realm_remove_table( + return _realm_get_object( arg0, - table_name, - table_deleted, + class_key, + obj_key, ); } - late final _realm_remove_tablePtr = _lookup< + late final _realm_get_objectPtr = _lookup< ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>>('realm_remove_table'); - late final _realm_remove_table = _realm_remove_tablePtr.asFunction< - bool Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>(); + ffi.Pointer Function(ffi.Pointer, + realm_class_key_t, realm_object_key_t)>>('realm_get_object'); + late final _realm_get_object = _realm_get_objectPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, int, int)>(); - ffi.Pointer - realm_results_add_notification_callback( - ffi.Pointer arg0, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, - ffi.Pointer key_path_array, - realm_on_collection_change_func_t arg4, + /// Get the schema version for this realm at the path. + int realm_get_persisted_schema_version( + ffi.Pointer config, ) { - return _realm_results_add_notification_callback( - arg0, - userdata, - userdata_free, - key_path_array, - arg4, + return _realm_get_persisted_schema_version( + config, ); } - late final _realm_results_add_notification_callbackPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - realm_free_userdata_func_t, - ffi.Pointer, - realm_on_collection_change_func_t)>>( - 'realm_results_add_notification_callback'); - late final _realm_results_add_notification_callback = - _realm_results_add_notification_callbackPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - realm_free_userdata_func_t, - ffi.Pointer, - realm_on_collection_change_func_t)>(); + late final _realm_get_persisted_schema_versionPtr = _lookup< + ffi.NativeFunction)>>( + 'realm_get_persisted_schema_version'); + late final _realm_get_persisted_schema_version = + _realm_get_persisted_schema_versionPtr + .asFunction)>(); - /// Compute the average value of a property in the results. + /// Find a property by its column key. /// - /// Note: For numeric columns, the average is always converted to double. + /// It is an error to pass a property @a key that is not present in this class. /// - /// @param out_average Where to write the result. - /// @param out_found Set to true if there are matching rows. + /// @param class_key The key of the class. + /// @param key The column key for the property. + /// @param out_property_info A pointer to a `realm_property_info_t` that will be + /// populated with information about the property. /// @return True if no exception occurred. - bool realm_results_average( - ffi.Pointer arg0, - int arg1, - ffi.Pointer out_average, - ffi.Pointer out_found, + bool realm_get_property( + ffi.Pointer arg0, + int class_key, + int key, + ffi.Pointer out_property_info, ) { - return _realm_results_average( + return _realm_get_property( arg0, - arg1, - out_average, - out_found, + class_key, + key, + out_property_info, ); } - late final _realm_results_averagePtr = _lookup< + late final _realm_get_propertyPtr = _lookup< ffi.NativeFunction< ffi.Bool Function( - ffi.Pointer, + ffi.Pointer, + realm_class_key_t, realm_property_key_t, - ffi.Pointer, - ffi.Pointer)>>('realm_results_average'); - late final _realm_results_average = _realm_results_averagePtr.asFunction< - bool Function(ffi.Pointer, int, - ffi.Pointer, ffi.Pointer)>(); + ffi.Pointer)>>('realm_get_property'); + late final _realm_get_property = _realm_get_propertyPtr.asFunction< + bool Function(ffi.Pointer, int, int, + ffi.Pointer)>(); - /// Count the number of results. - /// - /// If the result is "live" (not a snapshot), this may rerun the query if things - /// have changed. + /// Get the property keys for the class with this @a key. + /// In case of errors this function will return false (errors to be fetched via `realm_get_last_error()`). + /// If data is not copied the function will return true and set `out_n` with the capacity needed. + /// Data is only copied if the input array has enough capacity, otherwise the needed array capacity will be set. /// + /// @param key The class key. + /// @param out_col_keys An array of property keys. Array may be NULL, + /// in this case no data will be copied and `out_n` set if not NULL. + /// @param max The maximum number of keys to write to `out_col_keys`. Ignored if + /// `out_col_keys == NULL`. + /// @param out_n The actual number of properties written to `out_col_keys` (if + /// non-NULL), or number of properties in the class. /// @return True if no exception occurred. - bool realm_results_count( - ffi.Pointer arg0, - ffi.Pointer out_count, + bool realm_get_property_keys( + ffi.Pointer arg0, + int key, + ffi.Pointer out_col_keys, + int max, + ffi.Pointer out_n, ) { - return _realm_results_count( + return _realm_get_property_keys( arg0, - out_count, + key, + out_col_keys, + max, + out_n, ); } - late final _realm_results_countPtr = _lookup< + late final _realm_get_property_keysPtr = _lookup< ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, - ffi.Pointer)>>('realm_results_count'); - late final _realm_results_count = _realm_results_countPtr.asFunction< - bool Function(ffi.Pointer, ffi.Pointer)>(); + ffi.Bool Function( + ffi.Pointer, + realm_class_key_t, + ffi.Pointer, + ffi.Size, + ffi.Pointer)>>('realm_get_property_keys'); + late final _realm_get_property_keys = _realm_get_property_keysPtr.asFunction< + bool Function(ffi.Pointer, int, + ffi.Pointer, int, ffi.Pointer)>(); - /// Delete all objects in the result. + /// Get the schema for this realm. /// - /// If the result if "live" (not a snapshot), this may rerun the query if things - /// have changed. + /// Note: The returned value is allocated by this function, so `realm_release()` + /// must be called on it. + ffi.Pointer realm_get_schema( + ffi.Pointer arg0, + ) { + return _realm_get_schema( + arg0, + ); + } + + late final _realm_get_schemaPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer)>>('realm_get_schema'); + late final _realm_get_schema = _realm_get_schemaPtr + .asFunction Function(ffi.Pointer)>(); + + /// Get the schema version for this realm. /// - /// @return True if no exception occurred. - bool realm_results_delete_all( - ffi.Pointer arg0, + /// This function cannot fail. + int realm_get_schema_version( + ffi.Pointer realm, ) { - return _realm_results_delete_all( - arg0, + return _realm_get_schema_version( + realm, ); } - late final _realm_results_delete_allPtr = _lookup< - ffi.NativeFunction)>>( - 'realm_results_delete_all'); - late final _realm_results_delete_all = _realm_results_delete_allPtr - .asFunction)>(); + late final _realm_get_schema_versionPtr = + _lookup)>>( + 'realm_get_schema_version'); + late final _realm_get_schema_version = _realm_get_schema_versionPtr + .asFunction)>(); - /// Create a new results object by removing duplicates + /// Get a set instance for the property of an object. + /// + /// Note: It is up to the caller to call `realm_release()` on the returned set. /// - /// @param distinct_string Specifies a distinct condition. It has the format - /// ["," ]* - /// ::= ["." ]* /// @return A non-null pointer if no exception occurred. - ffi.Pointer realm_results_distinct( - ffi.Pointer results, - ffi.Pointer distinct_string, + ffi.Pointer realm_get_set( + ffi.Pointer arg0, + int arg1, ) { - return _realm_results_distinct( - results, - distinct_string, + return _realm_get_set( + arg0, + arg1, ); } - late final _realm_results_distinctPtr = _lookup< + late final _realm_get_setPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer)>>('realm_results_distinct'); - late final _realm_results_distinct = _realm_results_distinctPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, ffi.Pointer)>(); + ffi.Pointer Function(ffi.Pointer, + realm_property_key_t)>>('realm_get_set'); + late final _realm_get_set = _realm_get_setPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, int)>(); - /// Create a new results object by further filtering existing result. + /// Get the value for a property. /// - /// @return A non-null pointer if no exception occurred. - ffi.Pointer realm_results_filter( - ffi.Pointer arg0, - ffi.Pointer arg1, + /// @return True if no exception occurred. + bool realm_get_value( + ffi.Pointer arg0, + int arg1, + ffi.Pointer out_value, ) { - return _realm_results_filter( + return _realm_get_value( arg0, arg1, + out_value, ); } - late final _realm_results_filterPtr = _lookup< + late final _realm_get_valuePtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer)>>('realm_results_filter'); - late final _realm_results_filter = _realm_results_filterPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, ffi.Pointer)>(); + ffi.Bool Function(ffi.Pointer, realm_property_key_t, + ffi.Pointer)>>('realm_get_value'); + late final _realm_get_value = _realm_get_valuePtr.asFunction< + bool Function( + ffi.Pointer, int, ffi.Pointer)>(); - /// Find the index for the value passed as parameter inside realm results pointer passed a input parameter. - /// @param value the value to find inside the realm results - /// @param out_index the index where the object has been found, or realm::not_found - /// @param out_found boolean indicating if the value has been found or not - /// @return true if no error occurred, false otherwise - bool realm_results_find( - ffi.Pointer arg0, - ffi.Pointer value, - ffi.Pointer out_index, - ffi.Pointer out_found, + /// Get the value for the property at the specified index in the object's schema. + /// @param prop_index The index of the property in the class properties array the realm was opened with. + /// @return True if no exception occurred. + bool realm_get_value_by_property_index( + ffi.Pointer object, + int prop_index, + ffi.Pointer out_value, ) { - return _realm_results_find( - arg0, - value, - out_index, - out_found, + return _realm_get_value_by_property_index( + object, + prop_index, + out_value, ); } - late final _realm_results_findPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>>('realm_results_find'); - late final _realm_results_find = _realm_results_findPtr.asFunction< - bool Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer, ffi.Pointer)>(); + late final _realm_get_value_by_property_indexPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, ffi.Size, + ffi.Pointer)>>( + 'realm_get_value_by_property_index'); + late final _realm_get_value_by_property_index = + _realm_get_value_by_property_indexPtr.asFunction< + bool Function( + ffi.Pointer, int, ffi.Pointer)>(); - /// Find the index for the realm object passed as parameter inside realm results pointer passed a input parameter. - /// @param value the value to find inside the realm results - /// @param out_index the index where the object has been found, or realm::not_found - /// @param out_found boolean indicating if the value has been found or not - /// @return true if no error occurred, false otherwise - bool realm_results_find_object( - ffi.Pointer arg0, - ffi.Pointer value, - ffi.Pointer out_index, - ffi.Pointer out_found, + /// Get the values for several properties. + /// + /// This is provided as an alternative to calling `realm_get_value()` multiple + /// times in a row, which is particularly useful for language runtimes where + /// crossing the native bridge is comparatively expensive. In addition, it + /// eliminates some parameter validation that would otherwise be repeated for + /// each call. + /// + /// Example use cases: + /// + /// - Extracting all properties of an object for serialization. + /// - Converting an object to some in-memory representation. + /// + /// @param num_values The number of elements in @a properties and @a out_values. + /// @param properties The keys for the properties to fetch. May not be NULL. + /// @param out_values Where to write the property values. If an error occurs, + /// this array may only be partially initialized. May not be + /// NULL. + /// @return True if no exception occurs. + bool realm_get_values( + ffi.Pointer arg0, + int num_values, + ffi.Pointer properties, + ffi.Pointer out_values, ) { - return _realm_results_find_object( + return _realm_get_values( arg0, - value, - out_index, - out_found, + num_values, + properties, + out_values, ); } - late final _realm_results_find_objectPtr = _lookup< + late final _realm_get_valuesPtr = _lookup< ffi.NativeFunction< ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>>('realm_results_find_object'); - late final _realm_results_find_object = - _realm_results_find_objectPtr.asFunction< - bool Function( - ffi.Pointer, ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>(); + ffi.Size, + ffi.Pointer, + ffi.Pointer)>>('realm_get_values'); + late final _realm_get_values = _realm_get_valuesPtr.asFunction< + bool Function(ffi.Pointer, int, + ffi.Pointer, ffi.Pointer)>(); - /// Get an results object from a thread-safe reference, potentially originating - /// in a different `realm_t` instance - ffi.Pointer realm_results_from_thread_safe_reference( + /// Get the VersionID of the current transaction. + /// + /// @param out_found True if version information is available. This requires an available Read or Write transaction. + /// @param out_version The version of the current transaction. If `out_found` returns False, this returns (0,0). + /// @return True if no exception occurred. + bool realm_get_version_id( ffi.Pointer arg0, - ffi.Pointer arg1, + ffi.Pointer out_found, + ffi.Pointer out_version, ) { - return _realm_results_from_thread_safe_reference( + return _realm_get_version_id( arg0, - arg1, + out_found, + out_version, ); } - late final _realm_results_from_thread_safe_referencePtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer)>>( - 'realm_results_from_thread_safe_reference'); - late final _realm_results_from_thread_safe_reference = - _realm_results_from_thread_safe_referencePtr.asFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer)>(); + late final _realm_get_version_idPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('realm_get_version_id'); + late final _realm_get_version_id = _realm_get_version_idPtr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); - /// Get the matching element at @a index in the results. - /// - /// If the result is "live" (not a snapshot), this may rerun the query if things - /// have changed. - /// - /// Note: The bound returned by `realm_results_count()` for a non-snapshot result - /// is not a reliable way to iterate over elements in the result, because - /// the result will be live-updated if changes are made in each iteration - /// that may change the number of query results or even change the - /// ordering. In other words, this method should probably only be used with - /// snapshot results. + /// True if the Realm file is closed. /// - /// @return True if no exception occurred (including out-of-bounds). - bool realm_results_get( - ffi.Pointer arg0, - int index, - ffi.Pointer out_value, + /// This function cannot fail. + bool realm_is_closed( + ffi.Pointer arg0, ) { - return _realm_results_get( + return _realm_is_closed( arg0, - index, - out_value, ); } - late final _realm_results_getPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, ffi.Size, - ffi.Pointer)>>('realm_results_get'); - late final _realm_results_get = _realm_results_getPtr.asFunction< - bool Function( - ffi.Pointer, int, ffi.Pointer)>(); + late final _realm_is_closedPtr = + _lookup)>>( + 'realm_is_closed'); + late final _realm_is_closed = + _realm_is_closedPtr.asFunction)>(); - /// Returns an instance of realm_dictionary for the index passed as argument. - /// @return A valid ptr to a dictionary instance or nullptr in case of errors - ffi.Pointer realm_results_get_dictionary( - ffi.Pointer arg0, - int index, + /// True if a Realm C Wrapper object is "frozen" (immutable). + /// + /// Objects, collections, and results can be frozen. For all other types, this + /// function always returns false. + bool realm_is_frozen( + ffi.Pointer arg0, ) { - return _realm_results_get_dictionary( + return _realm_is_frozen( arg0, - index, ); } - late final _realm_results_get_dictionaryPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Size)>>('realm_results_get_dictionary'); - late final _realm_results_get_dictionary = - _realm_results_get_dictionaryPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, int)>(); + late final _realm_is_frozenPtr = + _lookup)>>( + 'realm_is_frozen'); + late final _realm_is_frozen = + _realm_is_frozenPtr.asFunction)>(); - /// Returns an instance of realm_list at the index passed as argument. - /// @return A valid ptr to a list instance or nullptr in case of errors - ffi.Pointer realm_results_get_list( - ffi.Pointer arg0, - int index, + /// Return true if the realm is in a write transaction. + /// + /// This function cannot fail. + bool realm_is_writable( + ffi.Pointer arg0, ) { - return _realm_results_get_list( + return _realm_is_writable( arg0, - index, ); } - late final _realm_results_get_listPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Size)>>('realm_results_get_list'); - late final _realm_results_get_list = _realm_results_get_listPtr.asFunction< - ffi.Pointer Function(ffi.Pointer, int)>(); + late final _realm_is_writablePtr = + _lookup)>>( + 'realm_is_writable'); + late final _realm_is_writable = + _realm_is_writablePtr.asFunction)>(); - /// Get the matching object at @a index in the results. - /// - /// If the result is "live" (not a snapshot), this may rerun the query if things - /// have changed. - /// - /// Note: The bound returned by `realm_results_count()` for a non-snapshot result - /// is not a reliable way to iterate over elements in the result, because - /// the result will be live-updated if changes are made in each iteration - /// that may change the number of query results or even change the - /// ordering. In other words, this method should probably only be used with - /// snapshot results. + /// Subscribe to notifications for this object. /// - /// @return An instance of `realm_object_t` if no exception occurred. - ffi.Pointer realm_results_get_object( - ffi.Pointer arg0, - int index, + /// @return A non-null pointer if no exception occurred. + ffi.Pointer realm_list_add_notification_callback( + ffi.Pointer arg0, + ffi.Pointer userdata, + realm_free_userdata_func_t userdata_free, + ffi.Pointer key_path_array, + realm_on_collection_change_func_t on_change, ) { - return _realm_results_get_object( + return _realm_list_add_notification_callback( arg0, - index, + userdata, + userdata_free, + key_path_array, + on_change, ); } - late final _realm_results_get_objectPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Size)>>('realm_results_get_object'); - late final _realm_results_get_object = - _realm_results_get_objectPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, int)>(); + late final _realm_list_add_notification_callbackPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + realm_free_userdata_func_t, + ffi.Pointer, + realm_on_collection_change_func_t)>>( + 'realm_list_add_notification_callback'); + late final _realm_list_add_notification_callback = + _realm_list_add_notification_callbackPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + realm_free_userdata_func_t, + ffi.Pointer, + realm_on_collection_change_func_t)>(); - /// Return the query associated to the results passed as argument. + /// Clear a list, removing all elements in the list. In a list of links, this + /// does *NOT* delete the target objects. /// - /// @param results the ptr to a valid results object. - /// @return a valid ptr to realm_query_t if no error has occurred - ffi.Pointer realm_results_get_query( - ffi.Pointer results, + /// @return True if no exception occurred. + bool realm_list_clear( + ffi.Pointer arg0, ) { - return _realm_results_get_query( - results, + return _realm_list_clear( + arg0, ); } - late final _realm_results_get_queryPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_results_get_query'); - late final _realm_results_get_query = _realm_results_get_queryPtr.asFunction< - ffi.Pointer Function(ffi.Pointer)>(); + late final _realm_list_clearPtr = + _lookup)>>( + 'realm_list_clear'); + late final _realm_list_clear = _realm_list_clearPtr + .asFunction)>(); - /// Set the boolean passed as argument to true or false whether the realm_results passed is valid or not - /// @return true/false if no exception has occurred. - bool realm_results_is_valid( - ffi.Pointer arg0, - ffi.Pointer arg1, + /// Erase the element at @a index. + /// + /// @return True if no exception occurred. + bool realm_list_erase( + ffi.Pointer arg0, + int index, ) { - return _realm_results_is_valid( + return _realm_list_erase( arg0, - arg1, + index, ); } - late final _realm_results_is_validPtr = _lookup< + late final _realm_list_erasePtr = _lookup< ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, - ffi.Pointer)>>('realm_results_is_valid'); - late final _realm_results_is_valid = _realm_results_is_validPtr.asFunction< - bool Function(ffi.Pointer, ffi.Pointer)>(); + ffi.Bool Function( + ffi.Pointer, ffi.Size)>>('realm_list_erase'); + late final _realm_list_erase = _realm_list_erasePtr + .asFunction, int)>(); - /// Create a new results object by limiting the number of items - /// - /// @param max_count Specifies the number of elements the new result can have at most - /// @return A non-null pointer if no exception occurred. - ffi.Pointer realm_results_limit( - ffi.Pointer results, - int max_count, + /// Find the value in the list passed as parameter. + /// @param value to search in the list + /// @param out_index the index in the list where the value has been found or realm::not_found. + /// @param out_found boolean that indicates whether the value is found or not + /// @return true if no exception occurred. + bool realm_list_find( + ffi.Pointer arg0, + ffi.Pointer value, + ffi.Pointer out_index, + ffi.Pointer out_found, ) { - return _realm_results_limit( - results, - max_count, + return _realm_list_find( + arg0, + value, + out_index, + out_found, ); } - late final _realm_results_limitPtr = _lookup< + late final _realm_list_findPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, ffi.Size)>>('realm_results_limit'); - late final _realm_results_limit = _realm_results_limitPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, int)>(); + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('realm_list_find'); + late final _realm_list_find = _realm_list_findPtr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); - /// Compute the maximum value of a property in the results. - /// - /// @param out_max Where to write the result, if there were matching rows. - /// @param out_found Set to true if there are matching rows. - /// @return True if no exception occurred. - bool realm_results_max( - ffi.Pointer arg0, - int arg1, - ffi.Pointer out_max, - ffi.Pointer out_found, + /// Get an list from a thread-safe reference, potentially originating in a + /// different `realm_t` instance + ffi.Pointer realm_list_from_thread_safe_reference( + ffi.Pointer arg0, + ffi.Pointer arg1, ) { - return _realm_results_max( + return _realm_list_from_thread_safe_reference( arg0, arg1, - out_max, - out_found, ); } - late final _realm_results_maxPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - realm_property_key_t, - ffi.Pointer, - ffi.Pointer)>>('realm_results_max'); - late final _realm_results_max = _realm_results_maxPtr.asFunction< - bool Function(ffi.Pointer, int, - ffi.Pointer, ffi.Pointer)>(); + late final _realm_list_from_thread_safe_referencePtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer)>>( + 'realm_list_from_thread_safe_reference'); + late final _realm_list_from_thread_safe_reference = + _realm_list_from_thread_safe_referencePtr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer)>(); - /// Compute the minimum value of a property in the results. + /// Get the value at @a index. /// - /// @param out_min Where to write the result, if there were matching rows. - /// @param out_found Set to true if there are matching rows. + /// @param out_value The resulting value, if no error occurred. May be NULL, + /// though nonsensical. /// @return True if no exception occurred. - bool realm_results_min( - ffi.Pointer arg0, - int arg1, - ffi.Pointer out_min, - ffi.Pointer out_found, + bool realm_list_get( + ffi.Pointer arg0, + int index, + ffi.Pointer out_value, ) { - return _realm_results_min( + return _realm_list_get( arg0, - arg1, - out_min, - out_found, + index, + out_value, ); } - late final _realm_results_minPtr = _lookup< + late final _realm_list_getPtr = _lookup< ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - realm_property_key_t, - ffi.Pointer, - ffi.Pointer)>>('realm_results_min'); - late final _realm_results_min = _realm_results_minPtr.asFunction< - bool Function(ffi.Pointer, int, - ffi.Pointer, ffi.Pointer)>(); + ffi.Bool Function(ffi.Pointer, ffi.Size, + ffi.Pointer)>>('realm_list_get'); + late final _realm_list_get = _realm_list_getPtr.asFunction< + bool Function( + ffi.Pointer, int, ffi.Pointer)>(); - /// Map the Results into a live Realm instance. - /// - /// This is equivalent to producing a thread-safe reference and resolving it in the live realm. + /// Returns a nested dictionary if such collection exists, NULL otherwise. /// - /// @return A live copy of the Results. - ffi.Pointer realm_results_resolve_in( - ffi.Pointer from_results, - ffi.Pointer target_realm, + /// @param list pointer to the list that containes the nested collection into + /// @param index position of collection in the list + /// @return a pointer to the the nested dictionary found at index passed as argument + ffi.Pointer realm_list_get_dictionary( + ffi.Pointer list, + int index, ) { - return _realm_results_resolve_in( - from_results, - target_realm, + return _realm_list_get_dictionary( + list, + index, ); } - late final _realm_results_resolve_inPtr = _lookup< + late final _realm_list_get_dictionaryPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer)>>('realm_results_resolve_in'); - late final _realm_results_resolve_in = - _realm_results_resolve_inPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, ffi.Pointer)>(); + ffi.Pointer Function(ffi.Pointer, + ffi.Size)>>('realm_list_get_dictionary'); + late final _realm_list_get_dictionary = + _realm_list_get_dictionaryPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, int)>(); - /// Return a snapshot of the results that never automatically updates. + /// Get object identified at index /// - /// The returned result is suitable for use with `realm_results_count()` + - /// `realm_results_get()`. - ffi.Pointer realm_results_snapshot( - ffi.Pointer arg0, + /// @return A non-NULL pointer if value is an object. + ffi.Pointer realm_list_get_linked_object( + ffi.Pointer arg0, + int index, ) { - return _realm_results_snapshot( + return _realm_list_get_linked_object( arg0, + index, ); } - late final _realm_results_snapshotPtr = _lookup< + late final _realm_list_get_linked_objectPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_results_snapshot'); - late final _realm_results_snapshot = _realm_results_snapshotPtr.asFunction< - ffi.Pointer Function(ffi.Pointer)>(); + ffi.Pointer Function(ffi.Pointer, + ffi.Size)>>('realm_list_get_linked_object'); + late final _realm_list_get_linked_object = + _realm_list_get_linked_objectPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, int)>(); - /// Create a new results object by further sorting existing result. + /// Returns a nested list if such collection exists, NULL otherwise. /// - /// @param sort_string Specifies a sort condition. It has the format - /// ["," ]* - /// ::= ["." ]* , - /// ::= "ASCENDING" | "DESCENDING" - /// @return A non-null pointer if no exception occurred. - ffi.Pointer realm_results_sort( - ffi.Pointer results, - ffi.Pointer sort_string, + /// @param list pointer to the list that containes the nested list + /// @param index index of collection in the list + /// @return a pointer to the the nested list found at the index passed as argument + ffi.Pointer realm_list_get_list( + ffi.Pointer list, + int index, ) { - return _realm_results_sort( - results, - sort_string, + return _realm_list_get_list( + list, + index, ); } - late final _realm_results_sortPtr = _lookup< + late final _realm_list_get_listPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer)>>('realm_results_sort'); - late final _realm_results_sort = _realm_results_sortPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, ffi.Pointer)>(); + ffi.Pointer Function( + ffi.Pointer, ffi.Size)>>('realm_list_get_list'); + late final _realm_list_get_list = _realm_list_get_listPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, int)>(); - /// Compute the sum value of a property in the results. + /// Get the property that this list came from. /// - /// @param out_sum Where to write the result. Zero if no rows matched. - /// @param out_found Set to true if there are matching rows. /// @return True if no exception occurred. - bool realm_results_sum( - ffi.Pointer arg0, - int arg1, - ffi.Pointer out_sum, - ffi.Pointer out_found, + bool realm_list_get_property( + ffi.Pointer arg0, + ffi.Pointer out_property_info, ) { - return _realm_results_sum( + return _realm_list_get_property( arg0, - arg1, - out_sum, - out_found, + out_property_info, ); } - late final _realm_results_sumPtr = _lookup< + late final _realm_list_get_propertyPtr = _lookup< ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - realm_property_key_t, - ffi.Pointer, - ffi.Pointer)>>('realm_results_sum'); - late final _realm_results_sum = _realm_results_sumPtr.asFunction< - bool Function(ffi.Pointer, int, - ffi.Pointer, ffi.Pointer)>(); + ffi.Bool Function(ffi.Pointer, + ffi.Pointer)>>('realm_list_get_property'); + late final _realm_list_get_property = _realm_list_get_propertyPtr.asFunction< + bool Function( + ffi.Pointer, ffi.Pointer)>(); - /// Roll back a write transaction. + /// Insert @a value at @a index. /// - /// @return True if the rollback succeeded and no exceptions were thrown. - bool realm_rollback( - ffi.Pointer arg0, + /// @param value The value to insert. + /// @return True if no exception occurred. + bool realm_list_insert( + ffi.Pointer arg0, + int index, + realm_value_t value, ) { - return _realm_rollback( + return _realm_list_insert( arg0, + index, + value, ); } - late final _realm_rollbackPtr = - _lookup)>>( - 'realm_rollback'); - late final _realm_rollback = - _realm_rollbackPtr.asFunction)>(); - - /// Get the scheduler used by frozen realms. This scheduler does not support - /// notifications, and does not perform any thread checking. - /// - /// This function is thread-safe, and cannot fail. - ffi.Pointer realm_scheduler_get_frozen() { - return _realm_scheduler_get_frozen(); - } - - late final _realm_scheduler_get_frozenPtr = - _lookup Function()>>( - 'realm_scheduler_get_frozen'); - late final _realm_scheduler_get_frozen = _realm_scheduler_get_frozenPtr - .asFunction Function()>(); + late final _realm_list_insertPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, ffi.Size, + realm_value_t)>>('realm_list_insert'); + late final _realm_list_insert = _realm_list_insertPtr.asFunction< + bool Function(ffi.Pointer, int, realm_value_t)>(); - /// Create an instance of the default scheduler for the current platform, - /// normally confined to the calling thread. - ffi.Pointer realm_scheduler_make_default() { - return _realm_scheduler_make_default(); + ffi.Pointer realm_list_insert_dictionary( + ffi.Pointer list, + int index, + ) { + return _realm_list_insert_dictionary( + list, + index, + ); } - late final _realm_scheduler_make_defaultPtr = - _lookup Function()>>( - 'realm_scheduler_make_default'); - late final _realm_scheduler_make_default = _realm_scheduler_make_defaultPtr - .asFunction Function()>(); + late final _realm_list_insert_dictionaryPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Size)>>('realm_list_insert_dictionary'); + late final _realm_list_insert_dictionary = + _realm_list_insert_dictionaryPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, int)>(); - /// Create a custom scheduler object from callback functions. + /// Insert an embedded object at a given position. /// - /// @param notify Function which will be called whenever the scheduler has work - /// to do. Each call to this should trigger a call to - /// `realm_scheduler_perform_work()` from within the scheduler's - /// event loop. This function must be thread-safe, or NULL, in - /// which case the scheduler is considered unable to deliver - /// notifications. - /// @param is_on_thread Function to return true if called from the same thread as - /// the scheduler. This function must be thread-safe. - /// @param can_deliver_notifications Function to return true if the scheduler can - /// support `notify()`. This function does not - /// need to be thread-safe. - ffi.Pointer realm_scheduler_new( - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, - realm_scheduler_notify_func_t notify, - realm_scheduler_is_on_thread_func_t is_on_thread, - realm_scheduler_is_same_as_func_t is_same_as, - realm_scheduler_can_deliver_notifications_func_t can_deliver_notifications, + /// @return A non-NULL pointer if the object was created successfully. + ffi.Pointer realm_list_insert_embedded( + ffi.Pointer arg0, + int index, ) { - return _realm_scheduler_new( - userdata, - userdata_free, - notify, - is_on_thread, - is_same_as, - can_deliver_notifications, + return _realm_list_insert_embedded( + arg0, + index, ); } - late final _realm_scheduler_newPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - realm_free_userdata_func_t, - realm_scheduler_notify_func_t, - realm_scheduler_is_on_thread_func_t, - realm_scheduler_is_same_as_func_t, - realm_scheduler_can_deliver_notifications_func_t)>>( - 'realm_scheduler_new'); - late final _realm_scheduler_new = _realm_scheduler_newPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, - realm_free_userdata_func_t, - realm_scheduler_notify_func_t, - realm_scheduler_is_on_thread_func_t, - realm_scheduler_is_same_as_func_t, - realm_scheduler_can_deliver_notifications_func_t)>(); + late final _realm_list_insert_embeddedPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Size)>>('realm_list_insert_embedded'); + late final _realm_list_insert_embedded = + _realm_list_insert_embeddedPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, int)>(); + + /// Insert a collection inside a list (only available for mixed types) + /// + /// @param list valid ptr to a list of mixed + /// @param index position in the list where to add the collection + /// @return pointer to a valid collection that has been just inserted at the index passed as argument + ffi.Pointer realm_list_insert_list( + ffi.Pointer list, + int index, + ) { + return _realm_list_insert_list( + list, + index, + ); + } - /// Performs all of the pending work for the given scheduler. + late final _realm_list_insert_listPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Size)>>('realm_list_insert_list'); + late final _realm_list_insert_list = _realm_list_insert_listPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, int)>(); + + /// Check if a list is valid. /// - /// This function must be called from within the scheduler's event loop. It must - /// be called each time the notify callback passed to the scheduler - /// is invoked. - void realm_scheduler_perform_work( - ffi.Pointer arg0, + /// @return True if the list is valid. + bool realm_list_is_valid( + ffi.Pointer arg0, ) { - return _realm_scheduler_perform_work( + return _realm_list_is_valid( arg0, ); } - late final _realm_scheduler_perform_workPtr = _lookup< - ffi - .NativeFunction)>>( - 'realm_scheduler_perform_work'); - late final _realm_scheduler_perform_work = _realm_scheduler_perform_workPtr - .asFunction)>(); + late final _realm_list_is_validPtr = + _lookup)>>( + 'realm_list_is_valid'); + late final _realm_list_is_valid = _realm_list_is_validPtr + .asFunction)>(); - /// Create a new schema from classes and their properties. - /// - /// Note: This function does not validate the schema. - /// - /// Note: `realm_class_key_t` and `realm_property_key_t` values inside - /// `realm_class_info_t` and `realm_property_info_t` are unused when - /// defining the schema. Call `realm_get_schema()` to obtain the values for - /// these fields in an open realm. + /// Move the element at @a from_index to @a to_index. /// - /// @return True if allocation of the schema structure succeeded. - ffi.Pointer realm_schema_new( - ffi.Pointer classes, - int num_classes, - ffi.Pointer> class_properties, + /// @param from_index The index of the element to move. + /// @param to_index The index to move the element to. + /// @return True if no exception occurred. + bool realm_list_move( + ffi.Pointer arg0, + int from_index, + int to_index, ) { - return _realm_schema_new( - classes, - num_classes, - class_properties, + return _realm_list_move( + arg0, + from_index, + to_index, ); } - late final _realm_schema_newPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Size, - ffi.Pointer>)>>( - 'realm_schema_new'); - late final _realm_schema_new = _realm_schema_newPtr.asFunction< - ffi.Pointer Function(ffi.Pointer, int, - ffi.Pointer>)>(); + late final _realm_list_movePtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, ffi.Size, + ffi.Size)>>('realm_list_move'); + late final _realm_list_move = _realm_list_movePtr + .asFunction, int, int)>(); - /// Rename a property for the schame of the open realm. - /// @param realm The realm for which the property schema has to be renamed - /// @param schema The schema to modifies - /// @param object_type type of the object to modify - /// @param old_name old name of the property - /// @param new_name new name of the property - bool realm_schema_rename_property( - ffi.Pointer realm, - ffi.Pointer schema, - ffi.Pointer object_type, - ffi.Pointer old_name, - ffi.Pointer new_name, + /// In a list of objects, delete all objects in the list and clear the list. In a + /// list of values, clear the list. + /// + /// @return True if no exception occurred. + bool realm_list_remove_all( + ffi.Pointer arg0, ) { - return _realm_schema_rename_property( - realm, - schema, - object_type, - old_name, - new_name, + return _realm_list_remove_all( + arg0, ); } - late final _realm_schema_rename_propertyPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>>('realm_schema_rename_property'); - late final _realm_schema_rename_property = - _realm_schema_rename_propertyPtr.asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>(); + late final _realm_list_remove_allPtr = + _lookup)>>( + 'realm_list_remove_all'); + late final _realm_list_remove_all = _realm_list_remove_allPtr + .asFunction)>(); - /// Validate the schema. + /// Resolve the list in the context of a given Realm instance. /// - /// @param validation_mode A bitwise combination of values from the - /// enum realm_schema_validation_mode. + /// This is equivalent to producing a thread-safe reference and resolving it in the frozen realm. /// - /// @return True if the schema passed validation. If validation failed, - /// `realm_get_last_error()` will produce an error describing the - /// validation failure. - bool realm_schema_validate( - ffi.Pointer arg0, - int validation_mode, + /// If resolution is possible, a valid resolved object is produced at '*resolved*'. + /// If resolution is not possible, but no error occurs, '*resolved' is set to NULL + /// + /// @return true if no error occurred. + bool realm_list_resolve_in( + ffi.Pointer list, + ffi.Pointer target_realm, + ffi.Pointer> resolved, ) { - return _realm_schema_validate( - arg0, - validation_mode, + return _realm_list_resolve_in( + list, + target_realm, + resolved, ); } - late final _realm_schema_validatePtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, - ffi.Uint64)>>('realm_schema_validate'); - late final _realm_schema_validate = _realm_schema_validatePtr - .asFunction, int)>(); + late final _realm_list_resolve_inPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer>)>>( + 'realm_list_resolve_in'); + late final _realm_list_resolve_in = _realm_list_resolve_inPtr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer>)>(); - /// Subscribe to notifications for this object. + /// Set the value at @a index. /// - /// @return A non-null pointer if no exception occurred. - ffi.Pointer realm_set_add_notification_callback( - ffi.Pointer arg0, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, - ffi.Pointer key_path_array, - realm_on_collection_change_func_t on_change, + /// @param value The value to set. + /// @return True if no exception occurred. + bool realm_list_set( + ffi.Pointer arg0, + int index, + realm_value_t value, ) { - return _realm_set_add_notification_callback( + return _realm_list_set( arg0, - userdata, - userdata_free, - key_path_array, - on_change, + index, + value, ); } - late final _realm_set_add_notification_callbackPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - realm_free_userdata_func_t, - ffi.Pointer, - realm_on_collection_change_func_t)>>( - 'realm_set_add_notification_callback'); - late final _realm_set_add_notification_callback = - _realm_set_add_notification_callbackPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - realm_free_userdata_func_t, - ffi.Pointer, - realm_on_collection_change_func_t)>(); + late final _realm_list_setPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, ffi.Size, + realm_value_t)>>('realm_list_set'); + late final _realm_list_set = _realm_list_setPtr.asFunction< + bool Function(ffi.Pointer, int, realm_value_t)>(); - void realm_set_auto_refresh( - ffi.Pointer realm, - bool enable, + ffi.Pointer realm_list_set_dictionary( + ffi.Pointer list, + int index, ) { - return _realm_set_auto_refresh( - realm, - enable, + return _realm_list_set_dictionary( + list, + index, ); } - late final _realm_set_auto_refreshPtr = _lookup< - ffi - .NativeFunction, ffi.Bool)>>( - 'realm_set_auto_refresh'); - late final _realm_set_auto_refresh = _realm_set_auto_refreshPtr - .asFunction, bool)>(); + late final _realm_list_set_dictionaryPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Size)>>('realm_list_set_dictionary'); + late final _realm_list_set_dictionary = + _realm_list_set_dictionaryPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, int)>(); - /// Clear a set of values. + /// Create an embedded object at a given position. /// - /// @return True if no exception occurred. - bool realm_set_clear( - ffi.Pointer arg0, + /// @return A non-NULL pointer if the object was created successfully. + ffi.Pointer realm_list_set_embedded( + ffi.Pointer arg0, + int index, ) { - return _realm_set_clear( + return _realm_list_set_embedded( arg0, + index, ); } - late final _realm_set_clearPtr = - _lookup)>>( - 'realm_set_clear'); - late final _realm_set_clear = - _realm_set_clearPtr.asFunction)>(); + late final _realm_list_set_embeddedPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Size)>>('realm_list_set_embedded'); + late final _realm_list_set_embedded = _realm_list_set_embeddedPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, int)>(); - ffi.Pointer realm_set_dictionary( - ffi.Pointer arg0, - int arg1, + /// Set a collection inside a list (only available for mixed types). + /// If the list already contains a collection of the requested type, the + /// operation is idempotent. + /// + /// @param list valid ptr to a list where a nested collection needs to be set + /// @param index position in the list where to set the collection + /// @return a valid ptr representing the collection just set + ffi.Pointer realm_list_set_list( + ffi.Pointer list, + int index, ) { - return _realm_set_dictionary( - arg0, - arg1, + return _realm_list_set_list( + list, + index, ); } - late final _realm_set_dictionaryPtr = _lookup< + late final _realm_list_set_listPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - realm_property_key_t)>>('realm_set_dictionary'); - late final _realm_set_dictionary = _realm_set_dictionaryPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, int)>(); + ffi.Pointer Function( + ffi.Pointer, ffi.Size)>>('realm_list_set_list'); + late final _realm_list_set_list = _realm_list_set_listPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, int)>(); - /// Create an embedded object in a given property. + /// Get the size of a list, in number of elements. /// - /// @return A non-NULL pointer if the object was created successfully. - ffi.Pointer realm_set_embedded( - ffi.Pointer arg0, - int arg1, + /// This function may fail if the object owning the list has been deleted. + /// + /// @param out_size Where to put the list size. May be NULL. + /// @return True if no exception occurred. + bool realm_list_size( + ffi.Pointer arg0, + ffi.Pointer out_size, ) { - return _realm_set_embedded( + return _realm_list_size( arg0, - arg1, + out_size, ); } - late final _realm_set_embeddedPtr = _lookup< + late final _realm_list_sizePtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - realm_property_key_t)>>('realm_set_embedded'); - late final _realm_set_embedded = _realm_set_embeddedPtr.asFunction< - ffi.Pointer Function(ffi.Pointer, int)>(); + ffi.Bool Function(ffi.Pointer, + ffi.Pointer)>>('realm_list_size'); + late final _realm_list_size = _realm_list_sizePtr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer)>(); - /// Erase an element from a set. - /// - /// If the element does not exist in the set, this function does nothing (and - /// does not report an error). + /// Convert a list to results. /// - /// @param value The value to erase. - /// @param out_erased If non-null, will be set to true if the element was found - /// and erased, and otherwise set to false. - /// @return True if no exception occurred. - bool realm_set_erase( - ffi.Pointer arg0, - realm_value_t value, - ffi.Pointer out_erased, + /// @return A non-null pointer if no exception occurred. + ffi.Pointer realm_list_to_results( + ffi.Pointer arg0, ) { - return _realm_set_erase( + return _realm_list_to_results( arg0, - value, - out_erased, ); } - late final _realm_set_erasePtr = _lookup< + late final _realm_list_to_resultsPtr = _lookup< ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, realm_value_t, - ffi.Pointer)>>('realm_set_erase'); - late final _realm_set_erase = _realm_set_erasePtr.asFunction< - bool Function( - ffi.Pointer, realm_value_t, ffi.Pointer)>(); + ffi.Pointer Function( + ffi.Pointer)>>('realm_list_to_results'); + late final _realm_list_to_results = _realm_list_to_resultsPtr.asFunction< + ffi.Pointer Function(ffi.Pointer)>(); - /// Find an element in a set. - /// - /// If @a value has a type that is incompatible with the set, it will be reported - /// as not existing in the set. - /// - /// @param value The value to look for in the set. - /// @param out_index If non-null, and the element is found, this will be - /// populated with the index of the found element in the set. - /// @param out_found If non-null, will be set to true if the element was found, - /// otherwise will be set to false. - /// @return True if no exception occurred. - bool realm_set_find( - ffi.Pointer arg0, - realm_value_t value, - ffi.Pointer out_index, - ffi.Pointer out_found, + /// Increment atomically property specified as parameter by value, for the object passed as argument. + /// @param object valid ptr to an object store in the database + /// @param property_key id of the property to change + /// @param value increment for the property passed as argument + /// @return True if not exception occurred. + bool realm_object_add_int( + ffi.Pointer object, + int property_key, + int value, ) { - return _realm_set_find( - arg0, + return _realm_object_add_int( + object, + property_key, value, - out_index, - out_found, ); } - late final _realm_set_findPtr = _lookup< + late final _realm_object_add_intPtr = _lookup< ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, realm_value_t, - ffi.Pointer, ffi.Pointer)>>('realm_set_find'); - late final _realm_set_find = _realm_set_findPtr.asFunction< - bool Function(ffi.Pointer, realm_value_t, - ffi.Pointer, ffi.Pointer)>(); + ffi.Bool Function(ffi.Pointer, realm_property_key_t, + ffi.Int64)>>('realm_object_add_int'); + late final _realm_object_add_int = _realm_object_add_intPtr + .asFunction, int, int)>(); - /// Get an set from a thread-safe reference, potentially originating in a - /// different `realm_t` instance - ffi.Pointer realm_set_from_thread_safe_reference( - ffi.Pointer arg0, - ffi.Pointer arg1, + /// Subscribe to notifications for this object. + /// + /// @return A non-null pointer if no exception occurred. + ffi.Pointer + realm_object_add_notification_callback( + ffi.Pointer arg0, + ffi.Pointer userdata, + realm_free_userdata_func_t userdata_free, + ffi.Pointer key_path_array, + realm_on_object_change_func_t on_change, ) { - return _realm_set_from_thread_safe_reference( + return _realm_object_add_notification_callback( arg0, - arg1, + userdata, + userdata_free, + key_path_array, + on_change, ); } - late final _realm_set_from_thread_safe_referencePtr = _lookup< + late final _realm_object_add_notification_callbackPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer)>>( - 'realm_set_from_thread_safe_reference'); - late final _realm_set_from_thread_safe_reference = - _realm_set_from_thread_safe_referencePtr.asFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer)>(); + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + realm_free_userdata_func_t, + ffi.Pointer, + realm_on_object_change_func_t)>>( + 'realm_object_add_notification_callback'); + late final _realm_object_add_notification_callback = + _realm_object_add_notification_callbackPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + realm_free_userdata_func_t, + ffi.Pointer, + realm_on_object_change_func_t)>(); - /// Get the value at @a index. - /// - /// Note that elements in a set move around arbitrarily when other elements are - /// inserted/removed. + /// Get a `realm_link_t` representing a link to @a object. /// - /// @param out_value The resulting value, if no error occurred. May be NULL, - /// though nonsensical. - /// @return True if no exception occurred. - bool realm_set_get( - ffi.Pointer arg0, - int index, - ffi.Pointer out_value, + /// This function cannot fail. + realm_link_t realm_object_as_link( + ffi.Pointer object, ) { - return _realm_set_get( - arg0, - index, - out_value, + return _realm_object_as_link( + object, ); } - late final _realm_set_getPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, ffi.Size, - ffi.Pointer)>>('realm_set_get'); - late final _realm_set_get = _realm_set_getPtr.asFunction< - bool Function( - ffi.Pointer, int, ffi.Pointer)>(); + late final _realm_object_as_linkPtr = _lookup< + ffi + .NativeFunction)>>( + 'realm_object_as_link'); + late final _realm_object_as_link = _realm_object_as_linkPtr + .asFunction)>(); - /// Get the property that this set came from. + /// Get the column keys for the properties that were modified in an object + /// notification. /// - /// @return True if no exception occurred. - bool realm_set_get_property( - ffi.Pointer arg0, - ffi.Pointer out_property_info, + /// This function cannot fail. + /// + /// @param out_modified Where the column keys should be written. May be NULL. + /// @param max The maximum number of column keys to write. + /// @return The number of column keys written to @a out_modified, or the number + /// of modified properties if @a out_modified is NULL. + int realm_object_changes_get_modified_properties( + ffi.Pointer arg0, + ffi.Pointer out_modified, + int max, ) { - return _realm_set_get_property( + return _realm_object_changes_get_modified_properties( arg0, - out_property_info, + out_modified, + max, ); } - late final _realm_set_get_propertyPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, - ffi.Pointer)>>('realm_set_get_property'); - late final _realm_set_get_property = _realm_set_get_propertyPtr.asFunction< - bool Function( - ffi.Pointer, ffi.Pointer)>(); - - /// Insert an element in a set. - /// - /// If the element is already in the set, this function does nothing (and does - /// not report an error). + late final _realm_object_changes_get_modified_propertiesPtr = _lookup< + ffi.NativeFunction< + ffi.Size Function( + ffi.Pointer, + ffi.Pointer, + ffi.Size)>>('realm_object_changes_get_modified_properties'); + late final _realm_object_changes_get_modified_properties = + _realm_object_changes_get_modified_propertiesPtr.asFunction< + int Function(ffi.Pointer, + ffi.Pointer, int)>(); + + /// Get the number of properties that were modified in an object notification. /// - /// @param value The value to insert. - /// @param out_index If non-null, will be set to the index of the inserted - /// element, or the index of the existing element. - /// @param out_inserted If non-null, will be set to true if the element did not - /// already exist in the set. Otherwise set to false. - /// @return True if no exception occurred. - bool realm_set_insert( - ffi.Pointer arg0, - realm_value_t value, - ffi.Pointer out_index, - ffi.Pointer out_inserted, + /// This function cannot fail. + int realm_object_changes_get_num_modified_properties( + ffi.Pointer arg0, ) { - return _realm_set_insert( + return _realm_object_changes_get_num_modified_properties( arg0, - value, - out_index, - out_inserted, ); } - late final _realm_set_insertPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - realm_value_t, - ffi.Pointer, - ffi.Pointer)>>('realm_set_insert'); - late final _realm_set_insert = _realm_set_insertPtr.asFunction< - bool Function(ffi.Pointer, realm_value_t, - ffi.Pointer, ffi.Pointer)>(); + late final _realm_object_changes_get_num_modified_propertiesPtr = _lookup< + ffi.NativeFunction< + ffi.Size Function(ffi.Pointer)>>( + 'realm_object_changes_get_num_modified_properties'); + late final _realm_object_changes_get_num_modified_properties = + _realm_object_changes_get_num_modified_propertiesPtr + .asFunction)>(); - /// Check if a set is valid. + /// True if an object notification indicates that the object was deleted. /// - /// @return True if the set is valid. - bool realm_set_is_valid( - ffi.Pointer arg0, + /// This function cannot fail. + bool realm_object_changes_is_deleted( + ffi.Pointer arg0, ) { - return _realm_set_is_valid( + return _realm_object_changes_is_deleted( arg0, ); } - late final _realm_set_is_validPtr = - _lookup)>>( - 'realm_set_is_valid'); - late final _realm_set_is_valid = _realm_set_is_validPtr - .asFunction)>(); + late final _realm_object_changes_is_deletedPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer)>>( + 'realm_object_changes_is_deleted'); + late final _realm_object_changes_is_deleted = + _realm_object_changes_is_deletedPtr + .asFunction)>(); - /// Assign a JSON formatted string to a Mixed property. Underlying structures will be created as needed + /// Create an object in a class without a primary key. /// - /// @param json_string The new value for the property. - /// @return True if no exception occurred. - bool realm_set_json( - ffi.Pointer arg0, + /// @return A non-NULL pointer if the object was created successfully. + ffi.Pointer realm_object_create( + ffi.Pointer arg0, int arg1, - ffi.Pointer json_string, ) { - return _realm_set_json( + return _realm_object_create( arg0, arg1, - json_string, ); } - late final _realm_set_jsonPtr = _lookup< + late final _realm_object_createPtr = _lookup< ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, realm_property_key_t, - ffi.Pointer)>>('realm_set_json'); - late final _realm_set_json = _realm_set_jsonPtr.asFunction< - bool Function(ffi.Pointer, int, ffi.Pointer)>(); + ffi.Pointer Function( + ffi.Pointer, realm_class_key_t)>>('realm_object_create'); + late final _realm_object_create = _realm_object_createPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, int)>(); - /// Create a collection in a given Mixed property. - ffi.Pointer realm_set_list( - ffi.Pointer arg0, + /// Create an object in a class with a primary key. Will not succeed if an + /// object with the given primary key value already exists. + /// + /// @return A non-NULL pointer if the object was created successfully. + ffi.Pointer realm_object_create_with_primary_key( + ffi.Pointer arg0, int arg1, + realm_value_t pk, ) { - return _realm_set_list( + return _realm_object_create_with_primary_key( arg0, arg1, + pk, ); } - late final _realm_set_listPtr = _lookup< + late final _realm_object_create_with_primary_keyPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - realm_property_key_t)>>('realm_set_list'); - late final _realm_set_list = _realm_set_listPtr.asFunction< - ffi.Pointer Function(ffi.Pointer, int)>(); + ffi.Pointer Function( + ffi.Pointer, + realm_class_key_t, + realm_value_t)>>('realm_object_create_with_primary_key'); + late final _realm_object_create_with_primary_key = + _realm_object_create_with_primary_keyPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, int, realm_value_t)>(); - /// Install the default logger - void realm_set_log_callback( - realm_log_func_t arg0, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, + /// Delete a realm object. + /// + /// Note: This does not call `realm_release()` on the `realm_object_t` instance. + /// + /// @return True if no exception occurred. + bool realm_object_delete( + ffi.Pointer arg0, ) { - return _realm_set_log_callback( + return _realm_object_delete( arg0, - userdata, - userdata_free, ); } - late final _realm_set_log_callbackPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(realm_log_func_t, ffi.Pointer, - realm_free_userdata_func_t)>>('realm_set_log_callback'); - late final _realm_set_log_callback = _realm_set_log_callbackPtr.asFunction< - void Function(realm_log_func_t, ffi.Pointer, - realm_free_userdata_func_t)>(); + late final _realm_object_deletePtr = _lookup< + ffi.NativeFunction)>>( + 'realm_object_delete'); + late final _realm_object_delete = _realm_object_deletePtr + .asFunction)>(); - void realm_set_log_level( - realm_log_level arg0, + /// Find all objects in class. + /// + /// Note: This is faster than running a query matching all objects (such as + /// "TRUEPREDICATE"). + /// + /// @return A non-NULL pointer if no exception was thrown. + ffi.Pointer realm_object_find_all( + ffi.Pointer arg0, + int arg1, ) { - return _realm_set_log_level( - arg0.value, + return _realm_object_find_all( + arg0, + arg1, ); } - late final _realm_set_log_levelPtr = - _lookup>( - 'realm_set_log_level'); - late final _realm_set_log_level = - _realm_set_log_levelPtr.asFunction(); + late final _realm_object_find_allPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + realm_class_key_t)>>('realm_object_find_all'); + late final _realm_object_find_all = _realm_object_find_allPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, int)>(); - /// Set the logging level for given category. Return the previous level. - realm_log_level realm_set_log_level_category( - ffi.Pointer arg0, - realm_log_level arg1, + /// Find an object with a particular primary key value. + /// + /// @param out_found A pointer to a boolean that will be set to true or false if + /// no error occurred. + /// @return A non-NULL pointer if the object was found and no exception occurred. + ffi.Pointer realm_object_find_with_primary_key( + ffi.Pointer arg0, + int arg1, + realm_value_t pk, + ffi.Pointer out_found, ) { - return realm_log_level.fromValue(_realm_set_log_level_category( + return _realm_object_find_with_primary_key( arg0, - arg1.value, - )); + arg1, + pk, + out_found, + ); } - late final _realm_set_log_level_categoryPtr = _lookup< + late final _realm_object_find_with_primary_keyPtr = _lookup< ffi.NativeFunction< - ffi.UnsignedInt Function(ffi.Pointer, - ffi.UnsignedInt)>>('realm_set_log_level_category'); - late final _realm_set_log_level_category = _realm_set_log_level_categoryPtr - .asFunction, int)>(); + ffi.Pointer Function( + ffi.Pointer, + realm_class_key_t, + realm_value_t, + ffi.Pointer)>>('realm_object_find_with_primary_key'); + late final _realm_object_find_with_primary_key = + _realm_object_find_with_primary_keyPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, int, + realm_value_t, ffi.Pointer)>(); - /// In a set of objects, delete all objects in the set and clear the set. In a - /// set of values, clear the set. - /// - /// @return True if no exception occurred. - bool realm_set_remove_all( - ffi.Pointer arg0, + /// Get an object from a thread-safe reference, potentially originating in a + /// different `realm_t` instance + ffi.Pointer realm_object_from_thread_safe_reference( + ffi.Pointer arg0, + ffi.Pointer arg1, ) { - return _realm_set_remove_all( + return _realm_object_from_thread_safe_reference( arg0, + arg1, ); } - late final _realm_set_remove_allPtr = - _lookup)>>( - 'realm_set_remove_all'); - late final _realm_set_remove_all = _realm_set_remove_allPtr - .asFunction)>(); + late final _realm_object_from_thread_safe_referencePtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer)>>( + 'realm_object_from_thread_safe_reference'); + late final _realm_object_from_thread_safe_reference = + _realm_object_from_thread_safe_referencePtr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer)>(); - /// Resolve the set in the context of a given Realm instance. - /// - /// This is equivalent to producing a thread-safe reference and resolving it in the frozen realm. - /// - /// If resolution is possible, a valid resolved object is produced at '*resolved*'. - /// If resolution is not possible, but no error occurs, '*resolved' is set to NULL - /// - /// @return true if no error occurred. - bool realm_set_resolve_in( - ffi.Pointer list, - ffi.Pointer target_realm, - ffi.Pointer> resolved, + /// Get the key for this object. + /// + /// This function cannot fail. + int realm_object_get_key( + ffi.Pointer object, ) { - return _realm_set_resolve_in( - list, - target_realm, - resolved, + return _realm_object_get_key( + object, ); } - late final _realm_set_resolve_inPtr = _lookup< + late final _realm_object_get_keyPtr = _lookup< ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer>)>>('realm_set_resolve_in'); - late final _realm_set_resolve_in = _realm_set_resolve_inPtr.asFunction< - bool Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer>)>(); + realm_object_key_t Function( + ffi.Pointer)>>('realm_object_get_key'); + late final _realm_object_get_key = _realm_object_get_keyPtr + .asFunction)>(); - /// Get the size of a set, in number of unique elements. - /// - /// This function may fail if the object owning the set has been deleted. + /// Create an object in a class with a primary key. If an object with the given + /// primary key value already exists, that object will be returned. /// - /// @param out_size Where to put the set size. May be NULL. - /// @return True if no exception occurred. - bool realm_set_size( - ffi.Pointer arg0, - ffi.Pointer out_size, + /// @return A non-NULL pointer if the object was found/created successfully. + ffi.Pointer realm_object_get_or_create_with_primary_key( + ffi.Pointer arg0, + int arg1, + realm_value_t pk, + ffi.Pointer did_create, ) { - return _realm_set_size( + return _realm_object_get_or_create_with_primary_key( arg0, - out_size, + arg1, + pk, + did_create, ); } - late final _realm_set_sizePtr = _lookup< + late final _realm_object_get_or_create_with_primary_keyPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + realm_class_key_t, realm_value_t, ffi.Pointer)>>( + 'realm_object_get_or_create_with_primary_key'); + late final _realm_object_get_or_create_with_primary_key = + _realm_object_get_or_create_with_primary_keyPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, int, + realm_value_t, ffi.Pointer)>(); + + /// Get the parent object for the object passed as argument. Only works for embedded objects. + /// @return true, if no errors occurred. + bool realm_object_get_parent( + ffi.Pointer object, + ffi.Pointer> parent, + ffi.Pointer class_key, + ) { + return _realm_object_get_parent( + object, + parent, + class_key, + ); + } + + late final _realm_object_get_parentPtr = _lookup< ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, - ffi.Pointer)>>('realm_set_size'); - late final _realm_set_size = _realm_set_sizePtr.asFunction< - bool Function(ffi.Pointer, ffi.Pointer)>(); + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer>, + ffi.Pointer)>>('realm_object_get_parent'); + late final _realm_object_get_parent = _realm_object_get_parentPtr.asFunction< + bool Function( + ffi.Pointer, + ffi.Pointer>, + ffi.Pointer)>(); - /// Convert a set to results. + /// Get the table for this object. /// - /// @return A non-null pointer if no exception occurred. - ffi.Pointer realm_set_to_results( - ffi.Pointer arg0, + /// This function cannot fail. + int realm_object_get_table( + ffi.Pointer object, ) { - return _realm_set_to_results( - arg0, + return _realm_object_get_table( + object, ); } - late final _realm_set_to_resultsPtr = _lookup< + late final _realm_object_get_tablePtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_set_to_results'); - late final _realm_set_to_results = _realm_set_to_resultsPtr.asFunction< - ffi.Pointer Function(ffi.Pointer)>(); + realm_class_key_t Function( + ffi.Pointer)>>('realm_object_get_table'); + late final _realm_object_get_table = _realm_object_get_tablePtr + .asFunction)>(); - /// Set the value for a property. + /// True if this object still exists in the realm. /// - /// @param new_value The new value for the property. - /// @param is_default True if this property is being set as part of setting the - /// default values for a new object. This has no effect in - /// non-sync'ed realms. - /// @return True if no exception occurred. - bool realm_set_value( + /// This function cannot fail. + bool realm_object_is_valid( ffi.Pointer arg0, - int arg1, - realm_value_t new_value, - bool is_default, ) { - return _realm_set_value( + return _realm_object_is_valid( arg0, - arg1, - new_value, - is_default, ); } - late final _realm_set_valuePtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, realm_property_key_t, - realm_value_t, ffi.Bool)>>('realm_set_value'); - late final _realm_set_value = _realm_set_valuePtr.asFunction< - bool Function(ffi.Pointer, int, realm_value_t, bool)>(); + late final _realm_object_is_validPtr = _lookup< + ffi.NativeFunction)>>( + 'realm_object_is_valid'); + late final _realm_object_is_valid = _realm_object_is_validPtr + .asFunction)>(); - /// Set the values for several properties. - /// - /// This is provided as an alternative to calling `realm_get_value()` multiple - /// times in a row, which is particularly useful for language runtimes where - /// crossing the native bridge is comparatively expensive. In addition, it - /// eliminates some parameter validation that would otherwise be repeated for - /// each call. - /// - /// Example use cases: - /// - /// - Initializing a new object with default values. - /// - Deserializing some in-memory structure into a realm object. + /// Resolve the Realm object in the provided Realm. /// - /// This operation is "atomic"; if an exception occurs due to invalid input (such - /// as type mismatch, nullability mismatch, etc.), the object will remain - /// unmodified. + /// This is equivalent to producing a thread-safe reference and resolving it in the target realm. /// - /// @param num_values The number of elements in @a properties and @a values. - /// @param properties The keys of the properties to set. May not be NULL. - /// @param values The values to assign to the properties. May not be NULL. - /// @param is_default True if the properties are being set as part of setting - /// default values for a new object. This has no effect in - /// non-sync'ed realms. - /// @return True if no exception occurred. - bool realm_set_values( - ffi.Pointer arg0, - int num_values, - ffi.Pointer properties, - ffi.Pointer values, - bool is_default, + /// If the object can be resolved in the target realm, '*resolved' points to the new object + /// If the object cannot be resolved in the target realm, '*resolved' will be null. + /// @return True if no exception occurred (except exceptions that may normally occur if resolution fails) + bool realm_object_resolve_in( + ffi.Pointer live_object, + ffi.Pointer target_realm, + ffi.Pointer> resolved, ) { - return _realm_set_values( - arg0, - num_values, - properties, - values, - is_default, + return _realm_object_resolve_in( + live_object, + target_realm, + resolved, ); } - late final _realm_set_valuesPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Size, - ffi.Pointer, - ffi.Pointer, - ffi.Bool)>>('realm_set_values'); - late final _realm_set_values = _realm_set_valuesPtr.asFunction< - bool Function( - ffi.Pointer, - int, - ffi.Pointer, - ffi.Pointer, - bool)>(); + late final _realm_object_resolve_inPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>>( + 'realm_object_resolve_in'); + late final _realm_object_resolve_in = _realm_object_resolve_inPtr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer>)>(); - void realm_sync_client_config_set_connect_timeout( - ffi.Pointer arg0, - int arg1, + /// Serializes an object to json and returns it as string. Serializes a single level of properties only. + /// + /// @return a json-serialized representation of the object. + ffi.Pointer realm_object_to_string( + ffi.Pointer arg0, ) { - return _realm_sync_client_config_set_connect_timeout( + return _realm_object_to_string( arg0, - arg1, ); } - late final _realm_sync_client_config_set_connect_timeoutPtr = _lookup< + late final _realm_object_to_stringPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Uint64)>>('realm_sync_client_config_set_connect_timeout'); - late final _realm_sync_client_config_set_connect_timeout = - _realm_sync_client_config_set_connect_timeoutPtr.asFunction< - void Function(ffi.Pointer, int)>(); + ffi.Pointer Function( + ffi.Pointer)>>('realm_object_to_string'); + late final _realm_object_to_string = _realm_object_to_stringPtr.asFunction< + ffi.Pointer Function(ffi.Pointer)>(); - void realm_sync_client_config_set_connection_linger_time( - ffi.Pointer arg0, - int arg1, + /// Open a Realm file. + /// + /// @param config Realm configuration. If the Realm is already opened on another + /// thread, validate that the given configuration is compatible + /// with the existing one. + /// @return If successful, the Realm object. Otherwise, NULL. + ffi.Pointer realm_open( + ffi.Pointer config, ) { - return _realm_sync_client_config_set_connection_linger_time( - arg0, - arg1, + return _realm_open( + config, ); } - late final _realm_sync_client_config_set_connection_linger_timePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, ffi.Uint64)>>( - 'realm_sync_client_config_set_connection_linger_time'); - late final _realm_sync_client_config_set_connection_linger_time = - _realm_sync_client_config_set_connection_linger_timePtr.asFunction< - void Function(ffi.Pointer, int)>(); - - void realm_sync_client_config_set_default_binding_thread_observer( - ffi.Pointer config, - realm_on_object_store_thread_callback_t on_thread_create, - realm_on_object_store_thread_callback_t on_thread_destroy, - realm_on_object_store_error_callback_t on_error, - ffi.Pointer user_data, - realm_free_userdata_func_t free_userdata, - ) { - return _realm_sync_client_config_set_default_binding_thread_observer( - config, - on_thread_create, - on_thread_destroy, - on_error, - user_data, - free_userdata, - ); - } - - late final _realm_sync_client_config_set_default_binding_thread_observerPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - realm_on_object_store_thread_callback_t, - realm_on_object_store_thread_callback_t, - realm_on_object_store_error_callback_t, - ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_sync_client_config_set_default_binding_thread_observer'); - late final _realm_sync_client_config_set_default_binding_thread_observer = - _realm_sync_client_config_set_default_binding_thread_observerPtr - .asFunction< - void Function( - ffi.Pointer, - realm_on_object_store_thread_callback_t, - realm_on_object_store_thread_callback_t, - realm_on_object_store_error_callback_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); + late final _realm_openPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer)>>('realm_open'); + late final _realm_open = _realm_openPtr + .asFunction Function(ffi.Pointer)>(); - void realm_sync_client_config_set_fast_reconnect_limit( - ffi.Pointer arg0, - int arg1, + /// Parse a query string and append it to an existing query via logical &&. + /// The query string applies to the same table and Realm as the existing query. + /// + /// If the query failed to parse, the parser error is available from + /// `realm_get_last_error()`. + /// + /// @param query_string A zero-terminated string in the Realm Query Language, + /// optionally containing argument placeholders (`$0`, `$1`, + /// etc.). + /// @param num_args The number of arguments for this query. + /// @param args A pointer to a list of argument values. + /// @return A non-null pointer if the query was successfully parsed and no + /// exception occurred. + ffi.Pointer realm_query_append_query( + ffi.Pointer arg0, + ffi.Pointer query_string, + int num_args, + ffi.Pointer args, ) { - return _realm_sync_client_config_set_fast_reconnect_limit( + return _realm_query_append_query( arg0, - arg1, + query_string, + num_args, + args, ); } - late final _realm_sync_client_config_set_fast_reconnect_limitPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, ffi.Uint64)>>( - 'realm_sync_client_config_set_fast_reconnect_limit'); - late final _realm_sync_client_config_set_fast_reconnect_limit = - _realm_sync_client_config_set_fast_reconnect_limitPtr.asFunction< - void Function(ffi.Pointer, int)>(); - - void realm_sync_client_config_set_max_resumption_delay_interval( - ffi.Pointer arg0, - int arg1, + late final _realm_query_append_queryPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Size, + ffi.Pointer)>>('realm_query_append_query'); + late final _realm_query_append_query = + _realm_query_append_queryPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, int, ffi.Pointer)>(); + + /// Count the number of objects found by this query. + bool realm_query_count( + ffi.Pointer arg0, + ffi.Pointer out_count, ) { - return _realm_sync_client_config_set_max_resumption_delay_interval( + return _realm_query_count( arg0, - arg1, + out_count, ); } - late final _realm_sync_client_config_set_max_resumption_delay_intervalPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, ffi.Uint64)>>( - 'realm_sync_client_config_set_max_resumption_delay_interval'); - late final _realm_sync_client_config_set_max_resumption_delay_interval = - _realm_sync_client_config_set_max_resumption_delay_intervalPtr.asFunction< - void Function(ffi.Pointer, int)>(); + late final _realm_query_countPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, + ffi.Pointer)>>('realm_query_count'); + late final _realm_query_count = _realm_query_countPtr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer)>(); - void realm_sync_client_config_set_multiplex_sessions( - ffi.Pointer arg0, - bool arg1, + /// Delete all objects matched by a query. + bool realm_query_delete_all( + ffi.Pointer arg0, ) { - return _realm_sync_client_config_set_multiplex_sessions( + return _realm_query_delete_all( arg0, - arg1, ); } - late final _realm_sync_client_config_set_multiplex_sessionsPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Bool)>>('realm_sync_client_config_set_multiplex_sessions'); - late final _realm_sync_client_config_set_multiplex_sessions = - _realm_sync_client_config_set_multiplex_sessionsPtr.asFunction< - void Function(ffi.Pointer, bool)>(); + late final _realm_query_delete_allPtr = _lookup< + ffi.NativeFunction)>>( + 'realm_query_delete_all'); + late final _realm_query_delete_all = _realm_query_delete_allPtr + .asFunction)>(); - void realm_sync_client_config_set_ping_keepalive_period( - ffi.Pointer arg0, - int arg1, + /// Produce a results object for this query. + /// + /// Note: This does not actually run the query until the results are accessed in + /// some way. + /// + /// @return A non-null pointer if no exception occurred. + ffi.Pointer realm_query_find_all( + ffi.Pointer arg0, ) { - return _realm_sync_client_config_set_ping_keepalive_period( + return _realm_query_find_all( arg0, - arg1, ); } - late final _realm_sync_client_config_set_ping_keepalive_periodPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, ffi.Uint64)>>( - 'realm_sync_client_config_set_ping_keepalive_period'); - late final _realm_sync_client_config_set_ping_keepalive_period = - _realm_sync_client_config_set_ping_keepalive_periodPtr.asFunction< - void Function(ffi.Pointer, int)>(); - - void realm_sync_client_config_set_pong_keepalive_timeout( - ffi.Pointer arg0, - int arg1, + late final _realm_query_find_allPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer)>>('realm_query_find_all'); + late final _realm_query_find_all = _realm_query_find_allPtr.asFunction< + ffi.Pointer Function(ffi.Pointer)>(); + + /// Return the first object matched by this query. + /// + /// Note: This function can only produce objects, not values. Use the + /// `realm_results_t` returned by `realm_query_find_all()` to retrieve + /// values from a list of primitive values. + /// + /// @param out_value Where to write the result, if any object matched the query. + /// May be NULL. + /// @param out_found Where to write whether the object was found. May be NULL. + /// @return True if no exception occurred. + bool realm_query_find_first( + ffi.Pointer arg0, + ffi.Pointer out_value, + ffi.Pointer out_found, ) { - return _realm_sync_client_config_set_pong_keepalive_timeout( + return _realm_query_find_first( arg0, - arg1, + out_value, + out_found, ); } - late final _realm_sync_client_config_set_pong_keepalive_timeoutPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, ffi.Uint64)>>( - 'realm_sync_client_config_set_pong_keepalive_timeout'); - late final _realm_sync_client_config_set_pong_keepalive_timeout = - _realm_sync_client_config_set_pong_keepalive_timeoutPtr.asFunction< - void Function(ffi.Pointer, int)>(); + late final _realm_query_find_firstPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('realm_query_find_first'); + late final _realm_query_find_first = _realm_query_find_firstPtr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); - void realm_sync_client_config_set_reconnect_mode( - ffi.Pointer arg0, - realm_sync_client_reconnect_mode arg1, + /// Get textual representation of query + /// + /// @return a string containing the description. The string memory is managed by the query object. + ffi.Pointer realm_query_get_description( + ffi.Pointer arg0, ) { - return _realm_sync_client_config_set_reconnect_mode( + return _realm_query_get_description( arg0, - arg1.value, ); } - late final _realm_sync_client_config_set_reconnect_modePtr = _lookup< + late final _realm_query_get_descriptionPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.UnsignedInt)>>('realm_sync_client_config_set_reconnect_mode'); - late final _realm_sync_client_config_set_reconnect_mode = - _realm_sync_client_config_set_reconnect_modePtr.asFunction< - void Function(ffi.Pointer, int)>(); + ffi.Pointer Function( + ffi.Pointer)>>('realm_query_get_description'); + late final _realm_query_get_description = _realm_query_get_descriptionPtr + .asFunction Function(ffi.Pointer)>(); - void realm_sync_client_config_set_resumption_delay_backoff_multiplier( - ffi.Pointer arg0, - int arg1, + /// Parse a query string and bind it to a table. + /// + /// If the query failed to parse, the parser error is available from + /// `realm_get_last_error()`. + /// + /// @param target_table The table on which to run this query. + /// @param query_string A zero-terminated string in the Realm Query Language, + /// optionally containing argument placeholders (`$0`, `$1`, + /// etc.). + /// @param num_args The number of arguments for this query. + /// @param args A pointer to a list of argument values. + /// @return A non-null pointer if the query was successfully parsed and no + /// exception occurred. + ffi.Pointer realm_query_parse( + ffi.Pointer arg0, + int target_table, + ffi.Pointer query_string, + int num_args, + ffi.Pointer args, ) { - return _realm_sync_client_config_set_resumption_delay_backoff_multiplier( + return _realm_query_parse( arg0, - arg1, + target_table, + query_string, + num_args, + args, ); } - late final _realm_sync_client_config_set_resumption_delay_backoff_multiplierPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, ffi.Int)>>( - 'realm_sync_client_config_set_resumption_delay_backoff_multiplier'); - late final _realm_sync_client_config_set_resumption_delay_backoff_multiplier = - _realm_sync_client_config_set_resumption_delay_backoff_multiplierPtr - .asFunction< - void Function(ffi.Pointer, int)>(); + late final _realm_query_parsePtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + realm_class_key_t, + ffi.Pointer, + ffi.Size, + ffi.Pointer)>>('realm_query_parse'); + late final _realm_query_parse = _realm_query_parsePtr.asFunction< + ffi.Pointer Function(ffi.Pointer, int, + ffi.Pointer, int, ffi.Pointer)>(); - void realm_sync_client_config_set_resumption_delay_interval( - ffi.Pointer arg0, - int arg1, + /// Parse a query string and bind it to a list. + /// + /// If the query failed to parse, the parser error is available from + /// `realm_get_last_error()`. + /// + /// @param target_list The list on which to run this query. + /// @param query_string A string in the Realm Query Language, optionally + /// containing argument placeholders (`$0`, `$1`, etc.). + /// @param num_args The number of arguments for this query. + /// @param args A pointer to a list of argument values. + /// @return A non-null pointer if the query was successfully parsed and no + /// exception occurred. + ffi.Pointer realm_query_parse_for_list( + ffi.Pointer target_list, + ffi.Pointer query_string, + int num_args, + ffi.Pointer args, ) { - return _realm_sync_client_config_set_resumption_delay_interval( - arg0, - arg1, + return _realm_query_parse_for_list( + target_list, + query_string, + num_args, + args, ); } - late final _realm_sync_client_config_set_resumption_delay_intervalPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, ffi.Uint64)>>( - 'realm_sync_client_config_set_resumption_delay_interval'); - late final _realm_sync_client_config_set_resumption_delay_interval = - _realm_sync_client_config_set_resumption_delay_intervalPtr.asFunction< - void Function(ffi.Pointer, int)>(); + late final _realm_query_parse_for_listPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Size, + ffi.Pointer)>>('realm_query_parse_for_list'); + late final _realm_query_parse_for_list = + _realm_query_parse_for_listPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, int, ffi.Pointer)>(); - void realm_sync_client_config_set_sync_socket( - ffi.Pointer arg0, - ffi.Pointer arg1, + /// Parse a query string and bind it to another query result. + /// + /// If the query failed to parse, the parser error is available from + /// `realm_get_last_error()`. + /// + /// @param target_results The results on which to run this query. + /// @param query_string A zero-terminated string in the Realm Query Language, + /// optionally containing argument placeholders (`$0`, `$1`, + /// etc.). + /// @param num_args The number of arguments for this query. + /// @param args A pointer to a list of argument values. + /// @return A non-null pointer if the query was successfully parsed and no + /// exception occurred. + ffi.Pointer realm_query_parse_for_results( + ffi.Pointer target_results, + ffi.Pointer query_string, + int num_args, + ffi.Pointer args, ) { - return _realm_sync_client_config_set_sync_socket( - arg0, - arg1, + return _realm_query_parse_for_results( + target_results, + query_string, + num_args, + args, ); } - late final _realm_sync_client_config_set_sync_socketPtr = _lookup< + late final _realm_query_parse_for_resultsPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Pointer)>>( - 'realm_sync_client_config_set_sync_socket'); - late final _realm_sync_client_config_set_sync_socket = - _realm_sync_client_config_set_sync_socketPtr.asFunction< - void Function(ffi.Pointer, - ffi.Pointer)>(); - - void realm_sync_client_config_set_user_agent_application_info( - ffi.Pointer arg0, - ffi.Pointer arg1, + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Size, + ffi.Pointer)>>( + 'realm_query_parse_for_results'); + late final _realm_query_parse_for_results = + _realm_query_parse_for_resultsPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, int, ffi.Pointer)>(); + + /// Parse a query string and bind it to a set. + /// + /// If the query failed to parse, the parser error is available from + /// `realm_get_last_error()`. + /// + /// @param target_set The set on which to run this query. + /// @param query_string A string in the Realm Query Language, optionally + /// containing argument placeholders (`$0`, `$1`, etc.). + /// @param num_args The number of arguments for this query. + /// @param args A pointer to a list of argument values. + /// @return A non-null pointer if the query was successfully parsed and no + /// exception occurred. + ffi.Pointer realm_query_parse_for_set( + ffi.Pointer target_set, + ffi.Pointer query_string, + int num_args, + ffi.Pointer args, ) { - return _realm_sync_client_config_set_user_agent_application_info( - arg0, - arg1, + return _realm_query_parse_for_set( + target_set, + query_string, + num_args, + args, ); } - late final _realm_sync_client_config_set_user_agent_application_infoPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Pointer)>>( - 'realm_sync_client_config_set_user_agent_application_info'); - late final _realm_sync_client_config_set_user_agent_application_info = - _realm_sync_client_config_set_user_agent_application_infoPtr.asFunction< - void Function(ffi.Pointer, - ffi.Pointer)>(); + late final _realm_query_parse_for_setPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Size, + ffi.Pointer)>>('realm_query_parse_for_set'); + late final _realm_query_parse_for_set = + _realm_query_parse_for_setPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, int, ffi.Pointer)>(); - void realm_sync_client_config_set_user_agent_binding_info( - ffi.Pointer arg0, - ffi.Pointer arg1, + /// Refresh the view of the realm file. + /// + /// If another process or thread has made changes to the realm file, this causes + /// those changes to become visible in this realm instance. + /// + /// This calls `advance_read()` at the Core layer. + /// + /// @return True if no exceptions are thrown, false otherwise. + bool realm_refresh( + ffi.Pointer arg0, + ffi.Pointer did_refresh, ) { - return _realm_sync_client_config_set_user_agent_binding_info( + return _realm_refresh( arg0, - arg1, + did_refresh, ); } - late final _realm_sync_client_config_set_user_agent_binding_infoPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Pointer)>>( - 'realm_sync_client_config_set_user_agent_binding_info'); - late final _realm_sync_client_config_set_user_agent_binding_info = - _realm_sync_client_config_set_user_agent_binding_infoPtr.asFunction< - void Function(ffi.Pointer, - ffi.Pointer)>(); + late final _realm_refreshPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, ffi.Pointer)>>('realm_refresh'); + late final _realm_refresh = _realm_refreshPtr + .asFunction, ffi.Pointer)>(); - ffi.Pointer realm_sync_config_new( - ffi.Pointer arg0, - ffi.Pointer partition_value, + /// In case of exception thrown in user code callbacks, this api will allow the sdk to store the user code exception + /// and retrieve a it later via realm_get_last_error. + /// Most importantly the SDK is responsible to handle the memory pointed by user_code_error. + /// @param usercode_error pointer representing whatever object the SDK treats as exception/error. + void realm_register_user_code_callback_error( + ffi.Pointer usercode_error, ) { - return _realm_sync_config_new( - arg0, - partition_value, + return _realm_register_user_code_callback_error( + usercode_error, ); } - late final _realm_sync_config_newPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer)>>('realm_sync_config_new'); - late final _realm_sync_config_new = _realm_sync_config_newPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, ffi.Pointer)>(); + late final _realm_register_user_code_callback_errorPtr = + _lookup)>>( + 'realm_register_user_code_callback_error'); + late final _realm_register_user_code_callback_error = + _realm_register_user_code_callback_errorPtr + .asFunction)>(); - void realm_sync_config_set_after_client_reset_handler( - ffi.Pointer arg0, - realm_sync_after_client_reset_func_t arg1, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, + /// Free any Realm C Wrapper object. + /// + /// Note: Any pointer returned from a library function is owned by the caller. + /// The caller is responsible for calling `realm_release()`. The only + /// exception from this is C++ bridge functions that return `void*`, with + /// the prefix `_realm`. + /// + /// Note: C++ destructors are typically `noexcept`, so it is likely that an + /// exception will crash the process. + /// + /// @param ptr A pointer to a Realm C Wrapper object. May be NULL. + void realm_release( + ffi.Pointer ptr, ) { - return _realm_sync_config_set_after_client_reset_handler( - arg0, - arg1, - userdata, - userdata_free, + return _realm_release( + ptr, ); } - late final _realm_sync_config_set_after_client_reset_handlerPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - realm_sync_after_client_reset_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_sync_config_set_after_client_reset_handler'); - late final _realm_sync_config_set_after_client_reset_handler = - _realm_sync_config_set_after_client_reset_handlerPtr.asFunction< - void Function( - ffi.Pointer, - realm_sync_after_client_reset_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); + late final _realm_releasePtr = + _lookup)>>( + 'realm_release'); + late final _realm_release = + _realm_releasePtr.asFunction)>(); - /// DEPRECATED - Will be removed in a future release - void realm_sync_config_set_authorization_header_name( - ffi.Pointer arg0, - ffi.Pointer arg1, + /// Find and delete the table passed as parementer for the realm instance passed to this function. + /// @param table_name for the table the user wants to delete + /// @param table_deleted in order to indicate if the table was actually deleted from realm + /// @return true if no error has occurred, false otherwise + bool realm_remove_table( + ffi.Pointer arg0, + ffi.Pointer table_name, + ffi.Pointer table_deleted, ) { - return _realm_sync_config_set_authorization_header_name( + return _realm_remove_table( arg0, - arg1, + table_name, + table_deleted, ); } - late final _realm_sync_config_set_authorization_header_namePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, ffi.Pointer)>>( - 'realm_sync_config_set_authorization_header_name'); - late final _realm_sync_config_set_authorization_header_name = - _realm_sync_config_set_authorization_header_namePtr.asFunction< - void Function( - ffi.Pointer, ffi.Pointer)>(); + late final _realm_remove_tablePtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('realm_remove_table'); + late final _realm_remove_table = _realm_remove_tablePtr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); - void realm_sync_config_set_before_client_reset_handler( - ffi.Pointer arg0, - realm_sync_before_client_reset_func_t arg1, + ffi.Pointer + realm_results_add_notification_callback( + ffi.Pointer arg0, ffi.Pointer userdata, realm_free_userdata_func_t userdata_free, + ffi.Pointer key_path_array, + realm_on_collection_change_func_t arg4, ) { - return _realm_sync_config_set_before_client_reset_handler( + return _realm_results_add_notification_callback( arg0, - arg1, userdata, userdata_free, + key_path_array, + arg4, ); } - late final _realm_sync_config_set_before_client_reset_handlerPtr = _lookup< + late final _realm_results_add_notification_callbackPtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - realm_sync_before_client_reset_func_t, + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_sync_config_set_before_client_reset_handler'); - late final _realm_sync_config_set_before_client_reset_handler = - _realm_sync_config_set_before_client_reset_handlerPtr.asFunction< - void Function( - ffi.Pointer, - realm_sync_before_client_reset_func_t, + realm_free_userdata_func_t, + ffi.Pointer, + realm_on_collection_change_func_t)>>( + 'realm_results_add_notification_callback'); + late final _realm_results_add_notification_callback = + _realm_results_add_notification_callbackPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, - realm_free_userdata_func_t)>(); - - void realm_sync_config_set_cancel_waits_on_nonfatal_error( - ffi.Pointer arg0, - bool arg1, - ) { - return _realm_sync_config_set_cancel_waits_on_nonfatal_error( - arg0, - arg1, - ); - } + realm_free_userdata_func_t, + ffi.Pointer, + realm_on_collection_change_func_t)>(); - late final _realm_sync_config_set_cancel_waits_on_nonfatal_errorPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Bool)>>( - 'realm_sync_config_set_cancel_waits_on_nonfatal_error'); - late final _realm_sync_config_set_cancel_waits_on_nonfatal_error = - _realm_sync_config_set_cancel_waits_on_nonfatal_errorPtr - .asFunction, bool)>(); - - /// DEPRECATED - Will be removed in a future release - void realm_sync_config_set_client_validate_ssl( - ffi.Pointer arg0, - bool arg1, + /// Compute the average value of a property in the results. + /// + /// Note: For numeric columns, the average is always converted to double. + /// + /// @param out_average Where to write the result. + /// @param out_found Set to true if there are matching rows. + /// @return True if no exception occurred. + bool realm_results_average( + ffi.Pointer arg0, + int arg1, + ffi.Pointer out_average, + ffi.Pointer out_found, ) { - return _realm_sync_config_set_client_validate_ssl( + return _realm_results_average( arg0, arg1, + out_average, + out_found, ); } - late final _realm_sync_config_set_client_validate_sslPtr = _lookup< + late final _realm_results_averagePtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Bool)>>('realm_sync_config_set_client_validate_ssl'); - late final _realm_sync_config_set_client_validate_ssl = - _realm_sync_config_set_client_validate_sslPtr - .asFunction, bool)>(); + ffi.Bool Function( + ffi.Pointer, + realm_property_key_t, + ffi.Pointer, + ffi.Pointer)>>('realm_results_average'); + late final _realm_results_average = _realm_results_averagePtr.asFunction< + bool Function(ffi.Pointer, int, + ffi.Pointer, ffi.Pointer)>(); - /// DEPRECATED - Will be removed in a future release - void realm_sync_config_set_custom_http_header( - ffi.Pointer arg0, - ffi.Pointer name, - ffi.Pointer value, + /// Count the number of results. + /// + /// If the result is "live" (not a snapshot), this may rerun the query if things + /// have changed. + /// + /// @return True if no exception occurred. + bool realm_results_count( + ffi.Pointer arg0, + ffi.Pointer out_count, ) { - return _realm_sync_config_set_custom_http_header( + return _realm_results_count( arg0, - name, - value, + out_count, ); } - late final _realm_sync_config_set_custom_http_headerPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>>( - 'realm_sync_config_set_custom_http_header'); - late final _realm_sync_config_set_custom_http_header = - _realm_sync_config_set_custom_http_headerPtr.asFunction< - void Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>(); + late final _realm_results_countPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, + ffi.Pointer)>>('realm_results_count'); + late final _realm_results_count = _realm_results_countPtr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer)>(); - void realm_sync_config_set_error_handler( - ffi.Pointer arg0, - realm_sync_error_handler_func_t arg1, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, + /// Delete all objects in the result. + /// + /// If the result if "live" (not a snapshot), this may rerun the query if things + /// have changed. + /// + /// @return True if no exception occurred. + bool realm_results_delete_all( + ffi.Pointer arg0, ) { - return _realm_sync_config_set_error_handler( + return _realm_results_delete_all( arg0, - arg1, - userdata, - userdata_free, ); } - late final _realm_sync_config_set_error_handlerPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - realm_sync_error_handler_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_sync_config_set_error_handler'); - late final _realm_sync_config_set_error_handler = - _realm_sync_config_set_error_handlerPtr.asFunction< - void Function( - ffi.Pointer, - realm_sync_error_handler_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); + late final _realm_results_delete_allPtr = _lookup< + ffi.NativeFunction)>>( + 'realm_results_delete_all'); + late final _realm_results_delete_all = _realm_results_delete_allPtr + .asFunction)>(); - void realm_sync_config_set_initial_subscription_handler( - ffi.Pointer arg0, - realm_async_open_task_init_subscription_func_t arg1, - bool rerun_on_open, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, + /// Create a new results object by removing duplicates + /// + /// @param distinct_string Specifies a distinct condition. It has the format + /// ["," ]* + /// ::= ["." ]* + /// @return A non-null pointer if no exception occurred. + ffi.Pointer realm_results_distinct( + ffi.Pointer results, + ffi.Pointer distinct_string, ) { - return _realm_sync_config_set_initial_subscription_handler( - arg0, - arg1, - rerun_on_open, - userdata, - userdata_free, + return _realm_results_distinct( + results, + distinct_string, ); } - late final _realm_sync_config_set_initial_subscription_handlerPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - realm_async_open_task_init_subscription_func_t, - ffi.Bool, - ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_sync_config_set_initial_subscription_handler'); - late final _realm_sync_config_set_initial_subscription_handler = - _realm_sync_config_set_initial_subscription_handlerPtr.asFunction< - void Function( - ffi.Pointer, - realm_async_open_task_init_subscription_func_t, - bool, - ffi.Pointer, - realm_free_userdata_func_t)>(); + late final _realm_results_distinctPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer)>>('realm_results_distinct'); + late final _realm_results_distinct = _realm_results_distinctPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); - void realm_sync_config_set_recovery_directory_path( - ffi.Pointer arg0, - ffi.Pointer arg1, + /// Create a new results object by further filtering existing result. + /// + /// @return A non-null pointer if no exception occurred. + ffi.Pointer realm_results_filter( + ffi.Pointer arg0, + ffi.Pointer arg1, ) { - return _realm_sync_config_set_recovery_directory_path( + return _realm_results_filter( arg0, arg1, ); } - late final _realm_sync_config_set_recovery_directory_pathPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, ffi.Pointer)>>( - 'realm_sync_config_set_recovery_directory_path'); - late final _realm_sync_config_set_recovery_directory_path = - _realm_sync_config_set_recovery_directory_pathPtr.asFunction< - void Function( - ffi.Pointer, ffi.Pointer)>(); - - void realm_sync_config_set_resync_mode( - ffi.Pointer arg0, - realm_sync_session_resync_mode arg1, - ) { - return _realm_sync_config_set_resync_mode( - arg0, - arg1.value, - ); - } - - late final _realm_sync_config_set_resync_modePtr = _lookup< + late final _realm_results_filterPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.UnsignedInt)>>('realm_sync_config_set_resync_mode'); - late final _realm_sync_config_set_resync_mode = - _realm_sync_config_set_resync_modePtr - .asFunction, int)>(); + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer)>>('realm_results_filter'); + late final _realm_results_filter = _realm_results_filterPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); - void realm_sync_config_set_session_stop_policy( - ffi.Pointer arg0, - realm_sync_session_stop_policy arg1, + /// Find the index for the value passed as parameter inside realm results pointer passed a input parameter. + /// @param value the value to find inside the realm results + /// @param out_index the index where the object has been found, or realm::not_found + /// @param out_found boolean indicating if the value has been found or not + /// @return true if no error occurred, false otherwise + bool realm_results_find( + ffi.Pointer arg0, + ffi.Pointer value, + ffi.Pointer out_index, + ffi.Pointer out_found, ) { - return _realm_sync_config_set_session_stop_policy( + return _realm_results_find( arg0, - arg1.value, + value, + out_index, + out_found, ); } - late final _realm_sync_config_set_session_stop_policyPtr = _lookup< + late final _realm_results_findPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.UnsignedInt)>>('realm_sync_config_set_session_stop_policy'); - late final _realm_sync_config_set_session_stop_policy = - _realm_sync_config_set_session_stop_policyPtr - .asFunction, int)>(); + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('realm_results_find'); + late final _realm_results_find = _realm_results_findPtr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); - /// DEPRECATED - Will be removed in a future release - void realm_sync_config_set_ssl_trust_certificate_path( - ffi.Pointer arg0, - ffi.Pointer arg1, + /// Find the index for the realm object passed as parameter inside realm results pointer passed a input parameter. + /// @param value the value to find inside the realm results + /// @param out_index the index where the object has been found, or realm::not_found + /// @param out_found boolean indicating if the value has been found or not + /// @return true if no error occurred, false otherwise + bool realm_results_find_object( + ffi.Pointer arg0, + ffi.Pointer value, + ffi.Pointer out_index, + ffi.Pointer out_found, ) { - return _realm_sync_config_set_ssl_trust_certificate_path( + return _realm_results_find_object( arg0, - arg1, + value, + out_index, + out_found, ); } - late final _realm_sync_config_set_ssl_trust_certificate_pathPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, ffi.Pointer)>>( - 'realm_sync_config_set_ssl_trust_certificate_path'); - late final _realm_sync_config_set_ssl_trust_certificate_path = - _realm_sync_config_set_ssl_trust_certificate_pathPtr.asFunction< - void Function( - ffi.Pointer, ffi.Pointer)>(); + late final _realm_results_find_objectPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('realm_results_find_object'); + late final _realm_results_find_object = + _realm_results_find_objectPtr.asFunction< + bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); - /// DEPRECATED - Will be removed in a future release - void realm_sync_config_set_ssl_verify_callback( - ffi.Pointer arg0, - realm_sync_ssl_verify_func_t arg1, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, + /// Get an results object from a thread-safe reference, potentially originating + /// in a different `realm_t` instance + ffi.Pointer realm_results_from_thread_safe_reference( + ffi.Pointer arg0, + ffi.Pointer arg1, ) { - return _realm_sync_config_set_ssl_verify_callback( + return _realm_results_from_thread_safe_reference( arg0, arg1, - userdata, - userdata_free, ); } - late final _realm_sync_config_set_ssl_verify_callbackPtr = _lookup< + late final _realm_results_from_thread_safe_referencePtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - realm_sync_ssl_verify_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_sync_config_set_ssl_verify_callback'); - late final _realm_sync_config_set_ssl_verify_callback = - _realm_sync_config_set_ssl_verify_callbackPtr.asFunction< - void Function( - ffi.Pointer, - realm_sync_ssl_verify_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer)>>( + 'realm_results_from_thread_safe_reference'); + late final _realm_results_from_thread_safe_reference = + _realm_results_from_thread_safe_referencePtr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer)>(); - /// Find subscription by name passed as parameter - /// @return a pointer to the subscription or nullptr if not found - ffi.Pointer - realm_sync_find_subscription_by_name( - ffi.Pointer arg0, - ffi.Pointer name, + /// Get the matching element at @a index in the results. + /// + /// If the result is "live" (not a snapshot), this may rerun the query if things + /// have changed. + /// + /// Note: The bound returned by `realm_results_count()` for a non-snapshot result + /// is not a reliable way to iterate over elements in the result, because + /// the result will be live-updated if changes are made in each iteration + /// that may change the number of query results or even change the + /// ordering. In other words, this method should probably only be used with + /// snapshot results. + /// + /// @return True if no exception occurred (including out-of-bounds). + bool realm_results_get( + ffi.Pointer arg0, + int index, + ffi.Pointer out_value, ) { - return _realm_sync_find_subscription_by_name( + return _realm_results_get( arg0, - name, + index, + out_value, ); } - late final _realm_sync_find_subscription_by_namePtr = _lookup< + late final _realm_results_getPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer)>>('realm_sync_find_subscription_by_name'); - late final _realm_sync_find_subscription_by_name = - _realm_sync_find_subscription_by_namePtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer)>(); + ffi.Bool Function(ffi.Pointer, ffi.Size, + ffi.Pointer)>>('realm_results_get'); + late final _realm_results_get = _realm_results_getPtr.asFunction< + bool Function( + ffi.Pointer, int, ffi.Pointer)>(); - /// Find subscription associated to the query passed as parameter - /// @return a pointer to the subscription or nullptr if not found - ffi.Pointer - realm_sync_find_subscription_by_query( - ffi.Pointer arg0, - ffi.Pointer arg1, + /// Returns an instance of realm_dictionary for the index passed as argument. + /// @return A valid ptr to a dictionary instance or nullptr in case of errors + ffi.Pointer realm_results_get_dictionary( + ffi.Pointer arg0, + int index, ) { - return _realm_sync_find_subscription_by_query( + return _realm_results_get_dictionary( arg0, - arg1, + index, ); } - late final _realm_sync_find_subscription_by_queryPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer)>>( - 'realm_sync_find_subscription_by_query'); - late final _realm_sync_find_subscription_by_query = - _realm_sync_find_subscription_by_queryPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer)>(); - - /// Find subscription associated to the results set passed as parameter - /// @return a pointer to the subscription or nullptr if not found - ffi.Pointer - realm_sync_find_subscription_by_results( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - return _realm_sync_find_subscription_by_results( - arg0, - arg1, - ); - } + late final _realm_results_get_dictionaryPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Size)>>('realm_results_get_dictionary'); + late final _realm_results_get_dictionary = + _realm_results_get_dictionaryPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, int)>(); - late final _realm_sync_find_subscription_by_resultsPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer)>>( - 'realm_sync_find_subscription_by_results'); - late final _realm_sync_find_subscription_by_results = - _realm_sync_find_subscription_by_resultsPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer)>(); - - /// Get active subscription set - /// @return a non null subscription set pointer if such it exists. - ffi.Pointer - realm_sync_get_active_subscription_set( - ffi.Pointer arg0, + /// Returns an instance of realm_list at the index passed as argument. + /// @return A valid ptr to a list instance or nullptr in case of errors + ffi.Pointer realm_results_get_list( + ffi.Pointer arg0, + int index, ) { - return _realm_sync_get_active_subscription_set( + return _realm_results_get_list( arg0, + index, ); } - late final _realm_sync_get_active_subscription_setPtr = _lookup< + late final _realm_results_get_listPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_sync_get_active_subscription_set'); - late final _realm_sync_get_active_subscription_set = - _realm_sync_get_active_subscription_setPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer)>(); + ffi.Pointer Function(ffi.Pointer, + ffi.Size)>>('realm_results_get_list'); + late final _realm_results_get_list = _realm_results_get_listPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, int)>(); - /// Get latest subscription set - /// @return a non null subscription set pointer if such it exists. - ffi.Pointer - realm_sync_get_latest_subscription_set( - ffi.Pointer arg0, + /// Get the matching object at @a index in the results. + /// + /// If the result is "live" (not a snapshot), this may rerun the query if things + /// have changed. + /// + /// Note: The bound returned by `realm_results_count()` for a non-snapshot result + /// is not a reliable way to iterate over elements in the result, because + /// the result will be live-updated if changes are made in each iteration + /// that may change the number of query results or even change the + /// ordering. In other words, this method should probably only be used with + /// snapshot results. + /// + /// @return An instance of `realm_object_t` if no exception occurred. + ffi.Pointer realm_results_get_object( + ffi.Pointer arg0, + int index, ) { - return _realm_sync_get_latest_subscription_set( + return _realm_results_get_object( arg0, + index, ); } - late final _realm_sync_get_latest_subscription_setPtr = _lookup< + late final _realm_results_get_objectPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_sync_get_latest_subscription_set'); - late final _realm_sync_get_latest_subscription_set = - _realm_sync_get_latest_subscription_setPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer)>(); + ffi.Pointer Function(ffi.Pointer, + ffi.Size)>>('realm_results_get_object'); + late final _realm_results_get_object = + _realm_results_get_objectPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, int)>(); - /// In case manual reset is needed, run this function in order to reset sync client files. - /// The sync_path is going to passed into realm_sync_error_handler_func_t, if manual reset is needed. - /// This function is supposed to be called inside realm_sync_error_handler_func_t callback, if sync client reset is - /// needed - /// @param realm_app ptr to realm app. - /// @param sync_path path where the sync files are. - /// @param did_run ptr to bool, which will be set to true if operation was successful - /// @return true if operation was successful - bool realm_sync_immediately_run_file_actions( - ffi.Pointer realm_app, - ffi.Pointer sync_path, - ffi.Pointer did_run, + /// Return the query associated to the results passed as argument. + /// + /// @param results the ptr to a valid results object. + /// @return a valid ptr to realm_query_t if no error has occurred + ffi.Pointer realm_results_get_query( + ffi.Pointer results, ) { - return _realm_sync_immediately_run_file_actions( - realm_app, - sync_path, - did_run, + return _realm_results_get_query( + results, ); } - late final _realm_sync_immediately_run_file_actionsPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>>( - 'realm_sync_immediately_run_file_actions'); - late final _realm_sync_immediately_run_file_actions = - _realm_sync_immediately_run_file_actionsPtr.asFunction< - bool Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>(); + late final _realm_results_get_queryPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer)>>('realm_results_get_query'); + late final _realm_results_get_query = _realm_results_get_queryPtr.asFunction< + ffi.Pointer Function(ffi.Pointer)>(); - /// Convert a subscription into a mutable one in order to alter the subscription itself - /// @return a pointer to a mutable subscription - ffi.Pointer - realm_sync_make_subscription_set_mutable( - ffi.Pointer arg0, + /// Set the boolean passed as argument to true or false whether the realm_results passed is valid or not + /// @return true/false if no exception has occurred. + bool realm_results_is_valid( + ffi.Pointer arg0, + ffi.Pointer arg1, ) { - return _realm_sync_make_subscription_set_mutable( + return _realm_results_is_valid( arg0, + arg1, ); } - late final _realm_sync_make_subscription_set_mutablePtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>( - 'realm_sync_make_subscription_set_mutable'); - late final _realm_sync_make_subscription_set_mutable = - _realm_sync_make_subscription_set_mutablePtr.asFunction< - ffi.Pointer Function( - ffi.Pointer)>(); - - /// Register a handler in order to be notified when subscription set is equal to the one passed as parameter - /// This is an asynchronous operation. - /// @return true/false if the handler was registered correctly - bool realm_sync_on_subscription_set_state_change_async( - ffi.Pointer subscription_set, - realm_flx_sync_subscription_set_state notify_when, - realm_sync_on_subscription_state_changed_t arg2, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, - ) { - return _realm_sync_on_subscription_set_state_change_async( - subscription_set, - notify_when.value, - arg2, - userdata, - userdata_free, - ); - } - - late final _realm_sync_on_subscription_set_state_change_asyncPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.UnsignedInt, - realm_sync_on_subscription_state_changed_t, - ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_sync_on_subscription_set_state_change_async'); - late final _realm_sync_on_subscription_set_state_change_async = - _realm_sync_on_subscription_set_state_change_asyncPtr.asFunction< - bool Function( - ffi.Pointer, - int, - realm_sync_on_subscription_state_changed_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); - - /// Wait until subscripton set state is equal to the state passed as parameter. - /// This is a blocking operation. - /// @return the current subscription state - realm_flx_sync_subscription_set_state - realm_sync_on_subscription_set_state_change_wait( - ffi.Pointer arg0, - realm_flx_sync_subscription_set_state arg1, - ) { - return realm_flx_sync_subscription_set_state - .fromValue(_realm_sync_on_subscription_set_state_change_wait( - arg0, - arg1.value, - )); - } - - late final _realm_sync_on_subscription_set_state_change_waitPtr = _lookup< - ffi.NativeFunction< - ffi.UnsignedInt Function( - ffi.Pointer, - ffi.UnsignedInt)>>( - 'realm_sync_on_subscription_set_state_change_wait'); - late final _realm_sync_on_subscription_set_state_change_wait = - _realm_sync_on_subscription_set_state_change_waitPtr.asFunction< - int Function(ffi.Pointer, int)>(); + late final _realm_results_is_validPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, + ffi.Pointer)>>('realm_results_is_valid'); + late final _realm_results_is_valid = _realm_results_is_validPtr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer)>(); - /// Get the sync session for a specific realm. - /// - /// This function will not fail if the realm wasn't open with a sync configuration in place, - /// but just return NULL; + /// Create a new results object by limiting the number of items /// - /// @return A non-null pointer if a session exists. - ffi.Pointer realm_sync_session_get( - ffi.Pointer arg0, + /// @param max_count Specifies the number of elements the new result can have at most + /// @return A non-null pointer if no exception occurred. + ffi.Pointer realm_results_limit( + ffi.Pointer results, + int max_count, ) { - return _realm_sync_session_get( - arg0, + return _realm_results_limit( + results, + max_count, ); } - late final _realm_sync_session_getPtr = _lookup< + late final _realm_results_limitPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_sync_session_get'); - late final _realm_sync_session_get = _realm_sync_session_getPtr.asFunction< - ffi.Pointer Function(ffi.Pointer)>(); - - /// Fetch connection state for the session passed as parameter - /// @param session ptr to the sync session to retrieve the state for - /// @return realm_sync_connection_state_e value - realm_sync_connection_state realm_sync_session_get_connection_state( - ffi.Pointer session, - ) { - return realm_sync_connection_state - .fromValue(_realm_sync_session_get_connection_state( - session, - )); - } - - late final _realm_sync_session_get_connection_statePtr = _lookup< - ffi.NativeFunction< - ffi.UnsignedInt Function(ffi.Pointer)>>( - 'realm_sync_session_get_connection_state'); - late final _realm_sync_session_get_connection_state = - _realm_sync_session_get_connection_statePtr - .asFunction)>(); + ffi.Pointer Function( + ffi.Pointer, ffi.Size)>>('realm_results_limit'); + late final _realm_results_limit = _realm_results_limitPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, int)>(); - /// Gets the file ident/salt currently assigned to the realm by sync. Callers should supply a pointer token - /// a realm_salted_file_ident_t for this function to fill out. - void realm_sync_session_get_file_ident( - ffi.Pointer arg0, - ffi.Pointer out, + /// Compute the maximum value of a property in the results. + /// + /// @param out_max Where to write the result, if there were matching rows. + /// @param out_found Set to true if there are matching rows. + /// @return True if no exception occurred. + bool realm_results_max( + ffi.Pointer arg0, + int arg1, + ffi.Pointer out_max, + ffi.Pointer out_found, ) { - return _realm_sync_session_get_file_ident( + return _realm_results_max( arg0, - out, + arg1, + out_max, + out_found, ); } - late final _realm_sync_session_get_file_identPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Pointer)>>( - 'realm_sync_session_get_file_ident'); - late final _realm_sync_session_get_file_ident = - _realm_sync_session_get_file_identPtr.asFunction< - void Function(ffi.Pointer, - ffi.Pointer)>(); + late final _realm_results_maxPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + realm_property_key_t, + ffi.Pointer, + ffi.Pointer)>>('realm_results_max'); + late final _realm_results_max = _realm_results_maxPtr.asFunction< + bool Function(ffi.Pointer, int, + ffi.Pointer, ffi.Pointer)>(); - /// Get the filesystem path of the realm file backing this session. - ffi.Pointer realm_sync_session_get_file_path( - ffi.Pointer arg0, + /// Compute the minimum value of a property in the results. + /// + /// @param out_min Where to write the result, if there were matching rows. + /// @param out_found Set to true if there are matching rows. + /// @return True if no exception occurred. + bool realm_results_min( + ffi.Pointer arg0, + int arg1, + ffi.Pointer out_min, + ffi.Pointer out_found, ) { - return _realm_sync_session_get_file_path( + return _realm_results_min( arg0, + arg1, + out_min, + out_found, ); } - late final _realm_sync_session_get_file_pathPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>( - 'realm_sync_session_get_file_path'); - late final _realm_sync_session_get_file_path = - _realm_sync_session_get_file_pathPtr.asFunction< - ffi.Pointer Function(ffi.Pointer)>(); + late final _realm_results_minPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + realm_property_key_t, + ffi.Pointer, + ffi.Pointer)>>('realm_results_min'); + late final _realm_results_min = _realm_results_minPtr.asFunction< + bool Function(ffi.Pointer, int, + ffi.Pointer, ffi.Pointer)>(); - /// Fetch partition value for the session passed as parameter - /// @param session ptr to the sync session to retrieve the partition value for - /// @return a string containing the partition value - ffi.Pointer realm_sync_session_get_partition_value( - ffi.Pointer session, + /// Map the Results into a live Realm instance. + /// + /// This is equivalent to producing a thread-safe reference and resolving it in the live realm. + /// + /// @return A live copy of the Results. + ffi.Pointer realm_results_resolve_in( + ffi.Pointer from_results, + ffi.Pointer target_realm, ) { - return _realm_sync_session_get_partition_value( - session, + return _realm_results_resolve_in( + from_results, + target_realm, ); } - late final _realm_sync_session_get_partition_valuePtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>( - 'realm_sync_session_get_partition_value'); - late final _realm_sync_session_get_partition_value = - _realm_sync_session_get_partition_valuePtr.asFunction< - ffi.Pointer Function(ffi.Pointer)>(); - - /// Fetch state for the session passed as parameter - /// @param session ptr to the sync session to retrieve the state for - /// @return realm_sync_session_state_e value - realm_sync_session_state realm_sync_session_get_state( - ffi.Pointer session, - ) { - return realm_sync_session_state.fromValue(_realm_sync_session_get_state( - session, - )); - } - - late final _realm_sync_session_get_statePtr = _lookup< - ffi.NativeFunction< - ffi.UnsignedInt Function(ffi.Pointer)>>( - 'realm_sync_session_get_state'); - late final _realm_sync_session_get_state = _realm_sync_session_get_statePtr - .asFunction)>(); + late final _realm_results_resolve_inPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer)>>('realm_results_resolve_in'); + late final _realm_results_resolve_in = + _realm_results_resolve_inPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); - /// Fetch user for the session passed as parameter - /// @param session ptr to the sync session to retrieve the user for - /// @return ptr to realm_user_t - ffi.Pointer realm_sync_session_get_user( - ffi.Pointer session, + /// Return a snapshot of the results that never automatically updates. + /// + /// The returned result is suitable for use with `realm_results_count()` + + /// `realm_results_get()`. + ffi.Pointer realm_results_snapshot( + ffi.Pointer arg0, ) { - return _realm_sync_session_get_user( - session, + return _realm_results_snapshot( + arg0, ); } - late final _realm_sync_session_get_userPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>( - 'realm_sync_session_get_user'); - late final _realm_sync_session_get_user = - _realm_sync_session_get_userPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer)>(); - - /// Wrapper for SyncSession::OnlyForTesting::handle_error. This routine should be used only for testing. - /// @param session ptr to a valid sync session - /// @param error_code realm_errno_e representing the error to simulate - /// @param error_str error message to be included with Status - /// @param is_fatal boolean to signal if the error is fatal or not - void realm_sync_session_handle_error_for_testing( - ffi.Pointer session, - realm_errno error_code, - ffi.Pointer error_str, - bool is_fatal, - ) { - return _realm_sync_session_handle_error_for_testing( - session, - error_code.value, - error_str, - is_fatal, - ); - } - - late final _realm_sync_session_handle_error_for_testingPtr = _lookup< + late final _realm_results_snapshotPtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.UnsignedInt, - ffi.Pointer, - ffi.Bool)>>('realm_sync_session_handle_error_for_testing'); - late final _realm_sync_session_handle_error_for_testing = - _realm_sync_session_handle_error_for_testingPtr.asFunction< - void Function(ffi.Pointer, int, - ffi.Pointer, bool)>(); + ffi.Pointer Function( + ffi.Pointer)>>('realm_results_snapshot'); + late final _realm_results_snapshot = _realm_results_snapshotPtr.asFunction< + ffi.Pointer Function(ffi.Pointer)>(); - /// Ask the session to pause synchronization. + /// Create a new results object by further sorting existing result. /// - /// No-op if the session is already inactive. - void realm_sync_session_pause( - ffi.Pointer arg0, + /// @param sort_string Specifies a sort condition. It has the format + /// ["," ]* + /// ::= ["." ]* , + /// ::= "ASCENDING" | "DESCENDING" + /// @return A non-null pointer if no exception occurred. + ffi.Pointer realm_results_sort( + ffi.Pointer results, + ffi.Pointer sort_string, ) { - return _realm_sync_session_pause( - arg0, + return _realm_results_sort( + results, + sort_string, ); } - late final _realm_sync_session_pausePtr = _lookup< + late final _realm_results_sortPtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer)>>('realm_sync_session_pause'); - late final _realm_sync_session_pause = _realm_sync_session_pausePtr - .asFunction)>(); + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer)>>('realm_results_sort'); + late final _realm_results_sort = _realm_results_sortPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); - /// Register a callback that will be invoked every time the session's connection state changes. + /// Compute the sum value of a property in the results. /// - /// @return a notification token object. Dispose it to stop receiving notifications. - ffi.Pointer - realm_sync_session_register_connection_state_change_callback( - ffi.Pointer arg0, - realm_sync_connection_state_changed_func_t arg1, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, + /// @param out_sum Where to write the result. Zero if no rows matched. + /// @param out_found Set to true if there are matching rows. + /// @return True if no exception occurred. + bool realm_results_sum( + ffi.Pointer arg0, + int arg1, + ffi.Pointer out_sum, + ffi.Pointer out_found, ) { - return _realm_sync_session_register_connection_state_change_callback( + return _realm_results_sum( arg0, arg1, - userdata, - userdata_free, + out_sum, + out_found, ); } - late final _realm_sync_session_register_connection_state_change_callbackPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - realm_sync_connection_state_changed_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_sync_session_register_connection_state_change_callback'); - late final _realm_sync_session_register_connection_state_change_callback = - _realm_sync_session_register_connection_state_change_callbackPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, - realm_sync_connection_state_changed_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); + late final _realm_results_sumPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + realm_property_key_t, + ffi.Pointer, + ffi.Pointer)>>('realm_results_sum'); + late final _realm_results_sum = _realm_results_sumPtr.asFunction< + bool Function(ffi.Pointer, int, + ffi.Pointer, ffi.Pointer)>(); - /// Register a callback that will be invoked every time the session reports progress. - /// - /// @param is_streaming If true, then the notifier will be called forever, and will - /// always contain the most up-to-date number of downloadable or uploadable bytes. - /// Otherwise, the number of downloaded or uploaded bytes will always be reported - /// relative to the number of downloadable or uploadable bytes at the point in time - /// when the notifier was registered. - /// @return a notification token object. Dispose it to stop receiving notifications. - ffi.Pointer - realm_sync_session_register_progress_notifier( - ffi.Pointer arg0, - realm_sync_progress_func_t arg1, - realm_sync_progress_direction arg2, - bool is_streaming, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, + /// Roll back a write transaction. + /// + /// @return True if the rollback succeeded and no exceptions were thrown. + bool realm_rollback( + ffi.Pointer arg0, ) { - return _realm_sync_session_register_progress_notifier( + return _realm_rollback( arg0, - arg1, - arg2.value, - is_streaming, - userdata, - userdata_free, ); } - late final _realm_sync_session_register_progress_notifierPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - realm_sync_progress_func_t, - ffi.UnsignedInt, - ffi.Bool, - ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_sync_session_register_progress_notifier'); - late final _realm_sync_session_register_progress_notifier = - _realm_sync_session_register_progress_notifierPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, - realm_sync_progress_func_t, - int, - bool, - ffi.Pointer, - realm_free_userdata_func_t)>(); + late final _realm_rollbackPtr = + _lookup)>>( + 'realm_rollback'); + late final _realm_rollback = + _realm_rollbackPtr.asFunction)>(); - /// Ask the session to resume synchronization. + /// Get the scheduler used by frozen realms. This scheduler does not support + /// notifications, and does not perform any thread checking. /// - /// No-op if the session is already active. - void realm_sync_session_resume( - ffi.Pointer arg0, - ) { - return _realm_sync_session_resume( - arg0, - ); + /// This function is thread-safe, and cannot fail. + ffi.Pointer realm_scheduler_get_frozen() { + return _realm_scheduler_get_frozen(); } - late final _realm_sync_session_resumePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer)>>('realm_sync_session_resume'); - late final _realm_sync_session_resume = _realm_sync_session_resumePtr - .asFunction)>(); - - /// Register a callback that will be invoked when all pending downloads have completed. - void realm_sync_session_wait_for_download_completion( - ffi.Pointer arg0, - realm_sync_wait_for_completion_func_t arg1, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, - ) { - return _realm_sync_session_wait_for_download_completion( - arg0, - arg1, - userdata, - userdata_free, - ); + late final _realm_scheduler_get_frozenPtr = + _lookup Function()>>( + 'realm_scheduler_get_frozen'); + late final _realm_scheduler_get_frozen = _realm_scheduler_get_frozenPtr + .asFunction Function()>(); + + /// Create an instance of the default scheduler for the current platform, + /// normally confined to the calling thread. + ffi.Pointer realm_scheduler_make_default() { + return _realm_scheduler_make_default(); } - late final _realm_sync_session_wait_for_download_completionPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - realm_sync_wait_for_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_sync_session_wait_for_download_completion'); - late final _realm_sync_session_wait_for_download_completion = - _realm_sync_session_wait_for_download_completionPtr.asFunction< - void Function( - ffi.Pointer, - realm_sync_wait_for_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); + late final _realm_scheduler_make_defaultPtr = + _lookup Function()>>( + 'realm_scheduler_make_default'); + late final _realm_scheduler_make_default = _realm_scheduler_make_defaultPtr + .asFunction Function()>(); - /// Register a callback that will be invoked when all pending uploads have completed. - void realm_sync_session_wait_for_upload_completion( - ffi.Pointer arg0, - realm_sync_wait_for_completion_func_t arg1, + /// Create a custom scheduler object from callback functions. + /// + /// @param notify Function which will be called whenever the scheduler has work + /// to do. Each call to this should trigger a call to + /// `realm_scheduler_perform_work()` from within the scheduler's + /// event loop. This function must be thread-safe, or NULL, in + /// which case the scheduler is considered unable to deliver + /// notifications. + /// @param is_on_thread Function to return true if called from the same thread as + /// the scheduler. This function must be thread-safe. + /// @param can_deliver_notifications Function to return true if the scheduler can + /// support `notify()`. This function does not + /// need to be thread-safe. + ffi.Pointer realm_scheduler_new( ffi.Pointer userdata, realm_free_userdata_func_t userdata_free, + realm_scheduler_notify_func_t notify, + realm_scheduler_is_on_thread_func_t is_on_thread, + realm_scheduler_is_same_as_func_t is_same_as, + realm_scheduler_can_deliver_notifications_func_t can_deliver_notifications, ) { - return _realm_sync_session_wait_for_upload_completion( - arg0, - arg1, + return _realm_scheduler_new( userdata, userdata_free, + notify, + is_on_thread, + is_same_as, + can_deliver_notifications, ); } - late final _realm_sync_session_wait_for_upload_completionPtr = _lookup< + late final _realm_scheduler_newPtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - realm_sync_wait_for_completion_func_t, + ffi.Pointer Function( ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_sync_session_wait_for_upload_completion'); - late final _realm_sync_session_wait_for_upload_completion = - _realm_sync_session_wait_for_upload_completionPtr.asFunction< - void Function( - ffi.Pointer, - realm_sync_wait_for_completion_func_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); + realm_free_userdata_func_t, + realm_scheduler_notify_func_t, + realm_scheduler_is_on_thread_func_t, + realm_scheduler_is_same_as_func_t, + realm_scheduler_can_deliver_notifications_func_t)>>( + 'realm_scheduler_new'); + late final _realm_scheduler_new = _realm_scheduler_newPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + realm_free_userdata_func_t, + realm_scheduler_notify_func_t, + realm_scheduler_is_on_thread_func_t, + realm_scheduler_is_same_as_func_t, + realm_scheduler_can_deliver_notifications_func_t)>(); - /// Creates a new sync socket instance for the Sync Client that handles the operations for a custom - /// websocket and event loop implementation. - /// @param userdata CAPI implementation specific pointer containing custom context data that is provided to - /// each of the provided functions. - /// @param userdata_free function that will be called when the sync socket is destroyed to delete userdata. This - /// is required if userdata is not null. - /// @param post_func function that will be called to post a callback handler onto the event loop - use the - /// realm_sync_socket_post_complete() function when the callback handler is scheduled to run. - /// @param create_timer_func function that will be called to create a new timer resource with the callback - /// handler that will be run when the timer expires or an erorr occurs - use the - /// realm_sync_socket_timer_canceled() function if the timer is canceled or the - /// realm_sync_socket_timer_complete() function if the timer expires or an error occurs. - /// @param cancel_timer_func function that will be called when the timer has been canceled by the sync client. - /// @param free_timer_func function that will be called when the timer resource has been destroyed by the sync client. - /// @param websocket_connect_func function that will be called when the sync client creates a websocket. - /// @param websocket_write_func function that will be called when the sync client sends data over the websocket. - /// @param websocket_free_func function that will be called when the sync client closes the websocket conneciton. - /// @return a realm_sync_socket_t pointer suitable for passing to realm_sync_client_config_set_sync_socket() - ffi.Pointer realm_sync_socket_new( - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, - realm_sync_socket_post_func_t post_func, - realm_sync_socket_create_timer_func_t create_timer_func, - realm_sync_socket_timer_canceled_func_t cancel_timer_func, - realm_sync_socket_timer_free_func_t free_timer_func, - realm_sync_socket_connect_func_t websocket_connect_func, - realm_sync_socket_websocket_async_write_func_t websocket_write_func, - realm_sync_socket_websocket_free_func_t websocket_free_func, - ) { - return _realm_sync_socket_new( - userdata, - userdata_free, - post_func, - create_timer_func, - cancel_timer_func, - free_timer_func, - websocket_connect_func, - websocket_write_func, - websocket_free_func, + /// Performs all of the pending work for the given scheduler. + /// + /// This function must be called from within the scheduler's event loop. It must + /// be called each time the notify callback passed to the scheduler + /// is invoked. + void realm_scheduler_perform_work( + ffi.Pointer arg0, + ) { + return _realm_scheduler_perform_work( + arg0, ); } - late final _realm_sync_socket_newPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - realm_free_userdata_func_t, - realm_sync_socket_post_func_t, - realm_sync_socket_create_timer_func_t, - realm_sync_socket_timer_canceled_func_t, - realm_sync_socket_timer_free_func_t, - realm_sync_socket_connect_func_t, - realm_sync_socket_websocket_async_write_func_t, - realm_sync_socket_websocket_free_func_t)>>( - 'realm_sync_socket_new'); - late final _realm_sync_socket_new = _realm_sync_socket_newPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, - realm_free_userdata_func_t, - realm_sync_socket_post_func_t, - realm_sync_socket_create_timer_func_t, - realm_sync_socket_timer_canceled_func_t, - realm_sync_socket_timer_free_func_t, - realm_sync_socket_connect_func_t, - realm_sync_socket_websocket_async_write_func_t, - realm_sync_socket_websocket_free_func_t)>(); - - /// To be called to execute the callback function provided to the post_func when the event loop executes - /// that post'ed operation. The post_handler resource will automatically be destroyed during this - /// operation. - /// @param post_handler the post callback handler that was originally provided to the post_func - /// @param result the error code for the error that occurred or RLM_ERR_SYNC_SOCKET_SUCCESS if the - /// callback handler should be executed normally. - /// @param reason a string describing details about the error that occurred or empty string if no error. - /// NOTE: This function must be called by the event loop execution thread. - void realm_sync_socket_post_complete( - ffi.Pointer post_handler, - realm_sync_socket_callback_result result, - ffi.Pointer reason, - ) { - return _realm_sync_socket_post_complete( - post_handler, - result.value, - reason, - ); - } - - late final _realm_sync_socket_post_completePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.UnsignedInt, - ffi.Pointer)>>('realm_sync_socket_post_complete'); - late final _realm_sync_socket_post_complete = - _realm_sync_socket_post_completePtr.asFunction< - void Function(ffi.Pointer, int, - ffi.Pointer)>(); + late final _realm_scheduler_perform_workPtr = _lookup< + ffi + .NativeFunction)>>( + 'realm_scheduler_perform_work'); + late final _realm_scheduler_perform_work = _realm_scheduler_perform_workPtr + .asFunction)>(); - /// To be called to execute the callback handler provided to the create_timer_func when the timer has been - /// canceled. - /// @param timer_handler the timer callback handler that was provided when the timer was created. - /// NOTE: This function must be called by the event loop execution thread. - void realm_sync_socket_timer_canceled( - ffi.Pointer timer_handler, + /// Create a new schema from classes and their properties. + /// + /// Note: This function does not validate the schema. + /// + /// Note: `realm_class_key_t` and `realm_property_key_t` values inside + /// `realm_class_info_t` and `realm_property_info_t` are unused when + /// defining the schema. Call `realm_get_schema()` to obtain the values for + /// these fields in an open realm. + /// + /// @return True if allocation of the schema structure succeeded. + ffi.Pointer realm_schema_new( + ffi.Pointer classes, + int num_classes, + ffi.Pointer> class_properties, ) { - return _realm_sync_socket_timer_canceled( - timer_handler, + return _realm_schema_new( + classes, + num_classes, + class_properties, ); } - late final _realm_sync_socket_timer_canceledPtr = _lookup< + late final _realm_schema_newPtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer)>>( - 'realm_sync_socket_timer_canceled'); - late final _realm_sync_socket_timer_canceled = - _realm_sync_socket_timer_canceledPtr.asFunction< - void Function(ffi.Pointer)>(); + ffi.Pointer Function( + ffi.Pointer, + ffi.Size, + ffi.Pointer>)>>( + 'realm_schema_new'); + late final _realm_schema_new = _realm_schema_newPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, int, + ffi.Pointer>)>(); - /// To be called to execute the callback handler provided to the create_timer_func when the timer is - /// complete or an error occurs while processing the timer. - /// @param timer_handler the timer callback handler that was provided when the timer was created. - /// @param result the error code for the error that occurred or RLM_ERR_SYNC_SOCKET_SUCCESS if the timer - /// expired normally. - /// @param reason a string describing details about the error that occurred or empty string if no error. - /// NOTE: This function must be called by the event loop execution thread. - void realm_sync_socket_timer_complete( - ffi.Pointer timer_handler, - realm_sync_socket_callback_result result, - ffi.Pointer reason, + /// Rename a property for the schame of the open realm. + /// @param realm The realm for which the property schema has to be renamed + /// @param schema The schema to modifies + /// @param object_type type of the object to modify + /// @param old_name old name of the property + /// @param new_name new name of the property + bool realm_schema_rename_property( + ffi.Pointer realm, + ffi.Pointer schema, + ffi.Pointer object_type, + ffi.Pointer old_name, + ffi.Pointer new_name, ) { - return _realm_sync_socket_timer_complete( - timer_handler, - result.value, - reason, + return _realm_schema_rename_property( + realm, + schema, + object_type, + old_name, + new_name, ); } - late final _realm_sync_socket_timer_completePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.UnsignedInt, - ffi.Pointer)>>('realm_sync_socket_timer_complete'); - late final _realm_sync_socket_timer_complete = - _realm_sync_socket_timer_completePtr.asFunction< - void Function(ffi.Pointer, int, - ffi.Pointer)>(); - - /// To be called when the websocket has been closed, either due to an error or a normal close operation. - /// @param realm_websocket_observer the websocket observer object that was provided to the websocket_connect_func - /// @param was_clean boolean value that indicates whether this is a normal close situation (true), the - /// close code was provided by the server via a close message (true), or if the close code was - /// generated by the local websocket as a result of some other error (false) (e.g. host - /// unreachable, etc.) - /// @param code the websocket close code (per the WebSocket spec) that describes why the websocket was closed. - /// @param reason a string describing details about the error that occurred or empty string if no error. - /// @return bool designates whether the WebSocket object has been destroyed during the execution of this - /// function. The normal return value is True to indicate the WebSocket object is no longer valid. If - /// False is returned, the WebSocket object will be destroyed at some point in the future. - /// NOTE: This function must be called by the event loop execution thread and should not be called - /// after the websocket_free_func has been called to release the websocket resources. - bool realm_sync_socket_websocket_closed( - ffi.Pointer realm_websocket_observer, - bool was_clean, - realm_web_socket_errno code, - ffi.Pointer reason, - ) { - return _realm_sync_socket_websocket_closed( - realm_websocket_observer, - was_clean, - code.value, - reason, - ); - } - - late final _realm_sync_socket_websocket_closedPtr = _lookup< + late final _realm_schema_rename_propertyPtr = _lookup< ffi.NativeFunction< ffi.Bool Function( - ffi.Pointer, - ffi.Bool, - ffi.UnsignedInt, - ffi.Pointer)>>('realm_sync_socket_websocket_closed'); - late final _realm_sync_socket_websocket_closed = - _realm_sync_socket_websocket_closedPtr.asFunction< - bool Function(ffi.Pointer, bool, int, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('realm_schema_rename_property'); + late final _realm_schema_rename_property = + _realm_schema_rename_propertyPtr.asFunction< + bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); - /// To be called when the websocket successfully connects to the server. - /// @param realm_websocket_observer the websocket observer object that was provided to the websocket_connect_func - /// @param protocol the value of the Sec-WebSocket-Protocol header in the connect response from the server. - /// NOTE: This function must be called by the event loop execution thread and should not be called - /// after the websocket_free_func has been called to release the websocket resources. - void realm_sync_socket_websocket_connected( - ffi.Pointer realm_websocket_observer, - ffi.Pointer protocol, + /// Validate the schema. + /// + /// @param validation_mode A bitwise combination of values from the + /// enum realm_schema_validation_mode. + /// + /// @return True if the schema passed validation. If validation failed, + /// `realm_get_last_error()` will produce an error describing the + /// validation failure. + bool realm_schema_validate( + ffi.Pointer arg0, + int validation_mode, ) { - return _realm_sync_socket_websocket_connected( - realm_websocket_observer, - protocol, + return _realm_schema_validate( + arg0, + validation_mode, ); } - late final _realm_sync_socket_websocket_connectedPtr = _lookup< + late final _realm_schema_validatePtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Pointer)>>('realm_sync_socket_websocket_connected'); - late final _realm_sync_socket_websocket_connected = - _realm_sync_socket_websocket_connectedPtr.asFunction< - void Function(ffi.Pointer, - ffi.Pointer)>(); + ffi.Bool Function(ffi.Pointer, + ffi.Uint64)>>('realm_schema_validate'); + late final _realm_schema_validate = _realm_schema_validatePtr + .asFunction, int)>(); - /// To be called when an error occurs - the actual error value will be provided when the websocket_closed - /// function is called. This function informs that the socket object is in an error state and no further - /// TX operations should be performed. - /// @param realm_websocket_observer the websocket observer object that was provided to the websocket_connect_func - /// NOTE: This function must be called by the event loop execution thread and should not be called - /// after the websocket_free_func has been called to release the websocket resources. - void realm_sync_socket_websocket_error( - ffi.Pointer realm_websocket_observer, + /// Subscribe to notifications for this object. + /// + /// @return A non-null pointer if no exception occurred. + ffi.Pointer realm_set_add_notification_callback( + ffi.Pointer arg0, + ffi.Pointer userdata, + realm_free_userdata_func_t userdata_free, + ffi.Pointer key_path_array, + realm_on_collection_change_func_t on_change, ) { - return _realm_sync_socket_websocket_error( - realm_websocket_observer, + return _realm_set_add_notification_callback( + arg0, + userdata, + userdata_free, + key_path_array, + on_change, ); } - late final _realm_sync_socket_websocket_errorPtr = _lookup< + late final _realm_set_add_notification_callbackPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer)>>( - 'realm_sync_socket_websocket_error'); - late final _realm_sync_socket_websocket_error = - _realm_sync_socket_websocket_errorPtr - .asFunction)>(); - - /// To be called to provide the received data to the Sync Client when a write operation has completed. - /// The data buffer can be safely discarded after this function has completed. - /// @param realm_websocket_observer the websocket observer object that was provided to the websocket_connect_func - /// @param data a pointer to the buffer that contains the data received over the websocket - /// @param data_size the number of bytes in the data buffer - /// @return bool designates whether the WebSocket object should continue processing messages. The normal return - /// value is true. False must be returned if the websocket object has been destroyed during execution of - /// the function. - /// NOTE: This function must be called by the event loop execution thread and should not be called - /// after the websocket_free_func has been called to release the websocket resources. - bool realm_sync_socket_websocket_message( - ffi.Pointer realm_websocket_observer, - ffi.Pointer data, - int data_size, - ) { - return _realm_sync_socket_websocket_message( - realm_websocket_observer, - data, - data_size, + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + realm_free_userdata_func_t, + ffi.Pointer, + realm_on_collection_change_func_t)>>( + 'realm_set_add_notification_callback'); + late final _realm_set_add_notification_callback = + _realm_set_add_notification_callbackPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + realm_free_userdata_func_t, + ffi.Pointer, + realm_on_collection_change_func_t)>(); + + void realm_set_auto_refresh( + ffi.Pointer realm, + bool enable, + ) { + return _realm_set_auto_refresh( + realm, + enable, ); } - late final _realm_sync_socket_websocket_messagePtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size)>>('realm_sync_socket_websocket_message'); - late final _realm_sync_socket_websocket_message = - _realm_sync_socket_websocket_messagePtr.asFunction< - bool Function(ffi.Pointer, - ffi.Pointer, int)>(); - - /// To be called to execute the callback function provided to the websocket_write_func when the write - /// operation is complete. The write_handler resource will automatically be destroyed during this - /// operation. - /// @param write_handler the write callback handler that was originally provided to the websocket_write_func - /// @param result the error code for the error that occurred or RLM_ERR_SYNC_SOCKET_SUCCESS if write completed - /// successfully - /// @param reason a string describing details about the error that occurred or empty string if no error. - /// NOTE: This function must be called by the event loop execution thread. - void realm_sync_socket_write_complete( - ffi.Pointer write_handler, - realm_sync_socket_callback_result result, - ffi.Pointer reason, - ) { - return _realm_sync_socket_write_complete( - write_handler, - result.value, - reason, - ); - } - - late final _realm_sync_socket_write_completePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.UnsignedInt, - ffi.Pointer)>>('realm_sync_socket_write_complete'); - late final _realm_sync_socket_write_complete = - _realm_sync_socket_write_completePtr.asFunction< - void Function(ffi.Pointer, int, - ffi.Pointer)>(); + late final _realm_set_auto_refreshPtr = _lookup< + ffi + .NativeFunction, ffi.Bool)>>( + 'realm_set_auto_refresh'); + late final _realm_set_auto_refresh = _realm_set_auto_refreshPtr + .asFunction, bool)>(); - /// Access the subscription at index. - /// @return the subscription or nullptr if the index is not valid - ffi.Pointer realm_sync_subscription_at( - ffi.Pointer arg0, - int index, + /// Clear a set of values. + /// + /// @return True if no exception occurred. + bool realm_set_clear( + ffi.Pointer arg0, ) { - return _realm_sync_subscription_at( + return _realm_set_clear( arg0, - index, ); } - late final _realm_sync_subscription_atPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Size)>>('realm_sync_subscription_at'); - late final _realm_sync_subscription_at = - _realm_sync_subscription_atPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, int)>(); + late final _realm_set_clearPtr = + _lookup)>>( + 'realm_set_clear'); + late final _realm_set_clear = + _realm_set_clearPtr.asFunction)>(); - /// Fetch the timestamp in which the subscription was created for the subscription passed as argument. - /// @return realm_timestamp_t representing the timestamp in which the subscription for created. - realm_timestamp_t realm_sync_subscription_created_at( - ffi.Pointer subscription, + ffi.Pointer realm_set_dictionary( + ffi.Pointer arg0, + int arg1, ) { - return _realm_sync_subscription_created_at( - subscription, + return _realm_set_dictionary( + arg0, + arg1, ); } - late final _realm_sync_subscription_created_atPtr = _lookup< - ffi.NativeFunction< - realm_timestamp_t Function( - ffi.Pointer)>>( - 'realm_sync_subscription_created_at'); - late final _realm_sync_subscription_created_at = - _realm_sync_subscription_created_atPtr.asFunction< - realm_timestamp_t Function( - ffi.Pointer)>(); + late final _realm_set_dictionaryPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + realm_property_key_t)>>('realm_set_dictionary'); + late final _realm_set_dictionary = _realm_set_dictionaryPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, int)>(); - /// Fetch subscription id for the subscription passed as argument. - /// @return realm_object_id_t for the subscription passed as argument - realm_object_id_t realm_sync_subscription_id( - ffi.Pointer subscription, + /// Create an embedded object in a given property. + /// + /// @return A non-NULL pointer if the object was created successfully. + ffi.Pointer realm_set_embedded( + ffi.Pointer arg0, + int arg1, ) { - return _realm_sync_subscription_id( - subscription, + return _realm_set_embedded( + arg0, + arg1, ); } - late final _realm_sync_subscription_idPtr = _lookup< - ffi.NativeFunction< - realm_object_id_t Function( - ffi.Pointer)>>( - 'realm_sync_subscription_id'); - late final _realm_sync_subscription_id = - _realm_sync_subscription_idPtr.asFunction< - realm_object_id_t Function( - ffi.Pointer)>(); + late final _realm_set_embeddedPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + realm_property_key_t)>>('realm_set_embedded'); + late final _realm_set_embedded = _realm_set_embeddedPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, int)>(); - /// Fetch subscription name for the subscription passed as argument. - /// @return realm_string_t which contains the name of the subscription. - realm_string_t realm_sync_subscription_name( - ffi.Pointer subscription, + /// Erase an element from a set. + /// + /// If the element does not exist in the set, this function does nothing (and + /// does not report an error). + /// + /// @param value The value to erase. + /// @param out_erased If non-null, will be set to true if the element was found + /// and erased, and otherwise set to false. + /// @return True if no exception occurred. + bool realm_set_erase( + ffi.Pointer arg0, + realm_value_t value, + ffi.Pointer out_erased, ) { - return _realm_sync_subscription_name( - subscription, + return _realm_set_erase( + arg0, + value, + out_erased, ); } - late final _realm_sync_subscription_namePtr = _lookup< - ffi.NativeFunction< - realm_string_t Function( - ffi.Pointer)>>( - 'realm_sync_subscription_name'); - late final _realm_sync_subscription_name = - _realm_sync_subscription_namePtr.asFunction< - realm_string_t Function( - ffi.Pointer)>(); + late final _realm_set_erasePtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, realm_value_t, + ffi.Pointer)>>('realm_set_erase'); + late final _realm_set_erase = _realm_set_erasePtr.asFunction< + bool Function( + ffi.Pointer, realm_value_t, ffi.Pointer)>(); - /// Fetch object class name for the subscription passed as argument. - /// @return a realm_string_t which contains the class name of the subscription. - realm_string_t realm_sync_subscription_object_class_name( - ffi.Pointer subscription, + /// Find an element in a set. + /// + /// If @a value has a type that is incompatible with the set, it will be reported + /// as not existing in the set. + /// + /// @param value The value to look for in the set. + /// @param out_index If non-null, and the element is found, this will be + /// populated with the index of the found element in the set. + /// @param out_found If non-null, will be set to true if the element was found, + /// otherwise will be set to false. + /// @return True if no exception occurred. + bool realm_set_find( + ffi.Pointer arg0, + realm_value_t value, + ffi.Pointer out_index, + ffi.Pointer out_found, ) { - return _realm_sync_subscription_object_class_name( - subscription, + return _realm_set_find( + arg0, + value, + out_index, + out_found, ); } - late final _realm_sync_subscription_object_class_namePtr = _lookup< - ffi.NativeFunction< - realm_string_t Function( - ffi.Pointer)>>( - 'realm_sync_subscription_object_class_name'); - late final _realm_sync_subscription_object_class_name = - _realm_sync_subscription_object_class_namePtr.asFunction< - realm_string_t Function( - ffi.Pointer)>(); + late final _realm_set_findPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, realm_value_t, + ffi.Pointer, ffi.Pointer)>>('realm_set_find'); + late final _realm_set_find = _realm_set_findPtr.asFunction< + bool Function(ffi.Pointer, realm_value_t, + ffi.Pointer, ffi.Pointer)>(); - /// Fetch the query string associated with the subscription passed as argument. - /// @return realm_string_t which contains the query associated with the subscription. - realm_string_t realm_sync_subscription_query_string( - ffi.Pointer subscription, + /// Get an set from a thread-safe reference, potentially originating in a + /// different `realm_t` instance + ffi.Pointer realm_set_from_thread_safe_reference( + ffi.Pointer arg0, + ffi.Pointer arg1, ) { - return _realm_sync_subscription_query_string( - subscription, + return _realm_set_from_thread_safe_reference( + arg0, + arg1, ); } - late final _realm_sync_subscription_query_stringPtr = _lookup< + late final _realm_set_from_thread_safe_referencePtr = _lookup< ffi.NativeFunction< - realm_string_t Function( - ffi.Pointer)>>( - 'realm_sync_subscription_query_string'); - late final _realm_sync_subscription_query_string = - _realm_sync_subscription_query_stringPtr.asFunction< - realm_string_t Function( - ffi.Pointer)>(); + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer)>>( + 'realm_set_from_thread_safe_reference'); + late final _realm_set_from_thread_safe_reference = + _realm_set_from_thread_safe_referencePtr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer)>(); - /// Clear the subscription set passed as parameter - /// @return true/false if operation was successful - bool realm_sync_subscription_set_clear( - ffi.Pointer arg0, + /// Get the value at @a index. + /// + /// Note that elements in a set move around arbitrarily when other elements are + /// inserted/removed. + /// + /// @param out_value The resulting value, if no error occurred. May be NULL, + /// though nonsensical. + /// @return True if no exception occurred. + bool realm_set_get( + ffi.Pointer arg0, + int index, + ffi.Pointer out_value, ) { - return _realm_sync_subscription_set_clear( + return _realm_set_get( arg0, + index, + out_value, ); } - late final _realm_sync_subscription_set_clearPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer)>>( - 'realm_sync_subscription_set_clear'); - late final _realm_sync_subscription_set_clear = - _realm_sync_subscription_set_clearPtr.asFunction< - bool Function( - ffi.Pointer)>(); + late final _realm_set_getPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, ffi.Size, + ffi.Pointer)>>('realm_set_get'); + late final _realm_set_get = _realm_set_getPtr.asFunction< + bool Function( + ffi.Pointer, int, ffi.Pointer)>(); - /// Commit the subscription_set passed as parameter (in order that all the changes made will take effect) - /// @return pointer to a valid immutable subscription if commit was successful - ffi.Pointer - realm_sync_subscription_set_commit( - ffi.Pointer arg0, + /// Get the property that this set came from. + /// + /// @return True if no exception occurred. + bool realm_set_get_property( + ffi.Pointer arg0, + ffi.Pointer out_property_info, ) { - return _realm_sync_subscription_set_commit( + return _realm_set_get_property( arg0, + out_property_info, ); } - late final _realm_sync_subscription_set_commitPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>( - 'realm_sync_subscription_set_commit'); - late final _realm_sync_subscription_set_commit = - _realm_sync_subscription_set_commitPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer)>(); - - /// Remove all subscriptions for a given class type. If operation completes successfully set the bool out param. - /// @return true if no error occurred, false otherwise (use realm_get_last_error for fetching the error). - bool realm_sync_subscription_set_erase_by_class_name( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer erased, + late final _realm_set_get_propertyPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, + ffi.Pointer)>>('realm_set_get_property'); + late final _realm_set_get_property = _realm_set_get_propertyPtr.asFunction< + bool Function( + ffi.Pointer, ffi.Pointer)>(); + + /// Insert an element in a set. + /// + /// If the element is already in the set, this function does nothing (and does + /// not report an error). + /// + /// @param value The value to insert. + /// @param out_index If non-null, will be set to the index of the inserted + /// element, or the index of the existing element. + /// @param out_inserted If non-null, will be set to true if the element did not + /// already exist in the set. Otherwise set to false. + /// @return True if no exception occurred. + bool realm_set_insert( + ffi.Pointer arg0, + realm_value_t value, + ffi.Pointer out_index, + ffi.Pointer out_inserted, ) { - return _realm_sync_subscription_set_erase_by_class_name( + return _realm_set_insert( arg0, - arg1, - erased, + value, + out_index, + out_inserted, ); } - late final _realm_sync_subscription_set_erase_by_class_namePtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>>( - 'realm_sync_subscription_set_erase_by_class_name'); - late final _realm_sync_subscription_set_erase_by_class_name = - _realm_sync_subscription_set_erase_by_class_namePtr.asFunction< - bool Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>(); + late final _realm_set_insertPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + realm_value_t, + ffi.Pointer, + ffi.Pointer)>>('realm_set_insert'); + late final _realm_set_insert = _realm_set_insertPtr.asFunction< + bool Function(ffi.Pointer, realm_value_t, + ffi.Pointer, ffi.Pointer)>(); - /// Erase from subscription set by id. If operation completes successfully set the bool out param. - /// @return true if no error occurred, false otherwise (use realm_get_last_error for fetching the error). - bool realm_sync_subscription_set_erase_by_id( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer erased, + /// Check if a set is valid. + /// + /// @return True if the set is valid. + bool realm_set_is_valid( + ffi.Pointer arg0, ) { - return _realm_sync_subscription_set_erase_by_id( + return _realm_set_is_valid( arg0, - arg1, - erased, ); } - late final _realm_sync_subscription_set_erase_by_idPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>>( - 'realm_sync_subscription_set_erase_by_id'); - late final _realm_sync_subscription_set_erase_by_id = - _realm_sync_subscription_set_erase_by_idPtr.asFunction< - bool Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>(); - - /// Erase from subscription set by name. If operation completes successfully set the bool out param. - /// @return true if no error occurred, false otherwise (use realm_get_last_error for fetching the error) - bool realm_sync_subscription_set_erase_by_name( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer erased, + late final _realm_set_is_validPtr = + _lookup)>>( + 'realm_set_is_valid'); + late final _realm_set_is_valid = _realm_set_is_validPtr + .asFunction)>(); + + /// Assign a JSON formatted string to a Mixed property. Underlying structures will be created as needed + /// + /// @param json_string The new value for the property. + /// @return True if no exception occurred. + bool realm_set_json( + ffi.Pointer arg0, + int arg1, + ffi.Pointer json_string, ) { - return _realm_sync_subscription_set_erase_by_name( + return _realm_set_json( arg0, arg1, - erased, + json_string, ); } - late final _realm_sync_subscription_set_erase_by_namePtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>>( - 'realm_sync_subscription_set_erase_by_name'); - late final _realm_sync_subscription_set_erase_by_name = - _realm_sync_subscription_set_erase_by_namePtr.asFunction< - bool Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>(); - - /// Erase from subscription set by query. If operation completes successfully set the bool out param. - /// @return true if no error occurred, false otherwise (use realm_get_last_error for fetching the error) - bool realm_sync_subscription_set_erase_by_query( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer erased, + late final _realm_set_jsonPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, realm_property_key_t, + ffi.Pointer)>>('realm_set_json'); + late final _realm_set_json = _realm_set_jsonPtr.asFunction< + bool Function(ffi.Pointer, int, ffi.Pointer)>(); + + /// Create a collection in a given Mixed property. + ffi.Pointer realm_set_list( + ffi.Pointer arg0, + int arg1, ) { - return _realm_sync_subscription_set_erase_by_query( + return _realm_set_list( arg0, arg1, - erased, ); } - late final _realm_sync_subscription_set_erase_by_queryPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>>( - 'realm_sync_subscription_set_erase_by_query'); - late final _realm_sync_subscription_set_erase_by_query = - _realm_sync_subscription_set_erase_by_queryPtr.asFunction< - bool Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>(); + late final _realm_set_listPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + realm_property_key_t)>>('realm_set_list'); + late final _realm_set_list = _realm_set_listPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, int)>(); - /// Erase from subscription set by results. If operation completes successfully set the bool out param. - /// @return true if no error occurred, false otherwise (use realm_get_last_error for fetching the error) - bool realm_sync_subscription_set_erase_by_results( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer erased, + /// Install the default logger + void realm_set_log_callback( + realm_log_func_t arg0, + ffi.Pointer userdata, + realm_free_userdata_func_t userdata_free, ) { - return _realm_sync_subscription_set_erase_by_results( + return _realm_set_log_callback( arg0, - arg1, - erased, + userdata, + userdata_free, ); } - late final _realm_sync_subscription_set_erase_by_resultsPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>>( - 'realm_sync_subscription_set_erase_by_results'); - late final _realm_sync_subscription_set_erase_by_results = - _realm_sync_subscription_set_erase_by_resultsPtr.asFunction< - bool Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>(); + late final _realm_set_log_callbackPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(realm_log_func_t, ffi.Pointer, + realm_free_userdata_func_t)>>('realm_set_log_callback'); + late final _realm_set_log_callback = _realm_set_log_callbackPtr.asFunction< + void Function(realm_log_func_t, ffi.Pointer, + realm_free_userdata_func_t)>(); - /// Query subscription set error string - /// @return error string for the subscription passed as parameter - ffi.Pointer realm_sync_subscription_set_error_str( - ffi.Pointer arg0, + void realm_set_log_level( + realm_log_level arg0, ) { - return _realm_sync_subscription_set_error_str( - arg0, + return _realm_set_log_level( + arg0.value, ); } - late final _realm_sync_subscription_set_error_strPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>( - 'realm_sync_subscription_set_error_str'); - late final _realm_sync_subscription_set_error_str = - _realm_sync_subscription_set_error_strPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer)>(); - - /// Insert ot update a query for the subscription set passed as parameter, if successful the index where the query - /// was inserted or updated is returned along with the info whether a new query was inserted or not. It is possible to - /// specify a name for the query inserted (optional). - /// @return true/false if operation was successful - bool realm_sync_subscription_set_insert_or_assign_query( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer name, - ffi.Pointer out_index, - ffi.Pointer out_inserted, + late final _realm_set_log_levelPtr = + _lookup>( + 'realm_set_log_level'); + late final _realm_set_log_level = + _realm_set_log_levelPtr.asFunction(); + + /// Set the logging level for given category. Return the previous level. + realm_log_level realm_set_log_level_category( + ffi.Pointer arg0, + realm_log_level arg1, ) { - return _realm_sync_subscription_set_insert_or_assign_query( + return realm_log_level.fromValue(_realm_set_log_level_category( arg0, - arg1, - name, - out_index, - out_inserted, - ); + arg1.value, + )); } - late final _realm_sync_subscription_set_insert_or_assign_queryPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>>( - 'realm_sync_subscription_set_insert_or_assign_query'); - late final _realm_sync_subscription_set_insert_or_assign_query = - _realm_sync_subscription_set_insert_or_assign_queryPtr.asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>(); + late final _realm_set_log_level_categoryPtr = _lookup< + ffi.NativeFunction< + ffi.UnsignedInt Function(ffi.Pointer, + ffi.UnsignedInt)>>('realm_set_log_level_category'); + late final _realm_set_log_level_category = _realm_set_log_level_categoryPtr + .asFunction, int)>(); - /// Insert ot update the query contained inside a result object for the subscription set passed as parameter, if - /// successful the index where the query was inserted or updated is returned along with the info whether a new query - /// was inserted or not. It is possible to specify a name for the query inserted (optional). - /// @return true/false if operation was successful - bool realm_sync_subscription_set_insert_or_assign_results( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer name, - ffi.Pointer out_index, - ffi.Pointer out_inserted, + /// In a set of objects, delete all objects in the set and clear the set. In a + /// set of values, clear the set. + /// + /// @return True if no exception occurred. + bool realm_set_remove_all( + ffi.Pointer arg0, ) { - return _realm_sync_subscription_set_insert_or_assign_results( + return _realm_set_remove_all( arg0, - arg1, - name, - out_index, - out_inserted, ); } - late final _realm_sync_subscription_set_insert_or_assign_resultsPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>>( - 'realm_sync_subscription_set_insert_or_assign_results'); - late final _realm_sync_subscription_set_insert_or_assign_results = - _realm_sync_subscription_set_insert_or_assign_resultsPtr.asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>(); + late final _realm_set_remove_allPtr = + _lookup)>>( + 'realm_set_remove_all'); + late final _realm_set_remove_all = _realm_set_remove_allPtr + .asFunction)>(); - /// Refresh subscription - /// @return true/false if the operation was successful or not - bool realm_sync_subscription_set_refresh( - ffi.Pointer arg0, + /// Resolve the set in the context of a given Realm instance. + /// + /// This is equivalent to producing a thread-safe reference and resolving it in the frozen realm. + /// + /// If resolution is possible, a valid resolved object is produced at '*resolved*'. + /// If resolution is not possible, but no error occurs, '*resolved' is set to NULL + /// + /// @return true if no error occurred. + bool realm_set_resolve_in( + ffi.Pointer list, + ffi.Pointer target_realm, + ffi.Pointer> resolved, ) { - return _realm_sync_subscription_set_refresh( - arg0, + return _realm_set_resolve_in( + list, + target_realm, + resolved, ); } - late final _realm_sync_subscription_set_refreshPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer)>>( - 'realm_sync_subscription_set_refresh'); - late final _realm_sync_subscription_set_refresh = - _realm_sync_subscription_set_refreshPtr.asFunction< - bool Function(ffi.Pointer)>(); + late final _realm_set_resolve_inPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer>)>>('realm_set_resolve_in'); + late final _realm_set_resolve_in = _realm_set_resolve_inPtr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer>)>(); - /// Retrieve the number of subscriptions for the subscription set passed as parameter - /// @return the number of subscriptions - int realm_sync_subscription_set_size( - ffi.Pointer arg0, + /// Get the size of a set, in number of unique elements. + /// + /// This function may fail if the object owning the set has been deleted. + /// + /// @param out_size Where to put the set size. May be NULL. + /// @return True if no exception occurred. + bool realm_set_size( + ffi.Pointer arg0, + ffi.Pointer out_size, ) { - return _realm_sync_subscription_set_size( + return _realm_set_size( arg0, + out_size, ); } - late final _realm_sync_subscription_set_sizePtr = _lookup< - ffi.NativeFunction< - ffi.Size Function( - ffi.Pointer)>>( - 'realm_sync_subscription_set_size'); - late final _realm_sync_subscription_set_size = - _realm_sync_subscription_set_sizePtr.asFunction< - int Function(ffi.Pointer)>(); + late final _realm_set_sizePtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, + ffi.Pointer)>>('realm_set_size'); + late final _realm_set_size = _realm_set_sizePtr.asFunction< + bool Function(ffi.Pointer, ffi.Pointer)>(); - /// Fetch current state for the subscription set passed as parameter - /// @return the current state of the subscription_set - realm_flx_sync_subscription_set_state realm_sync_subscription_set_state( - ffi.Pointer arg0, + /// Convert a set to results. + /// + /// @return A non-null pointer if no exception occurred. + ffi.Pointer realm_set_to_results( + ffi.Pointer arg0, ) { - return realm_flx_sync_subscription_set_state - .fromValue(_realm_sync_subscription_set_state( + return _realm_set_to_results( arg0, - )); + ); } - late final _realm_sync_subscription_set_statePtr = _lookup< - ffi.NativeFunction< - ffi.UnsignedInt Function( - ffi.Pointer)>>( - 'realm_sync_subscription_set_state'); - late final _realm_sync_subscription_set_state = - _realm_sync_subscription_set_statePtr.asFunction< - int Function(ffi.Pointer)>(); + late final _realm_set_to_resultsPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer)>>('realm_set_to_results'); + late final _realm_set_to_results = _realm_set_to_resultsPtr.asFunction< + ffi.Pointer Function(ffi.Pointer)>(); - /// Retrieve version for the subscription set passed as parameter - /// @return subscription set version if the poiter to the subscription is valid - int realm_sync_subscription_set_version( - ffi.Pointer arg0, + /// Set the value for a property. + /// + /// @param new_value The new value for the property. + /// @param is_default True if this property is being set as part of setting the + /// default values for a new object. This has no effect in + /// non-sync'ed realms. + /// @return True if no exception occurred. + bool realm_set_value( + ffi.Pointer arg0, + int arg1, + realm_value_t new_value, + bool is_default, ) { - return _realm_sync_subscription_set_version( + return _realm_set_value( arg0, + arg1, + new_value, + is_default, ); } - late final _realm_sync_subscription_set_versionPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer)>>( - 'realm_sync_subscription_set_version'); - late final _realm_sync_subscription_set_version = - _realm_sync_subscription_set_versionPtr.asFunction< - int Function(ffi.Pointer)>(); - - /// Fetch the timestamp in which the subscription was updated for the subscription passed as argument. - /// @return realm_timestamp_t representing the timestamp in which the subscription was updated. - realm_timestamp_t realm_sync_subscription_updated_at( - ffi.Pointer subscription, - ) { - return _realm_sync_subscription_updated_at( - subscription, - ); - } + late final _realm_set_valuePtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer, realm_property_key_t, + realm_value_t, ffi.Bool)>>('realm_set_value'); + late final _realm_set_value = _realm_set_valuePtr.asFunction< + bool Function(ffi.Pointer, int, realm_value_t, bool)>(); - late final _realm_sync_subscription_updated_atPtr = _lookup< - ffi.NativeFunction< - realm_timestamp_t Function( - ffi.Pointer)>>( - 'realm_sync_subscription_updated_at'); - late final _realm_sync_subscription_updated_at = - _realm_sync_subscription_updated_atPtr.asFunction< - realm_timestamp_t Function( - ffi.Pointer)>(); - - /// @return a notification token object. Dispose it to stop receiving notifications. - ffi.Pointer - realm_sync_user_on_state_change_register_callback( - ffi.Pointer arg0, - realm_sync_on_user_state_changed_t arg1, - ffi.Pointer userdata, - realm_free_userdata_func_t userdata_free, + /// Set the values for several properties. + /// + /// This is provided as an alternative to calling `realm_get_value()` multiple + /// times in a row, which is particularly useful for language runtimes where + /// crossing the native bridge is comparatively expensive. In addition, it + /// eliminates some parameter validation that would otherwise be repeated for + /// each call. + /// + /// Example use cases: + /// + /// - Initializing a new object with default values. + /// - Deserializing some in-memory structure into a realm object. + /// + /// This operation is "atomic"; if an exception occurs due to invalid input (such + /// as type mismatch, nullability mismatch, etc.), the object will remain + /// unmodified. + /// + /// @param num_values The number of elements in @a properties and @a values. + /// @param properties The keys of the properties to set. May not be NULL. + /// @param values The values to assign to the properties. May not be NULL. + /// @param is_default True if the properties are being set as part of setting + /// default values for a new object. This has no effect in + /// non-sync'ed realms. + /// @return True if no exception occurred. + bool realm_set_values( + ffi.Pointer arg0, + int num_values, + ffi.Pointer properties, + ffi.Pointer values, + bool is_default, ) { - return _realm_sync_user_on_state_change_register_callback( + return _realm_set_values( arg0, - arg1, - userdata, - userdata_free, + num_values, + properties, + values, + is_default, ); } - late final _realm_sync_user_on_state_change_register_callbackPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - realm_sync_on_user_state_changed_t, - ffi.Pointer, - realm_free_userdata_func_t)>>( - 'realm_sync_user_on_state_change_register_callback'); - late final _realm_sync_user_on_state_change_register_callback = - _realm_sync_user_on_state_change_register_callbackPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, - realm_sync_on_user_state_changed_t, - ffi.Pointer, - realm_free_userdata_func_t)>(); + late final _realm_set_valuesPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + ffi.Size, + ffi.Pointer, + ffi.Pointer, + ffi.Bool)>>('realm_set_values'); + late final _realm_set_values = _realm_set_valuesPtr.asFunction< + bool Function( + ffi.Pointer, + int, + ffi.Pointer, + ffi.Pointer, + bool)>(); /// Update the schema of an open realm. /// @@ -11171,221 +6497,6 @@ class RealmLibrary { ffi.Pointer, bool)>(); - /// Return the access token associated with the user. - /// @return a string that rapresents the access token - ffi.Pointer realm_user_get_access_token( - ffi.Pointer arg0, - ) { - return _realm_user_get_access_token( - arg0, - ); - } - - late final _realm_user_get_access_tokenPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_user_get_access_token'); - late final _realm_user_get_access_token = _realm_user_get_access_tokenPtr - .asFunction Function(ffi.Pointer)>(); - - /// Get the list of identities of this @a user. - /// - /// @param out_identities A pointer to an array of `realm_user_identity_t`, which - /// will be populated with the list of identities of this user. - /// Array may be NULL, in this case no data will be copied and `out_n` set if not NULL. - /// @param capacity The maximum number of elements `out_identities` can hold. - /// @param out_n The actual number of entries written to `out_identities`. May be NULL. - /// @return true, if no errors occurred. - bool realm_user_get_all_identities( - ffi.Pointer user, - ffi.Pointer out_identities, - int capacity, - ffi.Pointer out_n, - ) { - return _realm_user_get_all_identities( - user, - out_identities, - capacity, - out_n, - ); - } - - late final _realm_user_get_all_identitiesPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ffi.Pointer)>>('realm_user_get_all_identities'); - late final _realm_user_get_all_identities = - _realm_user_get_all_identitiesPtr.asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer)>(); - - /// Return the realm app for the user passed as parameter. - /// @return a ptr to the app for the user. - ffi.Pointer realm_user_get_app( - ffi.Pointer arg0, - ) { - return _realm_user_get_app( - arg0, - ); - } - - late final _realm_user_get_appPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_user_get_app'); - late final _realm_user_get_app = _realm_user_get_appPtr.asFunction< - ffi.Pointer Function(ffi.Pointer)>(); - - /// Get the custom user data from the user's access token. - /// - /// Returned value must be manually released with realm_free(). - /// - /// @return An Extended JSON document serialized as string, - /// or null if token doesn't have any custom data. - ffi.Pointer realm_user_get_custom_data( - ffi.Pointer arg0, - ) { - return _realm_user_get_custom_data( - arg0, - ); - } - - late final _realm_user_get_custom_dataPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_user_get_custom_data'); - late final _realm_user_get_custom_data = _realm_user_get_custom_dataPtr - .asFunction Function(ffi.Pointer)>(); - - /// returned pointer must be manually released with realm_free() - ffi.Pointer realm_user_get_device_id( - ffi.Pointer arg0, - ) { - return _realm_user_get_device_id( - arg0, - ); - } - - late final _realm_user_get_device_idPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_user_get_device_id'); - late final _realm_user_get_device_id = _realm_user_get_device_idPtr - .asFunction Function(ffi.Pointer)>(); - - /// Return the identiy for the user passed as argument - /// @param user ptr to the user for which the identiy has to be retrieved - /// @return a ptr to the identity string. This must be manually released with realm_free(). - ffi.Pointer realm_user_get_identity( - ffi.Pointer user, - ) { - return _realm_user_get_identity( - user, - ); - } - - late final _realm_user_get_identityPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_user_get_identity'); - late final _realm_user_get_identity = _realm_user_get_identityPtr - .asFunction Function(ffi.Pointer)>(); - - /// Get the user profile associated with this user. - /// - /// Returned value must be manually released with realm_free(). - /// - /// @return An Extended JSON document serialized as string, - /// or null if an error occurred. - ffi.Pointer realm_user_get_profile_data( - ffi.Pointer arg0, - ) { - return _realm_user_get_profile_data( - arg0, - ); - } - - late final _realm_user_get_profile_dataPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_user_get_profile_data'); - late final _realm_user_get_profile_data = _realm_user_get_profile_dataPtr - .asFunction Function(ffi.Pointer)>(); - - /// Return the refresh token associated with the user. - /// @return a string that represents the refresh token - ffi.Pointer realm_user_get_refresh_token( - ffi.Pointer arg0, - ) { - return _realm_user_get_refresh_token( - arg0, - ); - } - - late final _realm_user_get_refresh_tokenPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('realm_user_get_refresh_token'); - late final _realm_user_get_refresh_token = _realm_user_get_refresh_tokenPtr - .asFunction Function(ffi.Pointer)>(); - - /// Retrieve the state for the user passed as argument - /// @param user ptr to the user for which the state has to be retrieved - /// @return realm_user_state_e value - realm_user_state realm_user_get_state( - ffi.Pointer user, - ) { - return realm_user_state.fromValue(_realm_user_get_state( - user, - )); - } - - late final _realm_user_get_statePtr = _lookup< - ffi - .NativeFunction)>>( - 'realm_user_get_state'); - late final _realm_user_get_state = _realm_user_get_statePtr - .asFunction)>(); - - bool realm_user_is_logged_in( - ffi.Pointer arg0, - ) { - return _realm_user_is_logged_in( - arg0, - ); - } - - late final _realm_user_is_logged_inPtr = - _lookup)>>( - 'realm_user_is_logged_in'); - late final _realm_user_is_logged_in = _realm_user_is_logged_inPtr - .asFunction)>(); - - /// Log out the user and mark it as logged out. - /// - /// Any active sync sessions associated with this user will be stopped. - /// - /// @return true, if no errors occurred. - bool realm_user_log_out( - ffi.Pointer arg0, - ) { - return _realm_user_log_out( - arg0, - ); - } - - late final _realm_user_log_outPtr = - _lookup)>>( - 'realm_user_log_out'); - late final _realm_user_log_out = _realm_user_log_outPtr - .asFunction)>(); - late final addresses = _SymbolAddresses(this); } @@ -11554,101 +6665,18 @@ final class UnnamedUnion1 extends ffi.Union { @ffi.Double() external double dnum; - external realm_decimal128_t decimal128; - - external realm_object_id_t object_id; - - external realm_uuid_t uuid; - - external realm_link_t link; - - @ffi.Array.multi([16]) - external ffi.Array data; -} - -final class realm_app extends ffi.Opaque {} - -final class realm_app_config extends ffi.Opaque {} - -typedef realm_app_config_t = realm_app_config; - -final class realm_app_credentials extends ffi.Opaque {} - -typedef realm_app_credentials_t = realm_app_credentials; - -/// This type should never be returned from a function. -/// It's only meant as an asynchronous callback argument. -/// Pointers to this struct and its pointer members are only valid inside the scope -/// of the callback they were passed to. -final class realm_app_error extends ffi.Struct { - @ffi.UnsignedInt() - external int error; - - @realm_error_categories() - external int categories; - - external ffi.Pointer message; - - /// The underlying HTTP status code returned by the server, - /// otherwise zero. - @ffi.Int() - external int http_status_code; - - /// A link to MongoDB Realm server logs related to the error, - /// or NULL if error response didn't contain log information. - external ffi.Pointer link_to_server_logs; -} - -/// This type should never be returned from a function. -/// It's only meant as an asynchronous callback argument. -/// Pointers to this struct and its pointer members are only valid inside the scope -/// of the callback they were passed to. -typedef realm_app_error_t = realm_app_error; -typedef realm_app_t = realm_app; - -final class realm_app_user_apikey extends ffi.Struct { - external realm_object_id_t id; - - external ffi.Pointer key; - - external ffi.Pointer name; - - @ffi.Bool() - external bool disabled; -} + external realm_decimal128_t decimal128; -typedef realm_app_user_apikey_t = realm_app_user_apikey; + external realm_object_id_t object_id; -/// Completion callback for asynchronous Realm App operations that yield a user object. -/// -/// @param user User object produced by the operation, or null if it failed. -/// The pointer is alive only for the duration of the callback, -/// if you wish to use it further make a copy with realm_clone(). -/// @param error Pointer to an error object if the operation failed, otherwise null if it completed successfully. -typedef realm_app_user_completion_func_t - = ffi.Pointer>; -typedef realm_app_user_completion_func_tFunction = ffi.Void Function( - ffi.Pointer userdata, - ffi.Pointer user, - ffi.Pointer error); -typedef Dartrealm_app_user_completion_func_tFunction = void Function( - ffi.Pointer userdata, - ffi.Pointer user, - ffi.Pointer error); + external realm_uuid_t uuid; -final class realm_app_user_subscription_token extends ffi.Opaque {} + external realm_link_t link; -typedef realm_app_user_subscription_token_t = realm_app_user_subscription_token; + @ffi.Array.multi([16]) + external ffi.Array data; +} -/// Generic completion callback for asynchronous Realm App operations. -/// -/// @param error Pointer to an error object if the operation failed, otherwise null if it completed successfully. -typedef realm_app_void_completion_func_t - = ffi.Pointer>; -typedef realm_app_void_completion_func_tFunction = ffi.Void Function( - ffi.Pointer userdata, ffi.Pointer error); -typedef Dartrealm_app_void_completion_func_tFunction = void Function( - ffi.Pointer userdata, ffi.Pointer error); typedef realm_async_begin_write_func_t = ffi.Pointer>; typedef realm_async_begin_write_func_tFunction = ffi.Void Function( @@ -11667,67 +6695,6 @@ final class realm_async_error extends ffi.Opaque {} /// Error types typedef realm_async_error_t = realm_async_error; -final class realm_async_open_task extends ffi.Opaque {} - -/// invoked when the synchronized realm file has been downloaded -typedef realm_async_open_task_completion_func_t = ffi.Pointer< - ffi.NativeFunction>; -typedef realm_async_open_task_completion_func_tFunction = ffi.Void Function( - ffi.Pointer userdata, - ffi.Pointer realm, - ffi.Pointer error); -typedef Dartrealm_async_open_task_completion_func_tFunction = void Function( - ffi.Pointer userdata, - ffi.Pointer realm, - ffi.Pointer error); - -/// invoked once the file has been downloaded. Allows the caller to run some initial subscription before the completion -/// callback runs. -typedef realm_async_open_task_init_subscription_func_t = ffi.Pointer< - ffi.NativeFunction>; -typedef realm_async_open_task_init_subscription_func_tFunction - = ffi.Void Function(ffi.Pointer realm, - ffi.Pointer userdata); -typedef Dartrealm_async_open_task_init_subscription_func_tFunction - = void Function(ffi.Pointer realm, - ffi.Pointer userdata); - -final class realm_async_open_task_progress_notification_token - extends ffi.Opaque {} - -typedef realm_async_open_task_progress_notification_token_t - = realm_async_open_task_progress_notification_token; -typedef realm_async_open_task_t = realm_async_open_task; - -enum realm_auth_provider { - RLM_AUTH_PROVIDER_ANONYMOUS(0), - RLM_AUTH_PROVIDER_ANONYMOUS_NO_REUSE(1), - RLM_AUTH_PROVIDER_FACEBOOK(2), - RLM_AUTH_PROVIDER_GOOGLE(3), - RLM_AUTH_PROVIDER_APPLE(4), - RLM_AUTH_PROVIDER_CUSTOM(5), - RLM_AUTH_PROVIDER_EMAIL_PASSWORD(6), - RLM_AUTH_PROVIDER_FUNCTION(7), - RLM_AUTH_PROVIDER_API_KEY(8); - - final int value; - const realm_auth_provider(this.value); - - static realm_auth_provider fromValue(int value) => switch (value) { - 0 => RLM_AUTH_PROVIDER_ANONYMOUS, - 1 => RLM_AUTH_PROVIDER_ANONYMOUS_NO_REUSE, - 2 => RLM_AUTH_PROVIDER_FACEBOOK, - 3 => RLM_AUTH_PROVIDER_GOOGLE, - 4 => RLM_AUTH_PROVIDER_APPLE, - 5 => RLM_AUTH_PROVIDER_CUSTOM, - 6 => RLM_AUTH_PROVIDER_EMAIL_PASSWORD, - 7 => RLM_AUTH_PROVIDER_FUNCTION, - 8 => RLM_AUTH_PROVIDER_API_KEY, - _ => - throw ArgumentError("Unknown value for realm_auth_provider: $value"), - }; -} - final class realm_binary extends ffi.Struct { external ffi.Pointer data; @@ -12234,46 +7201,6 @@ final class realm_error extends ffi.Struct { typedef realm_error_categories = ffi.UnsignedInt; typedef Dartrealm_error_categories = int; typedef realm_error_t = realm_error; - -final class realm_flx_sync_mutable_subscription_set extends ffi.Opaque {} - -typedef realm_flx_sync_mutable_subscription_set_t - = realm_flx_sync_mutable_subscription_set; - -final class realm_flx_sync_subscription extends ffi.Opaque {} - -final class realm_flx_sync_subscription_desc extends ffi.Opaque {} - -final class realm_flx_sync_subscription_set extends ffi.Opaque {} - -enum realm_flx_sync_subscription_set_state { - RLM_SYNC_SUBSCRIPTION_UNCOMMITTED(0), - RLM_SYNC_SUBSCRIPTION_PENDING(1), - RLM_SYNC_SUBSCRIPTION_BOOTSTRAPPING(2), - RLM_SYNC_SUBSCRIPTION_COMPLETE(3), - RLM_SYNC_SUBSCRIPTION_ERROR(4), - RLM_SYNC_SUBSCRIPTION_SUPERSEDED(5), - RLM_SYNC_SUBSCRIPTION_AWAITING_MARK(6); - - final int value; - const realm_flx_sync_subscription_set_state(this.value); - - static realm_flx_sync_subscription_set_state fromValue(int value) => - switch (value) { - 0 => RLM_SYNC_SUBSCRIPTION_UNCOMMITTED, - 1 => RLM_SYNC_SUBSCRIPTION_PENDING, - 2 => RLM_SYNC_SUBSCRIPTION_BOOTSTRAPPING, - 3 => RLM_SYNC_SUBSCRIPTION_COMPLETE, - 4 => RLM_SYNC_SUBSCRIPTION_ERROR, - 5 => RLM_SYNC_SUBSCRIPTION_SUPERSEDED, - 6 => RLM_SYNC_SUBSCRIPTION_AWAITING_MARK, - _ => throw ArgumentError( - "Unknown value for realm_flx_sync_subscription_set_state: $value"), - }; -} - -typedef realm_flx_sync_subscription_set_t = realm_flx_sync_subscription_set; -typedef realm_flx_sync_subscription_t = realm_flx_sync_subscription; typedef realm_free_userdata_func_t = ffi.Pointer>; typedef realm_free_userdata_func_tFunction = ffi.Void Function( @@ -12281,101 +7208,6 @@ typedef realm_free_userdata_func_tFunction = ffi.Void Function( typedef Dartrealm_free_userdata_func_tFunction = void Function( ffi.Pointer userdata); -final class realm_http_header extends ffi.Struct { - external ffi.Pointer name; - - external ffi.Pointer value; -} - -typedef realm_http_header_t = realm_http_header; - -final class realm_http_request extends ffi.Struct { - @ffi.UnsignedInt() - external int method; - - external ffi.Pointer url; - - @ffi.Uint64() - external int timeout_ms; - - external ffi.Pointer headers; - - @ffi.Size() - external int num_headers; - - external ffi.Pointer body; - - @ffi.Size() - external int body_size; -} - -/// Callback function used by Core to make a HTTP request. -/// -/// Complete the request by calling realm_http_transport_complete_request(), -/// passing in the request_context pointer here and the received response. -/// Network request are expected to be asynchronous and can be completed on any thread. -/// -/// @param request The request to send. -/// @param request_context Internal state pointer of Core, needed by realm_http_transport_complete_request(). -typedef realm_http_request_func_t - = ffi.Pointer>; -typedef realm_http_request_func_tFunction = ffi.Void Function( - ffi.Pointer userdata, - realm_http_request_t request, - ffi.Pointer request_context); -typedef Dartrealm_http_request_func_tFunction = void Function( - ffi.Pointer userdata, - realm_http_request_t request, - ffi.Pointer request_context); - -/// HTTP transport -enum realm_http_request_method { - RLM_HTTP_REQUEST_METHOD_GET(0), - RLM_HTTP_REQUEST_METHOD_POST(1), - RLM_HTTP_REQUEST_METHOD_PATCH(2), - RLM_HTTP_REQUEST_METHOD_PUT(3), - RLM_HTTP_REQUEST_METHOD_DELETE(4); - - final int value; - const realm_http_request_method(this.value); - - static realm_http_request_method fromValue(int value) => switch (value) { - 0 => RLM_HTTP_REQUEST_METHOD_GET, - 1 => RLM_HTTP_REQUEST_METHOD_POST, - 2 => RLM_HTTP_REQUEST_METHOD_PATCH, - 3 => RLM_HTTP_REQUEST_METHOD_PUT, - 4 => RLM_HTTP_REQUEST_METHOD_DELETE, - _ => throw ArgumentError( - "Unknown value for realm_http_request_method: $value"), - }; -} - -typedef realm_http_request_t = realm_http_request; - -final class realm_http_response extends ffi.Struct { - @ffi.Int() - external int status_code; - - @ffi.Int() - external int custom_status_code; - - external ffi.Pointer headers; - - @ffi.Size() - external int num_headers; - - external ffi.Pointer body; - - @ffi.Size() - external int body_size; -} - -typedef realm_http_response_t = realm_http_response; - -final class realm_http_transport extends ffi.Opaque {} - -typedef realm_http_transport_t = realm_http_transport; - final class realm_index_range extends ffi.Struct { @ffi.Size() external int from; @@ -12458,46 +7290,6 @@ typedef Dartrealm_migration_func_tFunction = bool Function( ffi.Pointer old_realm, ffi.Pointer new_realm, ffi.Pointer schema); -typedef realm_mongodb_callback_t - = ffi.Pointer>; -typedef realm_mongodb_callback_tFunction = ffi.Void Function( - ffi.Pointer userdata, - realm_string_t bson, - ffi.Pointer app_error); -typedef Dartrealm_mongodb_callback_tFunction = void Function( - ffi.Pointer userdata, - realm_string_t bson, - ffi.Pointer app_error); - -final class realm_mongodb_collection extends ffi.Opaque {} - -typedef realm_mongodb_collection_t = realm_mongodb_collection; - -final class realm_mongodb_find_one_and_modify_options extends ffi.Struct { - external realm_string_t projection_bson; - - external realm_string_t sort_bson; - - @ffi.Bool() - external bool upsert; - - @ffi.Bool() - external bool return_new_document; -} - -typedef realm_mongodb_find_one_and_modify_options_t - = realm_mongodb_find_one_and_modify_options; - -final class realm_mongodb_find_options extends ffi.Struct { - external realm_string_t projection_bson; - - external realm_string_t sort_bson; - - @ffi.Int64() - external int limit; -} - -typedef realm_mongodb_find_options_t = realm_mongodb_find_options; final class realm_notification_token extends ffi.Opaque {} @@ -12539,18 +7331,6 @@ typedef realm_on_object_change_func_tFunction = ffi.Void Function( ffi.Pointer, ffi.Pointer); typedef Dartrealm_on_object_change_func_tFunction = void Function( ffi.Pointer, ffi.Pointer); -typedef realm_on_object_store_error_callback_t = ffi.Pointer< - ffi.NativeFunction>; -typedef realm_on_object_store_error_callback_tFunction = ffi.Bool Function( - ffi.Pointer, ffi.Pointer); -typedef Dartrealm_on_object_store_error_callback_tFunction = bool Function( - ffi.Pointer, ffi.Pointer); -typedef realm_on_object_store_thread_callback_t = ffi.Pointer< - ffi.NativeFunction>; -typedef realm_on_object_store_thread_callback_tFunction = ffi.Void Function( - ffi.Pointer userdata); -typedef Dartrealm_on_object_store_thread_callback_tFunction = void Function( - ffi.Pointer userdata); typedef realm_on_realm_change_func_t = ffi.Pointer>; typedef realm_on_realm_change_func_tFunction = ffi.Void Function( @@ -12684,48 +7464,6 @@ typedef realm_refresh_callback_token_t = realm_refresh_callback_token; final class realm_results extends ffi.Opaque {} typedef realm_results_t = realm_results; -typedef realm_return_apikey_func_t - = ffi.Pointer>; -typedef realm_return_apikey_func_tFunction = ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer); -typedef Dartrealm_return_apikey_func_tFunction = void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer); -typedef realm_return_apikey_list_func_t - = ffi.Pointer>; -typedef realm_return_apikey_list_func_tFunction = ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ffi.Pointer); -typedef Dartrealm_return_apikey_list_func_tFunction = void Function( - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer); -typedef realm_return_string_func_t - = ffi.Pointer>; -typedef realm_return_string_func_tFunction = ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer); -typedef Dartrealm_return_string_func_tFunction = void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer); - -final class realm_salted_file_ident extends ffi.Struct { - @ffi.Uint64() - external int ident; - - @ffi.Int64() - external int salt; -} - -typedef realm_salted_file_ident_t = realm_salted_file_ident; final class realm_scheduler extends ffi.Opaque {} @@ -12868,498 +7606,6 @@ final class realm_string extends ffi.Struct { /// - non-empty /// When the data member is non-NULL, and the size member is greater than 0. typedef realm_string_t = realm_string; -typedef realm_sync_after_client_reset_func_t = ffi - .Pointer>; -typedef realm_sync_after_client_reset_func_tFunction = ffi.Bool Function( - ffi.Pointer userdata, - ffi.Pointer before_realm, - ffi.Pointer after_realm, - ffi.Bool did_recover); -typedef Dartrealm_sync_after_client_reset_func_tFunction = bool Function( - ffi.Pointer userdata, - ffi.Pointer before_realm, - ffi.Pointer after_realm, - bool did_recover); -typedef realm_sync_before_client_reset_func_t = ffi - .Pointer>; -typedef realm_sync_before_client_reset_func_tFunction = ffi.Bool Function( - ffi.Pointer userdata, ffi.Pointer before_realm); -typedef Dartrealm_sync_before_client_reset_func_tFunction = bool Function( - ffi.Pointer userdata, ffi.Pointer before_realm); - -final class realm_sync_client_config extends ffi.Opaque {} - -typedef realm_sync_client_config_t = realm_sync_client_config; - -enum realm_sync_client_metadata_mode { - RLM_SYNC_CLIENT_METADATA_MODE_PLAINTEXT(0), - RLM_SYNC_CLIENT_METADATA_MODE_ENCRYPTED(1), - RLM_SYNC_CLIENT_METADATA_MODE_DISABLED(2); - - final int value; - const realm_sync_client_metadata_mode(this.value); - - static realm_sync_client_metadata_mode fromValue(int value) => - switch (value) { - 0 => RLM_SYNC_CLIENT_METADATA_MODE_PLAINTEXT, - 1 => RLM_SYNC_CLIENT_METADATA_MODE_ENCRYPTED, - 2 => RLM_SYNC_CLIENT_METADATA_MODE_DISABLED, - _ => throw ArgumentError( - "Unknown value for realm_sync_client_metadata_mode: $value"), - }; -} - -/// Sync -enum realm_sync_client_reconnect_mode { - RLM_SYNC_CLIENT_RECONNECT_MODE_NORMAL(0), - RLM_SYNC_CLIENT_RECONNECT_MODE_TESTING(1); - - final int value; - const realm_sync_client_reconnect_mode(this.value); - - static realm_sync_client_reconnect_mode fromValue(int value) => - switch (value) { - 0 => RLM_SYNC_CLIENT_RECONNECT_MODE_NORMAL, - 1 => RLM_SYNC_CLIENT_RECONNECT_MODE_TESTING, - _ => throw ArgumentError( - "Unknown value for realm_sync_client_reconnect_mode: $value"), - }; -} - -final class realm_sync_config extends ffi.Opaque {} - -typedef realm_sync_config_t = realm_sync_config; - -enum realm_sync_connection_state { - RLM_SYNC_CONNECTION_STATE_DISCONNECTED(0), - RLM_SYNC_CONNECTION_STATE_CONNECTING(1), - RLM_SYNC_CONNECTION_STATE_CONNECTED(2); - - final int value; - const realm_sync_connection_state(this.value); - - static realm_sync_connection_state fromValue(int value) => switch (value) { - 0 => RLM_SYNC_CONNECTION_STATE_DISCONNECTED, - 1 => RLM_SYNC_CONNECTION_STATE_CONNECTING, - 2 => RLM_SYNC_CONNECTION_STATE_CONNECTED, - _ => throw ArgumentError( - "Unknown value for realm_sync_connection_state: $value"), - }; -} - -typedef realm_sync_connection_state_changed_func_t = ffi.Pointer< - ffi.NativeFunction>; -typedef realm_sync_connection_state_changed_func_tFunction = ffi.Void Function( - ffi.Pointer userdata, - ffi.UnsignedInt old_state, - ffi.UnsignedInt new_state); -typedef Dartrealm_sync_connection_state_changed_func_tFunction = void Function( - ffi.Pointer userdata, - realm_sync_connection_state old_state, - realm_sync_connection_state new_state); - -/// This type should never be returned from a function. -/// It's only meant as an asynchronous callback argument. -/// Pointers to this struct and its pointer members are only valid inside the scope -/// of the callback they were passed to. -final class realm_sync_error extends ffi.Struct { - external realm_error_t status; - - external ffi.Pointer c_original_file_path_key; - - external ffi.Pointer c_recovery_file_path_key; - - @ffi.Bool() - external bool is_fatal; - - @ffi.Bool() - external bool is_unrecognized_by_client; - - @ffi.Bool() - external bool is_client_reset_requested; - - @ffi.UnsignedInt() - external int server_requests_action; - - external ffi.Pointer user_info_map; - - @ffi.Size() - external int user_info_length; - - external ffi.Pointer - compensating_writes; - - @ffi.Size() - external int compensating_writes_length; - - external ffi.Pointer user_code_error; -} - -enum realm_sync_error_action { - RLM_SYNC_ERROR_ACTION_NO_ACTION(0), - RLM_SYNC_ERROR_ACTION_PROTOCOL_VIOLATION(1), - RLM_SYNC_ERROR_ACTION_APPLICATION_BUG(2), - RLM_SYNC_ERROR_ACTION_WARNING(3), - RLM_SYNC_ERROR_ACTION_TRANSIENT(4), - RLM_SYNC_ERROR_ACTION_DELETE_REALM(5), - RLM_SYNC_ERROR_ACTION_CLIENT_RESET(6), - RLM_SYNC_ERROR_ACTION_CLIENT_RESET_NO_RECOVERY(7), - RLM_SYNC_ERROR_ACTION_MIGRATE_TO_FLX(8), - RLM_SYNC_ERROR_ACTION_REVERT_TO_PBS(9); - - final int value; - const realm_sync_error_action(this.value); - - static realm_sync_error_action fromValue(int value) => switch (value) { - 0 => RLM_SYNC_ERROR_ACTION_NO_ACTION, - 1 => RLM_SYNC_ERROR_ACTION_PROTOCOL_VIOLATION, - 2 => RLM_SYNC_ERROR_ACTION_APPLICATION_BUG, - 3 => RLM_SYNC_ERROR_ACTION_WARNING, - 4 => RLM_SYNC_ERROR_ACTION_TRANSIENT, - 5 => RLM_SYNC_ERROR_ACTION_DELETE_REALM, - 6 => RLM_SYNC_ERROR_ACTION_CLIENT_RESET, - 7 => RLM_SYNC_ERROR_ACTION_CLIENT_RESET_NO_RECOVERY, - 8 => RLM_SYNC_ERROR_ACTION_MIGRATE_TO_FLX, - 9 => RLM_SYNC_ERROR_ACTION_REVERT_TO_PBS, - _ => throw ArgumentError( - "Unknown value for realm_sync_error_action: $value"), - }; -} - -final class realm_sync_error_compensating_write_info extends ffi.Struct { - external ffi.Pointer reason; - - external ffi.Pointer object_name; - - external realm_value_t primary_key; -} - -typedef realm_sync_error_compensating_write_info_t - = realm_sync_error_compensating_write_info; -typedef realm_sync_error_handler_func_t - = ffi.Pointer>; -typedef realm_sync_error_handler_func_tFunction = ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - realm_sync_error_t); -typedef Dartrealm_sync_error_handler_func_tFunction = void Function( - ffi.Pointer, - ffi.Pointer, - realm_sync_error_t); - -/// This type should never be returned from a function. -/// It's only meant as an asynchronous callback argument. -/// Pointers to this struct and its pointer members are only valid inside the scope -/// of the callback they were passed to. -typedef realm_sync_error_t = realm_sync_error; - -final class realm_sync_error_user_info extends ffi.Struct { - external ffi.Pointer key; - - external ffi.Pointer value; -} - -typedef realm_sync_error_user_info_t = realm_sync_error_user_info; - -enum realm_sync_file_action { - RLM_SYNC_FILE_ACTION_DELETE_REALM(0), - RLM_SYNC_FILE_ACTION_BACK_UP_THEN_DELETE_REALM(1); - - final int value; - const realm_sync_file_action(this.value); - - static realm_sync_file_action fromValue(int value) => switch (value) { - 0 => RLM_SYNC_FILE_ACTION_DELETE_REALM, - 1 => RLM_SYNC_FILE_ACTION_BACK_UP_THEN_DELETE_REALM, - _ => throw ArgumentError( - "Unknown value for realm_sync_file_action: $value"), - }; -} - -final class realm_sync_manager extends ffi.Opaque {} - -typedef realm_sync_on_subscription_state_changed_t = ffi.Pointer< - ffi.NativeFunction>; -typedef realm_sync_on_subscription_state_changed_tFunction = ffi.Void Function( - ffi.Pointer userdata, ffi.UnsignedInt state); -typedef Dartrealm_sync_on_subscription_state_changed_tFunction = void Function( - ffi.Pointer userdata, - realm_flx_sync_subscription_set_state state); -typedef realm_sync_on_user_state_changed_t = ffi - .Pointer>; -typedef realm_sync_on_user_state_changed_tFunction = ffi.Void Function( - ffi.Pointer userdata, ffi.UnsignedInt s); -typedef Dartrealm_sync_on_user_state_changed_tFunction = void Function( - ffi.Pointer userdata, realm_user_state s); - -enum realm_sync_progress_direction { - RLM_SYNC_PROGRESS_DIRECTION_UPLOAD(0), - RLM_SYNC_PROGRESS_DIRECTION_DOWNLOAD(1); - - final int value; - const realm_sync_progress_direction(this.value); - - static realm_sync_progress_direction fromValue(int value) => switch (value) { - 0 => RLM_SYNC_PROGRESS_DIRECTION_UPLOAD, - 1 => RLM_SYNC_PROGRESS_DIRECTION_DOWNLOAD, - _ => throw ArgumentError( - "Unknown value for realm_sync_progress_direction: $value"), - }; -} - -typedef realm_sync_progress_func_t - = ffi.Pointer>; -typedef realm_sync_progress_func_tFunction = ffi.Void Function( - ffi.Pointer userdata, - ffi.Uint64 transferred_bytes, - ffi.Uint64 total_bytes, - ffi.Double progress_estimate); -typedef Dartrealm_sync_progress_func_tFunction = void Function( - ffi.Pointer userdata, - int transferred_bytes, - int total_bytes, - double progress_estimate); - -final class realm_sync_session extends ffi.Opaque {} - -final class realm_sync_session_connection_state_notification_token - extends ffi.Opaque {} - -typedef realm_sync_session_connection_state_notification_token_t - = realm_sync_session_connection_state_notification_token; - -enum realm_sync_session_resync_mode { - RLM_SYNC_SESSION_RESYNC_MODE_MANUAL(0), - RLM_SYNC_SESSION_RESYNC_MODE_DISCARD_LOCAL(1), - RLM_SYNC_SESSION_RESYNC_MODE_RECOVER(2), - RLM_SYNC_SESSION_RESYNC_MODE_RECOVER_OR_DISCARD(3); - - final int value; - const realm_sync_session_resync_mode(this.value); - - static realm_sync_session_resync_mode fromValue(int value) => switch (value) { - 0 => RLM_SYNC_SESSION_RESYNC_MODE_MANUAL, - 1 => RLM_SYNC_SESSION_RESYNC_MODE_DISCARD_LOCAL, - 2 => RLM_SYNC_SESSION_RESYNC_MODE_RECOVER, - 3 => RLM_SYNC_SESSION_RESYNC_MODE_RECOVER_OR_DISCARD, - _ => throw ArgumentError( - "Unknown value for realm_sync_session_resync_mode: $value"), - }; -} - -enum realm_sync_session_state { - RLM_SYNC_SESSION_STATE_ACTIVE(0), - RLM_SYNC_SESSION_STATE_DYING(1), - RLM_SYNC_SESSION_STATE_INACTIVE(2), - RLM_SYNC_SESSION_STATE_WAITING_FOR_ACCESS_TOKEN(3), - RLM_SYNC_SESSION_STATE_PAUSED(4); - - final int value; - const realm_sync_session_state(this.value); - - static realm_sync_session_state fromValue(int value) => switch (value) { - 0 => RLM_SYNC_SESSION_STATE_ACTIVE, - 1 => RLM_SYNC_SESSION_STATE_DYING, - 2 => RLM_SYNC_SESSION_STATE_INACTIVE, - 3 => RLM_SYNC_SESSION_STATE_WAITING_FOR_ACCESS_TOKEN, - 4 => RLM_SYNC_SESSION_STATE_PAUSED, - _ => throw ArgumentError( - "Unknown value for realm_sync_session_state: $value"), - }; -} - -enum realm_sync_session_stop_policy { - RLM_SYNC_SESSION_STOP_POLICY_IMMEDIATELY(0), - RLM_SYNC_SESSION_STOP_POLICY_LIVE_INDEFINITELY(1), - RLM_SYNC_SESSION_STOP_POLICY_AFTER_CHANGES_UPLOADED(2); - - final int value; - const realm_sync_session_stop_policy(this.value); - - static realm_sync_session_stop_policy fromValue(int value) => switch (value) { - 0 => RLM_SYNC_SESSION_STOP_POLICY_IMMEDIATELY, - 1 => RLM_SYNC_SESSION_STOP_POLICY_LIVE_INDEFINITELY, - 2 => RLM_SYNC_SESSION_STOP_POLICY_AFTER_CHANGES_UPLOADED, - _ => throw ArgumentError( - "Unknown value for realm_sync_session_stop_policy: $value"), - }; -} - -typedef realm_sync_session_t = realm_sync_session; - -final class realm_sync_socket extends ffi.Opaque {} - -final class realm_sync_socket_callback extends ffi.Opaque {} - -enum realm_sync_socket_callback_result { - /// These error values are pulled directly from realm_errno_e - RLM_ERR_SYNC_SOCKET_SUCCESS(0), - RLM_ERR_SYNC_SOCKET_OPERATION_ABORTED(1027), - RLM_ERR_SYNC_SOCKET_RUNTIME(1000), - RLM_ERR_SYNC_SOCKET_OUT_OF_MEMORY(1003), - RLM_ERR_SYNC_SOCKET_ADDRESS_SPACE_EXHAUSTED(1005), - RLM_ERR_SYNC_SOCKET_CONNECTION_CLOSED(1030), - RLM_ERR_SYNC_SOCKET_NOT_SUPPORTED(2001), - RLM_ERR_SYNC_SOCKET_INVALID_ARGUMENT(3000); - - final int value; - const realm_sync_socket_callback_result(this.value); - - static realm_sync_socket_callback_result fromValue(int value) => - switch (value) { - 0 => RLM_ERR_SYNC_SOCKET_SUCCESS, - 1027 => RLM_ERR_SYNC_SOCKET_OPERATION_ABORTED, - 1000 => RLM_ERR_SYNC_SOCKET_RUNTIME, - 1003 => RLM_ERR_SYNC_SOCKET_OUT_OF_MEMORY, - 1005 => RLM_ERR_SYNC_SOCKET_ADDRESS_SPACE_EXHAUSTED, - 1030 => RLM_ERR_SYNC_SOCKET_CONNECTION_CLOSED, - 2001 => RLM_ERR_SYNC_SOCKET_NOT_SUPPORTED, - 3000 => RLM_ERR_SYNC_SOCKET_INVALID_ARGUMENT, - _ => throw ArgumentError( - "Unknown value for realm_sync_socket_callback_result: $value"), - }; -} - -/// Called when the Sync Client is initiating a connection to the server. The endpoint -/// structure contains the server address/URL and the websocket_observer will need to -/// be stored locally in the WebSocket CAPI implementation so it can be used with the -/// realm_sync_socket_websocket_[connected|message|error|closed]() functions when -/// providing WebSocket status or data to the Sync Client. -typedef realm_sync_socket_connect_func_t - = ffi.Pointer>; -typedef realm_sync_socket_connect_func_tFunction - = realm_sync_socket_websocket_t Function( - ffi.Pointer userdata, - realm_websocket_endpoint_t endpoint, - ffi.Pointer websocket_observer); - -/// Called when a Sync Socket Timer is being created, which will start the timer countdown -/// immediately. The Timer CAPI implementation will need to be stored locally so it can -/// be used when calling realm_sync_socket_timer_complete() when the timer countdown -/// reaches 0 (i.e. expired) or realm_sync_socket_timer_canceled() when the timer is canceled. -/// The timer_callback pointer does not need to be released by the CAPI implementation. -typedef realm_sync_socket_create_timer_func_t = ffi - .Pointer>; -typedef realm_sync_socket_create_timer_func_tFunction - = realm_sync_socket_timer_t Function( - ffi.Pointer userdata, - ffi.Uint64 delay_ms, - ffi.Pointer timer_callback); -typedef Dartrealm_sync_socket_create_timer_func_tFunction - = realm_sync_socket_timer_t Function( - ffi.Pointer userdata, - int delay_ms, - ffi.Pointer timer_callback); -typedef realm_sync_socket_post_callback_t = realm_sync_socket_callback; - -/// Called when the Sync Client posts a callback handler to be run within the context -/// of the event loop. -/// The post_callback pointer does not need to be released by the CAPI implementation. -typedef realm_sync_socket_post_func_t - = ffi.Pointer>; -typedef realm_sync_socket_post_func_tFunction = ffi.Void Function( - ffi.Pointer userdata, - ffi.Pointer post_callback); -typedef Dartrealm_sync_socket_post_func_tFunction = void Function( - ffi.Pointer userdata, - ffi.Pointer post_callback); - -/// The following definitions are intended for internal state and structures -/// used by the Sync Client. These values should be retained by the Platform -/// Networking CAPI implementation so they can be provided back to the Platform -/// Networking CAPI functions. -typedef realm_sync_socket_t = realm_sync_socket; -typedef realm_sync_socket_timer_callback_t = realm_sync_socket_callback; - -/// Called when a Sync Socket Timer has been explicitly canceled or the Timer is being -/// destroyed. Use the realm_sync_socket_timer_canceled() function to notify the Sync Client -/// that the timer cancel is complete. NOTE: This function will always be called before the -/// timer is destroyed (even if the timer has completed), but the timer callback should only -/// be executed one time. -typedef realm_sync_socket_timer_canceled_func_t = ffi.Pointer< - ffi.NativeFunction>; -typedef realm_sync_socket_timer_canceled_func_tFunction = ffi.Void Function( - ffi.Pointer userdata, realm_sync_socket_timer_t timer_userdata); -typedef Dartrealm_sync_socket_timer_canceled_func_tFunction = void Function( - ffi.Pointer userdata, realm_sync_socket_timer_t timer_userdata); - -/// Called when the timer object has been destroyed so the Sync Socket Timer CAPI -/// implementation can clean up its timer resources. -typedef realm_sync_socket_timer_free_func_t = ffi - .Pointer>; -typedef realm_sync_socket_timer_free_func_tFunction = ffi.Void Function( - ffi.Pointer userdata, realm_sync_socket_timer_t timer_userdata); -typedef Dartrealm_sync_socket_timer_free_func_tFunction = void Function( - ffi.Pointer userdata, realm_sync_socket_timer_t timer_userdata); -typedef realm_sync_socket_timer_t = ffi.Pointer; - -/// Called by a connection in the Sync Client when it needs to send data to the server. The -/// write_callback is used with realm_sync_socket_write_complete() to inform the connection -/// that the data has been transferred successfully. -/// If an error occurs during the async write operation, it needs to be provided to the -/// write_callback handler, and the websocket is exepected to be closed by calling -/// realm_sync_socket_websocket_error() followed by providing the error code and reason to -/// realm_sync_socket_websocket_closed(). -/// The write_callback pointer does not need to be released by the CAPI implementation. -typedef realm_sync_socket_websocket_async_write_func_t = ffi.Pointer< - ffi.NativeFunction>; -typedef realm_sync_socket_websocket_async_write_func_tFunction - = ffi.Void Function( - ffi.Pointer userdata, - realm_sync_socket_websocket_t websocket, - ffi.Pointer data, - ffi.Size size, - ffi.Pointer write_callback); -typedef Dartrealm_sync_socket_websocket_async_write_func_tFunction - = void Function( - ffi.Pointer userdata, - realm_sync_socket_websocket_t websocket, - ffi.Pointer data, - int size, - ffi.Pointer write_callback); - -/// Called when the websocket has been destroyed in the Sync Client - no more write callbacks or observer -/// functions should be called when this function is called. -typedef realm_sync_socket_websocket_free_func_t = ffi.Pointer< - ffi.NativeFunction>; -typedef realm_sync_socket_websocket_free_func_tFunction = ffi.Void Function( - ffi.Pointer userdata, realm_sync_socket_websocket_t websocket); -typedef Dartrealm_sync_socket_websocket_free_func_tFunction = void Function( - ffi.Pointer userdata, realm_sync_socket_websocket_t websocket); -typedef realm_sync_socket_websocket_t = ffi.Pointer; -typedef realm_sync_socket_write_callback_t = realm_sync_socket_callback; -typedef realm_sync_ssl_verify_func_t - = ffi.Pointer>; -typedef realm_sync_ssl_verify_func_tFunction = ffi.Bool Function( - ffi.Pointer userdata, - ffi.Pointer server_address, - ffi.Short server_port, - ffi.Pointer pem_data, - ffi.Size pem_size, - ffi.Int preverify_ok, - ffi.Int depth); -typedef Dartrealm_sync_ssl_verify_func_tFunction = bool Function( - ffi.Pointer userdata, - ffi.Pointer server_address, - int server_port, - ffi.Pointer pem_data, - int pem_size, - int preverify_ok, - int depth); - -/// Callback function invoked by the sync session once it has uploaded or download -/// all available changesets. See @a realm_sync_session_wait_for_upload and -/// @a realm_sync_session_wait_for_download. -/// -/// This callback is invoked on the sync client's worker thread. -/// -/// @param error Null, if the operation completed successfully. -typedef realm_sync_wait_for_completion_func_t = ffi - .Pointer>; -typedef realm_sync_wait_for_completion_func_tFunction = ffi.Void Function( - ffi.Pointer userdata, ffi.Pointer error); -typedef Dartrealm_sync_wait_for_completion_func_tFunction = void Function( - ffi.Pointer userdata, ffi.Pointer error); typedef realm_t = shared_realm; final class realm_thread_safe_reference extends ffi.Opaque {} @@ -13376,38 +7622,6 @@ final class realm_timestamp extends ffi.Struct { typedef realm_timestamp_t = realm_timestamp; -final class realm_user extends ffi.Opaque {} - -final class realm_user_identity extends ffi.Struct { - /// Ptr to null terminated string representing user identity (memory has to be freed by SDK) - external ffi.Pointer id; - - /// Enum representing the list of auth providers - @ffi.UnsignedInt() - external int provider_type; -} - -typedef realm_user_identity_t = realm_user_identity; - -enum realm_user_state { - RLM_USER_STATE_LOGGED_OUT(0), - RLM_USER_STATE_LOGGED_IN(1), - RLM_USER_STATE_REMOVED(2); - - final int value; - const realm_user_state(this.value); - - static realm_user_state fromValue(int value) => switch (value) { - 0 => RLM_USER_STATE_LOGGED_OUT, - 1 => RLM_USER_STATE_LOGGED_IN, - 2 => RLM_USER_STATE_REMOVED, - _ => throw ArgumentError("Unknown value for realm_user_state: $value"), - }; -} - -/// App -typedef realm_user_t = realm_user; - final class realm_uuid extends ffi.Struct { @ffi.Array.multi([16]) external ffi.Array bytes; @@ -13473,98 +7687,6 @@ final class realm_version_id extends ffi.Struct { typedef realm_version_id_t = realm_version_id; -enum realm_web_socket_errno { - RLM_ERR_WEBSOCKET_OK(1000), - RLM_ERR_WEBSOCKET_GOINGAWAY(1001), - RLM_ERR_WEBSOCKET_PROTOCOLERROR(1002), - RLM_ERR_WEBSOCKET_UNSUPPORTEDDATA(1003), - RLM_ERR_WEBSOCKET_RESERVED(1004), - RLM_ERR_WEBSOCKET_NOSTATUSRECEIVED(1005), - RLM_ERR_WEBSOCKET_ABNORMALCLOSURE(1006), - RLM_ERR_WEBSOCKET_INVALIDPAYLOADDATA(1007), - RLM_ERR_WEBSOCKET_POLICYVIOLATION(1008), - RLM_ERR_WEBSOCKET_MESSAGETOOBIG(1009), - RLM_ERR_WEBSOCKET_INAVALIDEXTENSION(1010), - RLM_ERR_WEBSOCKET_INTERNALSERVERERROR(1011), - RLM_ERR_WEBSOCKET_TLSHANDSHAKEFAILED(1015), - RLM_ERR_WEBSOCKET_UNAUTHORIZED(4001), - RLM_ERR_WEBSOCKET_FORBIDDEN(4002), - RLM_ERR_WEBSOCKET_MOVEDPERMANENTLY(4003), - RLM_ERR_WEBSOCKET_CLIENT_TOO_OLD(4004), - RLM_ERR_WEBSOCKET_CLIENT_TOO_NEW(4005), - RLM_ERR_WEBSOCKET_PROTOCOL_MISMATCH(4006), - RLM_ERR_WEBSOCKET_RESOLVE_FAILED(4400), - RLM_ERR_WEBSOCKET_CONNECTION_FAILED(4401), - RLM_ERR_WEBSOCKET_READ_ERROR(4402), - RLM_ERR_WEBSOCKET_WRITE_ERROR(4403), - RLM_ERR_WEBSOCKET_RETRY_ERROR(4404), - RLM_ERR_WEBSOCKET_FATAL_ERROR(4405); - - final int value; - const realm_web_socket_errno(this.value); - - static realm_web_socket_errno fromValue(int value) => switch (value) { - 1000 => RLM_ERR_WEBSOCKET_OK, - 1001 => RLM_ERR_WEBSOCKET_GOINGAWAY, - 1002 => RLM_ERR_WEBSOCKET_PROTOCOLERROR, - 1003 => RLM_ERR_WEBSOCKET_UNSUPPORTEDDATA, - 1004 => RLM_ERR_WEBSOCKET_RESERVED, - 1005 => RLM_ERR_WEBSOCKET_NOSTATUSRECEIVED, - 1006 => RLM_ERR_WEBSOCKET_ABNORMALCLOSURE, - 1007 => RLM_ERR_WEBSOCKET_INVALIDPAYLOADDATA, - 1008 => RLM_ERR_WEBSOCKET_POLICYVIOLATION, - 1009 => RLM_ERR_WEBSOCKET_MESSAGETOOBIG, - 1010 => RLM_ERR_WEBSOCKET_INAVALIDEXTENSION, - 1011 => RLM_ERR_WEBSOCKET_INTERNALSERVERERROR, - 1015 => RLM_ERR_WEBSOCKET_TLSHANDSHAKEFAILED, - 4001 => RLM_ERR_WEBSOCKET_UNAUTHORIZED, - 4002 => RLM_ERR_WEBSOCKET_FORBIDDEN, - 4003 => RLM_ERR_WEBSOCKET_MOVEDPERMANENTLY, - 4004 => RLM_ERR_WEBSOCKET_CLIENT_TOO_OLD, - 4005 => RLM_ERR_WEBSOCKET_CLIENT_TOO_NEW, - 4006 => RLM_ERR_WEBSOCKET_PROTOCOL_MISMATCH, - 4400 => RLM_ERR_WEBSOCKET_RESOLVE_FAILED, - 4401 => RLM_ERR_WEBSOCKET_CONNECTION_FAILED, - 4402 => RLM_ERR_WEBSOCKET_READ_ERROR, - 4403 => RLM_ERR_WEBSOCKET_WRITE_ERROR, - 4404 => RLM_ERR_WEBSOCKET_RETRY_ERROR, - 4405 => RLM_ERR_WEBSOCKET_FATAL_ERROR, - _ => throw ArgumentError( - "Unknown value for realm_web_socket_errno: $value"), - }; -} - -/// Sync Socket Provider types -final class realm_websocket_endpoint extends ffi.Struct { - /// Host address - external ffi.Pointer address; - - /// Host port number - @ffi.Uint16() - external int port; - - /// Includes access token in query. - external ffi.Pointer path; - - /// Array of one or more websocket protocols - external ffi.Pointer> protocols; - - /// Number of protocols in array - @ffi.Size() - external int num_protocols; - - /// true if SSL should be used - @ffi.Bool() - external bool is_ssl; -} - -/// Sync Socket Provider types -typedef realm_websocket_endpoint_t = realm_websocket_endpoint; - -final class realm_websocket_observer extends ffi.Opaque {} - -typedef realm_websocket_observer_t = realm_websocket_observer; - final class realm_work_queue extends ffi.Opaque {} typedef realm_work_queue_t = realm_work_queue; diff --git a/packages/realm_dart/src/realm-core b/packages/realm_dart/src/realm-core index 60867846a..f98720a07 160000 --- a/packages/realm_dart/src/realm-core +++ b/packages/realm_dart/src/realm-core @@ -1 +1 @@ -Subproject commit 60867846a0aca0c7da5e482282b293236f730216 +Subproject commit f98720a07e6150c41c953e1937108225550ba155