diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2016-08-26 13:46:54 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2016-09-15 14:05:23 +0200 |
commit | d1d523686c01aacee1f1f9b6f6c7f22a6ff54d14 (patch) | |
tree | 45e6209ce30bf0e78d8b8690ead61e93befeb0a3 | |
parent | d6c958ba5fab8318be09d0c60a2eccd9ccbd7186 (diff) | |
download | qtlocation-mapboxgl-d1d523686c01aacee1f1f9b6f6c7f22a6ff54d14.tar.gz |
[core] upgrade RapidJSON to 1.1.0
-rw-r--r-- | CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/mbgl/sprite/sprite_parser.cpp | 6 | ||||
-rw-r--r-- | src/mbgl/style/parser.cpp | 12 | ||||
-rw-r--r-- | src/mbgl/style/rapidjson_conversion.hpp | 6 | ||||
-rw-r--r-- | test/sprite/sprite_parser.cpp | 2 | ||||
-rw-r--r-- | test/style/style_parser.cpp | 11 |
6 files changed, 21 insertions, 20 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c67b2c4707..ec7210ca3f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ endif() mason_use(geometry VERSION 0.8.0 HEADER_ONLY) mason_use(variant VERSION 1.1.0 HEADER_ONLY) mason_use(unique_resource VERSION dev HEADER_ONLY) -mason_use(rapidjson VERSION 1.0.2 HEADER_ONLY) +mason_use(rapidjson VERSION 1.1.0 HEADER_ONLY) mason_use(boost VERSION 1.60.0 HEADER_ONLY) mason_use(geojsonvt VERSION 6.1.3 HEADER_ONLY) mason_use(supercluster VERSION 0.2.0 HEADER_ONLY) @@ -29,7 +29,7 @@ mason_use(kdbush VERSION 0.1.1 HEADER_ONLY) mason_use(earcut VERSION 0.11 HEADER_ONLY) mason_use(protozero VERSION 1.4.2 HEADER_ONLY) mason_use(pixelmatch VERSION 0.9.0 HEADER_ONLY) -mason_use(geojson VERSION 0.1.4${MASON_CXXABI_SUFFIX}) +mason_use(geojson VERSION 0.3.0) if(WITH_COVERAGE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") diff --git a/src/mbgl/sprite/sprite_parser.cpp b/src/mbgl/sprite/sprite_parser.cpp index 190ac66e14..34b1d875b6 100644 --- a/src/mbgl/sprite/sprite_parser.cpp +++ b/src/mbgl/sprite/sprite_parser.cpp @@ -108,9 +108,9 @@ SpriteParseResult parseSprite(const std::string& image, const std::string& json) } else if (!doc.IsObject()) { return std::make_exception_ptr(std::runtime_error("Sprite JSON root must be an object")); } else { - for (JSValue::ConstMemberIterator itr = doc.MemberBegin(); itr != doc.MemberEnd(); ++itr) { - const std::string name = { itr->name.GetString(), itr->name.GetStringLength() }; - const JSValue& value = itr->value; + for (const auto& property : doc.GetObject()) { + const std::string name = { property.name.GetString(), property.name.GetStringLength() }; + const JSValue& value = property.value; if (value.IsObject()) { const uint16_t x = getUInt16(value, "x", 0); diff --git a/src/mbgl/style/parser.cpp b/src/mbgl/style/parser.cpp index e53fac2667..059082980d 100644 --- a/src/mbgl/style/parser.cpp +++ b/src/mbgl/style/parser.cpp @@ -113,11 +113,11 @@ void Parser::parseSources(const JSValue& value) { return; } - for (auto it = value.MemberBegin(); it != value.MemberEnd(); ++it) { - std::string id = *conversion::toString(it->name); + for (const auto& property : value.GetObject()) { + std::string id = *conversion::toString(property.name); - conversion::Result<std::unique_ptr<Source>> source - = conversion::convert<std::unique_ptr<Source>>(it->value, id); + conversion::Result<std::unique_ptr<Source>> source = + conversion::convert<std::unique_ptr<Source>>(property.value, id); if (!source) { Log::Warning(Event::ParseStyle, source.error().message); continue; @@ -136,9 +136,7 @@ void Parser::parseLayers(const JSValue& value) { return; } - for (rapidjson::SizeType i = 0; i < value.Size(); ++i) { - const JSValue& layerValue = value[i]; - + for (auto& layerValue : value.GetArray()) { if (!layerValue.IsObject()) { Log::Warning(Event::ParseStyle, "layer must be an object"); continue; diff --git a/src/mbgl/style/rapidjson_conversion.hpp b/src/mbgl/style/rapidjson_conversion.hpp index ecf044fb64..101fe67ec0 100644 --- a/src/mbgl/style/rapidjson_conversion.hpp +++ b/src/mbgl/style/rapidjson_conversion.hpp @@ -37,8 +37,10 @@ inline const JSValue* objectMember(const JSValue& value, const char * 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); + assert(value.IsObject()); + for (const auto& property : value.GetObject()) { + optional<Error> result = + fn({ property.name.GetString(), property.name.GetStringLength() }, property.value); if (result) { return result; } diff --git a/test/sprite/sprite_parser.cpp b/test/sprite/sprite_parser.cpp index 85a5387898..8d32d081bf 100644 --- a/test/sprite/sprite_parser.cpp +++ b/test/sprite/sprite_parser.cpp @@ -212,7 +212,7 @@ TEST(Sprite, SpriteParsingInvalidJSON) { const auto error = parseSprite(image_1x, json_1x).get<std::exception_ptr>(); EXPECT_EQ(util::toString(error), - std::string("Failed to parse JSON: Missing a closing quotation mark in string. at offset 13")); + std::string("Failed to parse JSON: Missing a closing quotation mark in string. at offset 14")); } TEST(Sprite, SpriteParsingEmptyImage) { diff --git a/test/style/style_parser.cpp b/test/style/style_parser.cpp index 3e1149c997..e3c1da582f 100644 --- a/test/style/style_parser.cpp +++ b/test/style/style_parser.cpp @@ -39,17 +39,18 @@ TEST_P(StyleParserTest, ParseStyle) { Log::Error(Event::ParseStyle, "Failed to parse style: %s", util::toString(error).c_str()); } - for (auto it = infoDoc.MemberBegin(), end = infoDoc.MemberEnd(); it != end; it++) { - const std::string name { it->name.GetString(), it->name.GetStringLength() }; - const JSValue &value = it->value; + ASSERT_TRUE(infoDoc.IsObject()); + for (const auto& property : infoDoc.GetObject()) { + const std::string name { property.name.GetString(), property.name.GetStringLength() }; + const JSValue &value = property.value; ASSERT_EQ(true, value.IsObject()); if (value.HasMember("log")) { const JSValue &js_log = value["log"]; ASSERT_EQ(true, js_log.IsArray()); - for (rapidjson::SizeType i = 0; i < js_log.Size(); i++) { - const JSValue &js_entry = js_log[i]; + for (auto& js_entry : js_log.GetArray()) { ASSERT_EQ(true, js_entry.IsArray()); + ASSERT_GE(4u, js_entry.Size()); const uint32_t count = js_entry[rapidjson::SizeType(0)].GetUint(); const FixtureLogObserver::LogMessage message { |