summaryrefslogtreecommitdiff
path: root/src/mbgl/style/rapidjson_conversion.hpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-06-22 16:28:21 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-06-24 09:39:51 -0700
commit16c435b1517b15a5ea8654987979ef58800b838b (patch)
tree8f81c4e202e1337d0966a06f27842d45a113fded /src/mbgl/style/rapidjson_conversion.hpp
parentc4e4cc5081965d03132eea754c27ece3c95961cb (diff)
downloadqtlocation-mapboxgl-16c435b1517b15a5ea8654987979ef58800b838b.tar.gz
[core, node] Implement bindings for addLayer
Diffstat (limited to 'src/mbgl/style/rapidjson_conversion.hpp')
-rw-r--r--src/mbgl/style/rapidjson_conversion.hpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/mbgl/style/rapidjson_conversion.hpp b/src/mbgl/style/rapidjson_conversion.hpp
index 1d9f88efa3..ecf044fb64 100644
--- a/src/mbgl/style/rapidjson_conversion.hpp
+++ b/src/mbgl/style/rapidjson_conversion.hpp
@@ -2,11 +2,16 @@
#include <mbgl/util/rapidjson.hpp>
#include <mbgl/util/feature.hpp>
+#include <mbgl/style/conversion.hpp>
namespace mbgl {
namespace style {
namespace conversion {
+inline bool isUndefined(const JSValue& value) {
+ return value.IsNull();
+}
+
inline bool isArray(const JSValue& value) {
return value.IsArray();
}
@@ -30,6 +35,17 @@ inline const JSValue* objectMember(const JSValue& value, const char * name) {
return &value[name];
}
+template <class Fn>
+optional<Error> eachMember(const JSValue& value, Fn&& fn) {
+ for (auto it = value.MemberBegin(); it != value.MemberEnd(); ++it) {
+ optional<Error> result = fn({it->name.GetString(), it->name.GetStringLength()}, it->value);
+ if (result) {
+ return result;
+ }
+ }
+ return {};
+}
+
inline optional<bool> toBool(const JSValue& value) {
if (!value.IsBool()) {
return {};