summaryrefslogtreecommitdiff
path: root/src/mbgl/style/property_parsing.cpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-06-10 21:17:23 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-06-13 17:22:05 -0700
commit282e626ac112b1ca7a9bf9f9d4c0239db8fbd97a (patch)
treef83ef7974687a84341dd616b364b2aa5a9c012a8 /src/mbgl/style/property_parsing.cpp
parent36bef2157595e1455aa55c64c6c526f096dd1c8e (diff)
downloadqtlocation-mapboxgl-282e626ac112b1ca7a9bf9f9d4c0239db8fbd97a.tar.gz
[core] Make enum ↔ string conversion more generic-friendly
Rewrite enum.hpp in such a way that parseConstant can be defined generically for all enumerated types. While there, properly validated enumerated property values.
Diffstat (limited to 'src/mbgl/style/property_parsing.cpp')
-rw-r--r--src/mbgl/style/property_parsing.cpp148
1 files changed, 0 insertions, 148 deletions
diff --git a/src/mbgl/style/property_parsing.cpp b/src/mbgl/style/property_parsing.cpp
index 6e5174e936..9985cc7f39 100644
--- a/src/mbgl/style/property_parsing.cpp
+++ b/src/mbgl/style/property_parsing.cpp
@@ -55,154 +55,6 @@ optional<Color> parseConstant(const char* name, const JSValue& value) {
css_color.a}};
}
-MBGL_DEFINE_ENUM_CLASS(TranslateAnchorTypeClass, TranslateAnchorType, {
- { TranslateAnchorType::Map, "map" },
- { TranslateAnchorType::Viewport, "viewport" },
-})
-
-template <>
-optional<TranslateAnchorType> parseConstant(const char* name, const JSValue& value) {
- if (!value.IsString()) {
- Log::Warning(Event::ParseStyle, "value of '%s' must be a string", name);
- return {};
- }
-
- return { TranslateAnchorTypeClass({ value.GetString(), value.GetStringLength() }) };
-}
-
-MBGL_DEFINE_ENUM_CLASS(RotateAnchorTypeClass, RotateAnchorType, {
- { RotateAnchorType::Map, "map" },
- { RotateAnchorType::Viewport, "viewport" },
-})
-
-template <>
-optional<RotateAnchorType> parseConstant<RotateAnchorType>(const char* name, const JSValue& value) {
- if (!value.IsString()) {
- Log::Warning(Event::ParseStyle, "value of '%s' must be a string", name);
- return {};
- }
-
- return { RotateAnchorTypeClass({ value.GetString(), value.GetStringLength() }) };
-}
-
-MBGL_DEFINE_ENUM_CLASS(LineCapTypeClass, LineCapType, {
- { LineCapType::Round, "round" },
- { LineCapType::Butt, "butt" },
- { LineCapType::Square, "square" },
-})
-
-template <>
-optional<LineCapType> parseConstant<LineCapType>(const char* name, const JSValue& value) {
- if (!value.IsString()) {
- Log::Warning(Event::ParseStyle, "value of '%s' must be a string", name);
- return {};
- }
-
- 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> parseConstant<LineJoinType>(const char* name, const JSValue& value) {
- if (!value.IsString()) {
- Log::Warning(Event::ParseStyle, "value of '%s' must be a string", name);
- return {};
- }
-
- return { LineJoinTypeClass({ value.GetString(), value.GetStringLength() }) };
-}
-
-MBGL_DEFINE_ENUM_CLASS(SymbolPlacementTypeClass, SymbolPlacementType, {
- { SymbolPlacementType::Point, "point" },
- { SymbolPlacementType::Line, "line" },
-})
-
-template <>
-optional<SymbolPlacementType> parseConstant<SymbolPlacementType>(const char* name, const JSValue& value) {
- if (!value.IsString()) {
- Log::Warning(Event::ParseStyle, "value of '%s' must be a string", name);
- return {};
- }
-
- 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> parseConstant<TextAnchorType>(const char* name, const JSValue& value) {
- if (!value.IsString()) {
- Log::Warning(Event::ParseStyle, "value of '%s' must be a string", name);
- return {};
- }
-
- return { TextAnchorTypeClass({ value.GetString(), value.GetStringLength() }) };
-}
-
-MBGL_DEFINE_ENUM_CLASS(TextJustifyTypeClass, TextJustifyType, {
- { TextJustifyType::Center, "center" },
- { TextJustifyType::Left, "left" },
- { TextJustifyType::Right, "right" },
-})
-
-template <>
-optional<TextJustifyType> parseConstant<TextJustifyType>(const char* name, const JSValue& value) {
- if (!value.IsString()) {
- Log::Warning(Event::ParseStyle, "value of '%s' must be a string", name);
- return {};
- }
-
- return { TextJustifyTypeClass({ value.GetString(), value.GetStringLength() }) };
-}
-
-MBGL_DEFINE_ENUM_CLASS(TextTransformTypeClass, TextTransformType, {
- { TextTransformType::None, "none" },
- { TextTransformType::Uppercase, "uppercase" },
- { TextTransformType::Lowercase, "lowercase" },
-})
-
-template <>
-optional<TextTransformType> parseConstant<TextTransformType>(const char* name, const JSValue& value) {
- if (!value.IsString()) {
- Log::Warning(Event::ParseStyle, "value of '%s' must be a string", name);
- return {};
- }
-
- return { TextTransformTypeClass({ value.GetString(), value.GetStringLength() }) };
-}
-
-MBGL_DEFINE_ENUM_CLASS(AlignmentTypeClass, AlignmentType, {
- { AlignmentType::Map, "map" },
- { AlignmentType::Viewport, "viewport" },
-})
-
-template <>
-optional<AlignmentType> parseConstant<AlignmentType>(const char* name, const JSValue& value) {
- if (!value.IsString()) {
- Log::Warning(Event::ParseStyle, "value of '%s' must be a string", name);
- return {};
- }
-
- return { AlignmentTypeClass({ value.GetString(), value.GetStringLength() }) };
-}
-
template <>
optional<std::array<float, 2>> parseConstant(const char* name, const JSValue& value) {
if (value.IsArray() && value.Size() == 2 &&