RLMObjectStore.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. NS_ASSUME_NONNULL_BEGIN
  24. //
  25. // Accessor Creation
  26. //
  27. // create or get cached accessors for the given schema
  28. void RLMRealmCreateAccessors(RLMSchema *schema);
  29. //
  30. // Adding, Removing, Getting Objects
  31. //
  32. // add an object to the given realm
  33. void RLMAddObjectToRealm(RLMObjectBase *object, RLMRealm *realm, bool createOrUpdate);
  34. // delete an object from its realm
  35. void RLMDeleteObjectFromRealm(RLMObjectBase *object, RLMRealm *realm);
  36. // deletes all objects from a realm
  37. void RLMDeleteAllObjectsFromRealm(RLMRealm *realm);
  38. // get objects of a given class
  39. RLMResults *RLMGetObjects(RLMRealm *realm, NSString *objectClassName, NSPredicate * _Nullable predicate)
  40. NS_RETURNS_RETAINED;
  41. // get an object with the given primary key
  42. id _Nullable RLMGetObject(RLMRealm *realm, NSString *objectClassName, id _Nullable key) NS_RETURNS_RETAINED;
  43. // create object from array or dictionary
  44. RLMObjectBase *RLMCreateObjectInRealmWithValue(RLMRealm *realm, NSString *className,
  45. id _Nullable value, bool createOrUpdate)
  46. NS_RETURNS_RETAINED;
  47. //
  48. // Accessor Creation
  49. //
  50. // switch List<> properties from being backed by unmanaged RLMArrays to RLMManagedArray
  51. void RLMInitializeSwiftAccessorGenerics(RLMObjectBase *object);
  52. #ifdef __cplusplus
  53. }
  54. namespace realm {
  55. class Table;
  56. template<typename T> class BasicRowExpr;
  57. using RowExpr = BasicRowExpr<Table>;
  58. }
  59. class RLMClassInfo;
  60. // Create accessors
  61. RLMObjectBase *RLMCreateObjectAccessor(RLMRealm *realm, RLMClassInfo& info,
  62. NSUInteger index) NS_RETURNS_RETAINED;
  63. RLMObjectBase *RLMCreateObjectAccessor(RLMRealm *realm, RLMClassInfo& info,
  64. realm::RowExpr row) NS_RETURNS_RETAINED;
  65. #endif
  66. NS_ASSUME_NONNULL_END