RLMObjectStore.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 <Realm/RLMConstants.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. RLM_HEADER_AUDIT_BEGIN(nullability)
  29. void RLMVerifyHasPrimaryKey(Class cls);
  30. void RLMVerifyInWriteTransaction(RLMRealm *const realm);
  31. //
  32. // Adding, Removing, Getting Objects
  33. //
  34. // add an object to the given realm
  35. void RLMAddObjectToRealm(RLMObjectBase *object, RLMRealm *realm, RLMUpdatePolicy);
  36. // delete an object from its realm
  37. void RLMDeleteObjectFromRealm(RLMObjectBase *object, RLMRealm *realm);
  38. // deletes all objects from a realm
  39. void RLMDeleteAllObjectsFromRealm(RLMRealm *realm);
  40. // get objects of a given class
  41. RLMResults *RLMGetObjects(RLMRealm *realm, NSString *objectClassName, NSPredicate * _Nullable predicate)
  42. NS_RETURNS_RETAINED;
  43. // get an object with the given primary key
  44. id _Nullable RLMGetObject(RLMRealm *realm, NSString *objectClassName, id _Nullable key) NS_RETURNS_RETAINED;
  45. // create object from array or dictionary
  46. RLMObjectBase *RLMCreateObjectInRealmWithValue(RLMRealm *realm, NSString *className,
  47. id _Nullable value, RLMUpdatePolicy updatePolicy)
  48. NS_RETURNS_RETAINED;
  49. // creates an asymmetric object and doesn't return
  50. void RLMCreateAsymmetricObjectInRealm(RLMRealm *realm, NSString *className, id value);
  51. //
  52. // Accessor Creation
  53. //
  54. // Perform the per-property accessor initialization for a managed RealmSwiftObject
  55. // promotingExisting should be true if the object was previously used as an
  56. // unmanaged object, and false if it is a newly created object.
  57. void RLMInitializeSwiftAccessor(RLMObjectBase *object, bool promotingExisting);
  58. #ifdef __cplusplus
  59. }
  60. namespace realm {
  61. class Obj;
  62. class Table;
  63. struct ColKey;
  64. struct ObjLink;
  65. }
  66. class RLMClassInfo;
  67. // get an object with a given table & object key
  68. RLMObjectBase *RLMObjectFromObjLink(RLMRealm *realm,
  69. realm::ObjLink&& objLink,
  70. bool parentIsSwiftObject) NS_RETURNS_RETAINED;
  71. // Create accessors
  72. RLMObjectBase *RLMCreateObjectAccessor(RLMClassInfo& info, int64_t key) NS_RETURNS_RETAINED;
  73. RLMObjectBase *RLMCreateObjectAccessor(RLMClassInfo& info, realm::Obj&& obj) NS_RETURNS_RETAINED;
  74. #endif
  75. RLM_HEADER_AUDIT_END(nullability)