summaryrefslogtreecommitdiff
path: root/platform/android/src/style
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-05-05 16:31:03 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-05-08 13:48:57 -0700
commitbaaae99a03202641ae5b8024e57b691fe61a6688 (patch)
tree459045e56197696aa1312594f1e452b03931775d /platform/android/src/style
parente34d8b5c802186008e49364668e4a7bd5668d0fd (diff)
downloadqtlocation-mapboxgl-baaae99a03202641ae5b8024e57b691fe61a6688.tar.gz
[core, android] Factor JSON string conversions
This adds a `convertJSON` template, to be used like: Error error optional<Foo> foo = convertJSON<Foo>(string, error); Internally, it parses the string with RapidJSON and then calls `convert<Foo>(parsed, error)`. While here, rationalize GeoJSON converters and fix error handling for Tileset conversion in OfflineDownload.
Diffstat (limited to 'platform/android/src/style')
-rw-r--r--platform/android/src/style/conversion/geojson.hpp14
1 files changed, 2 insertions, 12 deletions
diff --git a/platform/android/src/style/conversion/geojson.hpp b/platform/android/src/style/conversion/geojson.hpp
index 32a473b092..748fe7361e 100644
--- a/platform/android/src/style/conversion/geojson.hpp
+++ b/platform/android/src/style/conversion/geojson.hpp
@@ -10,25 +10,15 @@ namespace style {
namespace conversion {
template <>
-optional<GeoJSON> convertGeoJSON(const mbgl::android::Value& value, Error& error) {
-
+optional<GeoJSON> Converter<GeoJSON>::operator()(const mbgl::android::Value& value, Error& error) const {
if(value.isNull() || !value.isString()) {
error = { "no json data found" };
return {};
}
- return convertGeoJSON(value.toString(), error);
+ return convert<GeoJSON>(value.toString(), error);
}
-template <>
-struct Converter<GeoJSON> {
-
- optional<GeoJSON> operator()(const mbgl::android::Value& value, Error& error) const {
- return convertGeoJSON(value, error);
- }
-
-};
-
} // namespace conversion
} // namespace style
} // namespace mbgl