RLMObject_Private.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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/RLMObjectBase_Dynamic.h>
  19. NS_ASSUME_NONNULL_BEGIN
  20. // RLMObject accessor and read/write realm
  21. @interface RLMObjectBase () {
  22. @public
  23. RLMRealm *_realm;
  24. __unsafe_unretained RLMObjectSchema *_objectSchema;
  25. }
  26. // unmanaged initializer
  27. - (instancetype)initWithValue:(id)value schema:(RLMSchema *)schema NS_DESIGNATED_INITIALIZER;
  28. // live accessor initializer
  29. - (instancetype)initWithRealm:(__unsafe_unretained RLMRealm *const)realm
  30. schema:(RLMObjectSchema *)schema NS_DESIGNATED_INITIALIZER;
  31. // shared schema for this class
  32. + (nullable RLMObjectSchema *)sharedSchema;
  33. // provide injection point for alternative Swift object util class
  34. + (Class)objectUtilClass:(BOOL)isSwift;
  35. @end
  36. @interface RLMObject ()
  37. // unmanaged initializer
  38. - (instancetype)initWithValue:(id)value schema:(RLMSchema *)schema NS_DESIGNATED_INITIALIZER;
  39. // live accessor initializer
  40. - (instancetype)initWithRealm:(__unsafe_unretained RLMRealm *const)realm
  41. schema:(RLMObjectSchema *)schema NS_DESIGNATED_INITIALIZER;
  42. @end
  43. @interface RLMDynamicObject : RLMObject
  44. @end
  45. // A reference to an object's row that doesn't keep the object accessor alive.
  46. // Used by some Swift property types, such as LinkingObjects, to avoid retain cycles
  47. // with their containing object.
  48. @interface RLMWeakObjectHandle : NSObject<NSCopying>
  49. - (instancetype)initWithObject:(RLMObjectBase *)object;
  50. // Consumes the row, so can only usefully be called once.
  51. @property (nonatomic, readonly) RLMObjectBase *object;
  52. @end
  53. // Calls valueForKey: and re-raises NSUndefinedKeyExceptions
  54. FOUNDATION_EXTERN id _Nullable RLMValidatedValueForProperty(id object, NSString *key, NSString *className);
  55. // Compare two RLObjectBases
  56. FOUNDATION_EXTERN BOOL RLMObjectBaseAreEqual(RLMObjectBase * _Nullable o1, RLMObjectBase * _Nullable o2);
  57. typedef void (^RLMObjectNotificationCallback)(NSArray<NSString *> *_Nullable propertyNames,
  58. NSArray *_Nullable oldValues,
  59. NSArray *_Nullable newValues,
  60. NSError *_Nullable error);
  61. FOUNDATION_EXTERN RLMNotificationToken *RLMObjectAddNotificationBlock(RLMObjectBase *obj, RLMObjectNotificationCallback block);
  62. // Get ObjectUil class for objc or swift
  63. FOUNDATION_EXTERN Class RLMObjectUtilClass(BOOL isSwift);
  64. FOUNDATION_EXTERN const NSUInteger RLMDescriptionMaxDepth;
  65. @class RLMProperty, RLMArray;
  66. @interface RLMObjectUtil : NSObject
  67. + (nullable NSArray<NSString *> *)ignoredPropertiesForClass:(Class)cls;
  68. + (nullable NSArray<NSString *> *)indexedPropertiesForClass:(Class)cls;
  69. + (nullable NSDictionary<NSString *, NSDictionary<NSString *, NSString *> *> *)linkingObjectsPropertiesForClass:(Class)cls;
  70. + (nullable NSArray<NSString *> *)getGenericListPropertyNames:(id)obj;
  71. + (nullable NSDictionary<NSString *, NSString *> *)getLinkingObjectsProperties:(id)object;
  72. + (nullable NSDictionary<NSString *, NSNumber *> *)getOptionalProperties:(id)obj;
  73. + (nullable NSArray<NSString *> *)requiredPropertiesForClass:(Class)cls;
  74. @end
  75. NS_ASSUME_NONNULL_END