summaryrefslogtreecommitdiff
path: root/platform/darwin/src/NSDictionary+MGLAdditions.mm
blob: 4bc7ddb3cfe6857d2457a1e7d26e0aa7593a580c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#import "NSDictionary+MGLAdditions.h"

#import "NSExpression+MGLPrivateAdditions.h"
#import "NSArray+MGLAdditions.h"

@implementation NSDictionary (MGLAdditions)

- (mbgl::PropertyMap)mgl_propertyMap {
    mbgl::PropertyMap propertyMap;
    for (NSString *key in self.allKeys) {
        if ([self[key] isKindOfClass:[NSDictionary class]]) {
            propertyMap[[key UTF8String]] = [self[key] mgl_propertyMap];
        } else if ([self[key] isKindOfClass:[NSArray class]]) {
            NSArray *array = self[key];
            propertyMap[[key UTF8String]] = [array mgl_vector];
        } else {
            NSExpression *expression = [NSExpression expressionForConstantValue:self[key]];
            propertyMap[[key UTF8String]] = expression.mgl_constantMBGLValue;
        }
    }
    return propertyMap;
}

@end