123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- #import "RLMAccessor.h"
- #import "object_accessor.hpp"
- #import "RLMUtil.hpp"
- @class RLMRealm;
- class RLMClassInfo;
- class RLMObservationInfo;
- struct RLMOptionalId {
- id value;
- RLMOptionalId(id value) : value(value) { }
- explicit operator bool() const noexcept { return value; }
- id operator*() const noexcept { return value; }
- };
- class RLMAccessorContext {
- public:
-
- RLMAccessorContext(RLMAccessorContext& parent, realm::Property const& property);
- id box(realm::List&&);
- id box(realm::Results&&);
- id box(realm::Object&&);
- id box(realm::Obj&&);
- id box(bool v) { return @(v); }
- id box(double v) { return @(v); }
- id box(float v) { return @(v); }
- id box(long long v) { return @(v); }
- id box(realm::StringData v) { return RLMStringDataToNSString(v) ?: NSNull.null; }
- id box(realm::BinaryData v) { return RLMBinaryDataToNSData(v) ?: NSNull.null; }
- id box(realm::Timestamp v) { return RLMTimestampToNSDate(v) ?: NSNull.null; }
- id box(realm::Mixed v) { return RLMMixedToObjc(v); }
- id box(realm::util::Optional<bool> v) { return v ? @(*v) : NSNull.null; }
- id box(realm::util::Optional<double> v) { return v ? @(*v) : NSNull.null; }
- id box(realm::util::Optional<float> v) { return v ? @(*v) : NSNull.null; }
- id box(realm::util::Optional<int64_t> v) { return v ? @(*v) : NSNull.null; }
- void will_change(realm::Obj const&, realm::Property const&);
- void will_change(realm::Object& obj, realm::Property const& prop) { will_change(obj.obj(), prop); }
- void did_change();
- RLMOptionalId value_for_property(id dict, realm::Property const&, size_t prop_index);
- RLMOptionalId default_value_for_property(realm::ObjectSchema const&,
- realm::Property const& prop);
- bool is_same_list(realm::List const& list, id v) const noexcept;
- template<typename Func>
- void enumerate_list(__unsafe_unretained const id v, Func&& func) {
- id enumerable = RLMAsFastEnumeration(v) ?: v;
- for (id value in enumerable) {
- func(value);
- }
- }
- template<typename T>
- T unbox(id v, realm::CreatePolicy = realm::CreatePolicy::Skip, realm::ObjKey = {});
- bool is_null(id v) { return v == NSNull.null; }
- id null_value() { return NSNull.null; }
- id no_value() { return nil; }
- bool allow_missing(id v) { return [v isKindOfClass:[NSArray class]]; }
- std::string print(id obj) { return [obj description].UTF8String; }
-
- RLMAccessorContext(RLMObjectBase *parentObject, const realm::Property *property = nullptr);
- RLMAccessorContext(RLMClassInfo& info, bool promote=true);
-
-
- RLMProperty *currentProperty;
- private:
- __unsafe_unretained RLMRealm *const _realm;
- RLMClassInfo& _info;
-
-
- bool _promote_existing = true;
-
- __unsafe_unretained RLMObjectBase *const _parentObject = nil;
-
-
- NSDictionary *_defaultValues;
- RLMObservationInfo *_observationInfo = nullptr;
- NSString *_kvoPropertyName = nil;
- id defaultValue(NSString *key);
- id propertyValue(id obj, size_t propIndex, __unsafe_unretained RLMProperty *const prop);
- };
|