[core] upgrade RapidJSON to 1.1.0
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user