RLMObjectStore.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. template<typename T> class BasicRowExpr;
  63. using RowExpr = BasicRowExpr<Table>;
  64. }
  65. class RLMClassInfo;
  66. // Create accessors
  67. RLMObjectBase *RLMCreateObjectAccessor(RLMClassInfo& info, NSUInteger index) NS_RETURNS_RETAINED;
  68. RLMObjectBase *RLMCreateObjectAccessor(RLMClassInfo& info, realm::RowExpr row) NS_RETURNS_RETAINED;
  69. #endif
  70. NS_ASSUME_NONNULL_END