summaryrefslogtreecommitdiff
path: root/platform/darwin/src/MGLStyleAttributeFunction.mm
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-09-24 11:12:21 -0700
committerMinh Nguyễn <mxn@1ec5.org>2016-10-17 11:47:22 -0700
commit0c8a3feffa94a9594bcaa77fdc18d11a3c482ff5 (patch)
tree9570ab6ad86323a0dcea7616f91d8ca726cd6659 /platform/darwin/src/MGLStyleAttributeFunction.mm
parentae96e78ccd293d12e28e54a9a727d29d05a37980 (diff)
downloadqtlocation-mapboxgl-0c8a3feffa94a9594bcaa77fdc18d11a3c482ff5.tar.gz
[ios, macos] Replaced MGLStyleAttributeValue with MGLStyleValue
MGLStyleValue is an umbrella class serving as a variant container for MGLStyleConstantValue and MGLStyleFunction. These classes use lightweight generics to indicate the underlying type. A templated C++ class concisely converts between mbgl::style::PropertyValue and MGLStyleValue.
Diffstat (limited to 'platform/darwin/src/MGLStyleAttributeFunction.mm')
-rw-r--r--platform/darwin/src/MGLStyleAttributeFunction.mm62
1 files changed, 62 insertions, 0 deletions
diff --git a/platform/darwin/src/MGLStyleAttributeFunction.mm b/platform/darwin/src/MGLStyleAttributeFunction.mm
index 7eec5c2369..337e299127 100644
--- a/platform/darwin/src/MGLStyleAttributeFunction.mm
+++ b/platform/darwin/src/MGLStyleAttributeFunction.mm
@@ -4,6 +4,68 @@
#import "MGLStyleAttributeValue_Private.h"
#import "MGLStyleAttributeFunction_Private.h"
+@implementation MGLStyleValue
+
++ (instancetype)valueWithRawValue:(id)rawValue {
+ return [MGLStyleConstantValue valueWithRawValue:rawValue];
+}
+
++ (instancetype)valueWithBase:(CGFloat)base stops:(NSDictionary *)stops {
+ return [MGLStyleFunction functionWithBase:base stops:stops];
+}
+
++ (instancetype)valueWithStops:(NSDictionary *)stops {
+ return [MGLStyleFunction functionWithStops:stops];
+}
+
+@end
+
+@implementation MGLStyleConstantValue
+
++ (instancetype)valueWithRawValue:(id)rawValue {
+ return [[self alloc] initWithRawValue:rawValue];
+}
+
+- (instancetype)initWithRawValue:(id)rawValue {
+ if (self = [super init]) {
+ _rawValue = rawValue;
+ }
+ return self;
+}
+
+@end
+
+@implementation MGLStyleFunction
+
++ (instancetype)functionWithBase:(CGFloat)base stops:(NSDictionary *)stops {
+ return [[self alloc] initWithBase:base stops:stops];
+}
+
++ (instancetype)functionWithStops:(NSDictionary *)stops {
+ return [[self alloc] initWithBase:1 stops:stops];
+}
+
+- (instancetype)init {
+ if (self = [super init]) {
+ _base = 1;
+ }
+ return self;
+}
+
+- (instancetype)initWithBase:(CGFloat)base stops:(NSDictionary *)stops {
+ if (self = [self init]) {
+ _base = base;
+ _stops = stops;
+ }
+ return self;
+}
+
+@end
+
+
+
+
+
@interface MGLStyleAttributeFunction() <MGLStyleAttributeValue_Private>
@end