summaryrefslogtreecommitdiff
path: root/platform/darwin/src/MGLFeature_Private.h
diff options
context:
space:
mode:
Diffstat (limited to 'platform/darwin/src/MGLFeature_Private.h')
-rw-r--r--platform/darwin/src/MGLFeature_Private.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/platform/darwin/src/MGLFeature_Private.h b/platform/darwin/src/MGLFeature_Private.h
index 59c5ab8611..6751b3196a 100644
--- a/platform/darwin/src/MGLFeature_Private.h
+++ b/platform/darwin/src/MGLFeature_Private.h
@@ -39,3 +39,31 @@ mbgl::Feature mbglFeature(mbgl::Feature feature, id identifier, NSDictionary *at
NS_DICTIONARY_OF(NSString *, id) *NSDictionaryFeatureForGeometry(NSDictionary *geometry, NSDictionary *attributes, id identifier);
NS_ASSUME_NONNULL_END
+
+#define MGL_DEFINE_FEATURE_INIT_WITH_CODER() \
+ - (instancetype)initWithCoder:(NSCoder *)decoder { \
+ if (self = [super initWithCoder:decoder]) { \
+ NSSet<Class> *identifierClasses = [NSSet setWithArray:@[[NSString class], [NSNumber class]]]; \
+ identifier = [decoder decodeObjectOfClasses:identifierClasses forKey:@"identifier"]; \
+ attributes = [decoder decodeObjectOfClass:[NSDictionary class] forKey:@"attributes"]; \
+ } \
+ return self; \
+ }
+
+#define MGL_DEFINE_FEATURE_ENCODE() \
+ - (void)encodeWithCoder:(NSCoder *)coder { \
+ [super encodeWithCoder:coder]; \
+ [coder encodeObject:identifier forKey:@"identifier"]; \
+ [coder encodeObject:attributes forKey:@"attributes"]; \
+ }
+
+#define MGL_DEFINE_FEATURE_IS_EQUAL() \
+ - (BOOL)isEqual:(id)other { \
+ if (other == self) return YES; \
+ if (![other isKindOfClass:[self class]]) return NO; \
+ __typeof(self) otherFeature = other; \
+ return [super isEqual:other] && [self geoJSONObject] == [otherFeature geoJSONObject]; \
+ } \
+ - (NSUInteger)hash { \
+ return [super hash] + [[self geoJSONDictionary] hash]; \
+ }