summaryrefslogtreecommitdiff
path: root/include/mbgl/style/conversion/expression.hpp
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <tmpsantos@gmail.com>2017-11-10 19:18:39 -0200
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2017-11-12 13:41:08 -0200
commit1adc585c61e1e42f28c7944816010446091fa161 (patch)
treeafbab98a080dcea67851e5bfb43f78d7776be423 /include/mbgl/style/conversion/expression.hpp
parenta2120304a881507ed60c3199925946c1df06b44c (diff)
downloadqtlocation-mapboxgl-1adc585c61e1e42f28c7944816010446091fa161.tar.gz
Bump Mapbox GL Native
mapbox-gl-native @ 92608f58858d77c17a65ae9b29758e74bb2da7d2
Diffstat (limited to 'include/mbgl/style/conversion/expression.hpp')
-rw-r--r--include/mbgl/style/conversion/expression.hpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/include/mbgl/style/conversion/expression.hpp b/include/mbgl/style/conversion/expression.hpp
new file mode 100644
index 0000000000..c5fcf906a7
--- /dev/null
+++ b/include/mbgl/style/conversion/expression.hpp
@@ -0,0 +1,39 @@
+#pragma once
+
+#include <mbgl/style/expression/parsing_context.hpp>
+#include <mbgl/style/expression/type.hpp>
+#include <mbgl/style/conversion.hpp>
+
+#include <memory>
+
+namespace mbgl {
+namespace style {
+namespace conversion {
+
+using namespace mbgl::style::expression;
+
+template<> struct Converter<std::unique_ptr<Expression>> {
+ optional<std::unique_ptr<Expression>> operator()(const Convertible& value, Error& error, type::Type expected) const {
+ ParsingContext ctx(optional<type::Type> {expected});
+ ParseResult parsed = ctx.parse(value);
+ if (parsed) {
+ return std::move(*parsed);
+ }
+ std::string combinedError;
+ for (const ParsingError& parsingError : ctx.getErrors()) {
+ if (combinedError.size() > 0) {
+ combinedError += "\n";
+ }
+ if (parsingError.key.size() > 0) {
+ combinedError += parsingError.key + ": ";
+ }
+ combinedError += parsingError.message;
+ }
+ error = { combinedError };
+ return {};
+ };
+};
+
+} // namespace conversion
+} // namespace style
+} // namespace mbgl