summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-04-25 13:34:41 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-04-25 13:34:41 -0700
commitc1f40b9e711115c24d4a4e8464eb8d75f4004ddc (patch)
treea9911684c854fe702659ce02d0c7fe592daf4798
parentd20174270b2010c4842d20ad36cae48774d33272 (diff)
downloadqtlocation-mapboxgl-c1f40b9e711115c24d4a4e8464eb8d75f4004ddc.tar.gz
[core] Move enum type classes to implementation (#4831)
-rw-r--r--include/mbgl/style/types.hpp81
-rw-r--r--src/mbgl/style/property_parsing.cpp58
-rw-r--r--src/mbgl/style/style_parser.cpp5
3 files changed, 63 insertions, 81 deletions
diff --git a/include/mbgl/style/types.hpp b/include/mbgl/style/types.hpp
index 939dbc3a6d..9cad1071c4 100644
--- a/include/mbgl/style/types.hpp
+++ b/include/mbgl/style/types.hpp
@@ -46,27 +46,12 @@ enum class VisibilityType : bool {
None,
};
-MBGL_DEFINE_ENUM_CLASS(VisibilityTypeClass, VisibilityType, {
- { VisibilityType::Visible, "visible" },
- { VisibilityType::None, "none" },
-});
-
-// -------------------------------------------------------------------------------------------------
-
enum class LineCapType : uint8_t {
Round,
Butt,
Square,
};
-MBGL_DEFINE_ENUM_CLASS(LineCapTypeClass, LineCapType, {
- { LineCapType::Round, "round" },
- { LineCapType::Butt, "butt" },
- { LineCapType::Square, "square" },
-});
-
-// -------------------------------------------------------------------------------------------------
-
enum class LineJoinType : uint8_t {
Miter,
Bevel,
@@ -76,78 +61,32 @@ enum class LineJoinType : uint8_t {
FlipBevel
};
-MBGL_DEFINE_ENUM_CLASS(LineJoinTypeClass, LineJoinType, {
- { LineJoinType::Miter, "miter" },
- { LineJoinType::Bevel, "bevel" },
- { LineJoinType::Round, "round" },
- { LineJoinType::FakeRound, "fakeround" },
- { LineJoinType::FlipBevel, "flipbevel" },
-});
-
-// -------------------------------------------------------------------------------------------------
-
enum class TranslateAnchorType : bool {
Map,
Viewport
};
-MBGL_DEFINE_ENUM_CLASS(TranslateAnchorTypeClass, TranslateAnchorType, {
- { TranslateAnchorType::Map, "map" },
- { TranslateAnchorType::Viewport, "viewport" },
-});
-
-// -------------------------------------------------------------------------------------------------
-
enum class RotateAnchorType : bool {
Map,
Viewport,
};
-MBGL_DEFINE_ENUM_CLASS(RotateAnchorTypeClass, RotateAnchorType, {
- { RotateAnchorType::Map, "map" },
- { RotateAnchorType::Viewport, "viewport" },
-});
-
-// -------------------------------------------------------------------------------------------------
-
enum class SymbolPlacementType : bool {
Point,
Line,
};
-MBGL_DEFINE_ENUM_CLASS(SymbolPlacementTypeClass, SymbolPlacementType, {
- { SymbolPlacementType::Point, "point" },
- { SymbolPlacementType::Line, "line" },
-});
-
-// -------------------------------------------------------------------------------------------------
-
enum class RotationAlignmentType : bool {
Map,
Viewport,
};
-MBGL_DEFINE_ENUM_CLASS(RotationAlignmentTypeClass, RotationAlignmentType, {
- { RotationAlignmentType::Map, "map" },
- { RotationAlignmentType::Viewport, "viewport" },
-});
-
-// -------------------------------------------------------------------------------------------------
-
enum class TextJustifyType : uint8_t {
Center,
Left,
Right
};
-MBGL_DEFINE_ENUM_CLASS(TextJustifyTypeClass, TextJustifyType, {
- { TextJustifyType::Center, "center" },
- { TextJustifyType::Left, "left" },
- { TextJustifyType::Right, "right" },
-});
-
-// -------------------------------------------------------------------------------------------------
-
enum class TextAnchorType : uint8_t {
Center,
Left,
@@ -160,32 +99,12 @@ enum class TextAnchorType : uint8_t {
BottomRight
};
-MBGL_DEFINE_ENUM_CLASS(TextAnchorTypeClass, TextAnchorType, {
- { TextAnchorType::Center, "center" },
- { TextAnchorType::Left, "left" },
- { TextAnchorType::Right, "right" },
- { TextAnchorType::Top, "top" },
- { TextAnchorType::Bottom, "bottom" },
- { TextAnchorType::TopLeft, "top-left" },
- { TextAnchorType::TopRight, "top-right" },
- { TextAnchorType::BottomLeft, "bottom-left" },
- { TextAnchorType::BottomRight, "bottom-right" }
-});
-
-// -------------------------------------------------------------------------------------------------
-
enum class TextTransformType : uint8_t {
None,
Uppercase,
Lowercase,
};
-MBGL_DEFINE_ENUM_CLASS(TextTransformTypeClass, TextTransformType, {
- { TextTransformType::None, "none" },
- { TextTransformType::Uppercase, "uppercase" },
- { TextTransformType::Lowercase, "lowercase" },
-});
-
/**
* Initialize any GL state needed by the custom layer. This method is called once, from the
* rendering thread, at a point when the GL context is active but before rendering for the
diff --git a/src/mbgl/style/property_parsing.cpp b/src/mbgl/style/property_parsing.cpp
index 9932451975..84589ea414 100644
--- a/src/mbgl/style/property_parsing.cpp
+++ b/src/mbgl/style/property_parsing.cpp
@@ -58,6 +58,11 @@ optional<Color> parseProperty(const char* name, const JSValue& value) {
css_color.a}};
}
+MBGL_DEFINE_ENUM_CLASS(TranslateAnchorTypeClass, TranslateAnchorType, {
+ { TranslateAnchorType::Map, "map" },
+ { TranslateAnchorType::Viewport, "viewport" },
+});
+
template <>
optional<TranslateAnchorType> parseProperty(const char* name, const JSValue& value) {
if (!value.IsString()) {
@@ -68,6 +73,11 @@ optional<TranslateAnchorType> parseProperty(const char* name, const JSValue& val
return { TranslateAnchorTypeClass({ value.GetString(), value.GetStringLength() }) };
}
+MBGL_DEFINE_ENUM_CLASS(RotateAnchorTypeClass, RotateAnchorType, {
+ { RotateAnchorType::Map, "map" },
+ { RotateAnchorType::Viewport, "viewport" },
+});
+
template <>
optional<RotateAnchorType> parseProperty<RotateAnchorType>(const char* name, const JSValue& value) {
if (!value.IsString()) {
@@ -78,6 +88,12 @@ optional<RotateAnchorType> parseProperty<RotateAnchorType>(const char* name, con
return { RotateAnchorTypeClass({ value.GetString(), value.GetStringLength() }) };
}
+MBGL_DEFINE_ENUM_CLASS(LineCapTypeClass, LineCapType, {
+ { LineCapType::Round, "round" },
+ { LineCapType::Butt, "butt" },
+ { LineCapType::Square, "square" },
+});
+
template <>
optional<LineCapType> parseProperty<LineCapType>(const char* name, const JSValue& value) {
if (!value.IsString()) {
@@ -88,6 +104,14 @@ optional<LineCapType> parseProperty<LineCapType>(const char* name, const JSValue
return { LineCapTypeClass({ value.GetString(), value.GetStringLength() }) };
}
+MBGL_DEFINE_ENUM_CLASS(LineJoinTypeClass, LineJoinType, {
+ { LineJoinType::Miter, "miter" },
+ { LineJoinType::Bevel, "bevel" },
+ { LineJoinType::Round, "round" },
+ { LineJoinType::FakeRound, "fakeround" },
+ { LineJoinType::FlipBevel, "flipbevel" },
+});
+
template <>
optional<LineJoinType> parseProperty<LineJoinType>(const char* name, const JSValue& value) {
if (!value.IsString()) {
@@ -98,6 +122,11 @@ optional<LineJoinType> parseProperty<LineJoinType>(const char* name, const JSVal
return { LineJoinTypeClass({ value.GetString(), value.GetStringLength() }) };
}
+MBGL_DEFINE_ENUM_CLASS(SymbolPlacementTypeClass, SymbolPlacementType, {
+ { SymbolPlacementType::Point, "point" },
+ { SymbolPlacementType::Line, "line" },
+});
+
template <>
optional<SymbolPlacementType> parseProperty<SymbolPlacementType>(const char* name, const JSValue& value) {
if (!value.IsString()) {
@@ -108,6 +137,18 @@ optional<SymbolPlacementType> parseProperty<SymbolPlacementType>(const char* nam
return { SymbolPlacementTypeClass({ value.GetString(), value.GetStringLength() }) };
}
+MBGL_DEFINE_ENUM_CLASS(TextAnchorTypeClass, TextAnchorType, {
+ { TextAnchorType::Center, "center" },
+ { TextAnchorType::Left, "left" },
+ { TextAnchorType::Right, "right" },
+ { TextAnchorType::Top, "top" },
+ { TextAnchorType::Bottom, "bottom" },
+ { TextAnchorType::TopLeft, "top-left" },
+ { TextAnchorType::TopRight, "top-right" },
+ { TextAnchorType::BottomLeft, "bottom-left" },
+ { TextAnchorType::BottomRight, "bottom-right" }
+});
+
template <>
optional<TextAnchorType> parseProperty<TextAnchorType>(const char* name, const JSValue& value) {
if (!value.IsString()) {
@@ -118,6 +159,12 @@ optional<TextAnchorType> parseProperty<TextAnchorType>(const char* name, const J
return { TextAnchorTypeClass({ value.GetString(), value.GetStringLength() }) };
}
+MBGL_DEFINE_ENUM_CLASS(TextJustifyTypeClass, TextJustifyType, {
+ { TextJustifyType::Center, "center" },
+ { TextJustifyType::Left, "left" },
+ { TextJustifyType::Right, "right" },
+});
+
template <>
optional<TextJustifyType> parseProperty<TextJustifyType>(const char* name, const JSValue& value) {
if (!value.IsString()) {
@@ -128,6 +175,12 @@ optional<TextJustifyType> parseProperty<TextJustifyType>(const char* name, const
return { TextJustifyTypeClass({ value.GetString(), value.GetStringLength() }) };
}
+MBGL_DEFINE_ENUM_CLASS(TextTransformTypeClass, TextTransformType, {
+ { TextTransformType::None, "none" },
+ { TextTransformType::Uppercase, "uppercase" },
+ { TextTransformType::Lowercase, "lowercase" },
+});
+
template <>
optional<TextTransformType> parseProperty<TextTransformType>(const char* name, const JSValue& value) {
if (!value.IsString()) {
@@ -138,6 +191,11 @@ optional<TextTransformType> parseProperty<TextTransformType>(const char* name, c
return { TextTransformTypeClass({ value.GetString(), value.GetStringLength() }) };
}
+MBGL_DEFINE_ENUM_CLASS(RotationAlignmentTypeClass, RotationAlignmentType, {
+ { RotationAlignmentType::Map, "map" },
+ { RotationAlignmentType::Viewport, "viewport" },
+});
+
template <>
optional<RotationAlignmentType> parseProperty<RotationAlignmentType>(const char* name, const JSValue& value) {
if (!value.IsString()) {
diff --git a/src/mbgl/style/style_parser.cpp b/src/mbgl/style/style_parser.cpp
index ff0a3b13af..d99339b84a 100644
--- a/src/mbgl/style/style_parser.cpp
+++ b/src/mbgl/style/style_parser.cpp
@@ -481,6 +481,11 @@ void StyleParser::parseLayer(const std::string& id, const JSValue& value, std::u
layer->parsePaints(value);
}
+MBGL_DEFINE_ENUM_CLASS(VisibilityTypeClass, VisibilityType, {
+ { VisibilityType::Visible, "visible" },
+ { VisibilityType::None, "none" },
+});
+
void StyleParser::parseVisibility(StyleLayer& layer, const JSValue& value) {
if (!value.HasMember("visibility")) {
return;