RLMObjectStore.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. ////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2014 Realm Inc.
  4. //
  5. // Licensed under the Apache License, Version 2.0 (the "License");
  6. // you may not use this file except in compliance with the License.
  7. // You may obtain a copy of the License at
  8. //
  9. // http://www.apache.org/licenses/LICENSE-2.0
  10. //
  11. // Unless required by applicable law or agreed to in writing, software
  12. // distributed under the License is distributed on an "AS IS" BASIS,
  13. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. // See the License for the specific language governing permissions and
  15. // limitations under the License.
  16. //
  17. ////////////////////////////////////////////////////////////////////////////
  18. #import <Foundation/Foundation.h>
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. @class RLMRealm, RLMSchema, RLMObjectBase, RLMResults, RLMProperty;
  23. typedef NS_ENUM(NSUInteger, RLMUpdatePolicy) {
  24. RLMUpdatePolicyError = 1,
  25. RLMUpdatePolicyUpdateChanged = 3,
  26. RLMUpdatePolicyUpdateAll = 2,
  27. };
  28. NS_ASSUME_NONNULL_BEGIN
  29. void RLMVerifyHasPrimaryKey(Class cls);
  30. //
  31. // Accessor Creation
  32. //
  33. // create or get cached accessors for the given schema
  34. void RLMRealmCreateAccessors(RLMSchema *schema);
  35. //
  36. // Adding, Removing, Getting Objects
  37. //
  38. // add an object to the given realm
  39. void RLMAddObjectToRealm(RLMObjectBase *object, RLMRealm *realm, RLMUpdatePolicy);
  40. // delete an object from its realm
  41. void RLMDeleteObjectFromRealm(RLMObjectBase *object, RLMRealm *realm);
  42. // deletes all objects from a realm
  43. void RLMDeleteAllObjectsFromRealm(RLMRealm *realm);
  44. // get objects of a given class
  45. RLMResults *RLMGetObjects(RLMRealm *realm, NSString *objectClassName, NSPredicate * _Nullable predicate)
  46. NS_RETURNS_RETAINED;
  47. // get an object with the given primary key
  48. id _Nullable RLMGetObject(RLMRealm *realm, NSString *objectClassName, id _Nullable key) NS_RETURNS_RETAINED;
  49. // create object from array or dictionary
  50. RLMObjectBase *RLMCreateObjectInRealmWithValue(RLMRealm *realm, NSString *className,
  51. id _Nullable value, RLMUpdatePolicy updatePolicy)
  52. NS_RETURNS_RETAINED;
  53. //
  54. // Accessor Creation
  55. //
  56. // switch List<> properties from being backed by unmanaged RLMArrays to RLMManagedArray
  57. void RLMInitializeSwiftAccessorGenerics(RLMObjectBase *object);
  58. #ifdef __cplusplus
  59. }
  60. namespace realm {
  61. class Table;
  62. class Obj;
  63. }
  64. class RLMClassInfo;
  65. // Create accessors
  66. RLMObjectBase *RLMCreateObjectAccessor(RLMClassInfo& info, int64_t key) NS_RETURNS_RETAINED;
  67. RLMObjectBase *RLMCreateObjectAccessor(RLMClassInfo& info, realm::Obj&& obj) NS_RETURNS_RETAINED;
  68. #endif
  69. NS_ASSUME_NONNULL_END