From 26a222ac623e5d02faa898db4f6bf322195dfe0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Kalinowski?= Date: Sun, 26 Nov 2017 22:18:18 +0100 Subject: [PATCH] Change JsonType to enum class (#393) Change enum JsonType to enum class JsonType --- AI/VCAI/VCAI.cpp | 2 +- CCallback.cpp | 2 +- client/CMT.cpp | 4 +- client/CPlayerInterface.cpp | 4 +- client/gui/CAnimation.cpp | 10 +- launcher/jsonutils.cpp | 12 +- lib/CArtHandler.cpp | 4 +- lib/CCreatureHandler.cpp | 4 +- lib/CCreatureSet.cpp | 2 +- lib/CModHandler.cpp | 4 +- lib/CSkillHandler.cpp | 2 +- lib/CTownHandler.cpp | 4 +- lib/JsonDetail.cpp | 62 ++++----- lib/JsonNode.cpp | 158 +++++++++++------------ lib/JsonNode.h | 18 +-- lib/mapObjects/CGHeroInstance.cpp | 6 +- lib/mapObjects/CObjectClassesHandler.cpp | 6 +- lib/mapObjects/CommonConstructors.cpp | 4 +- lib/mapObjects/JsonRandom.cpp | 10 +- lib/mapObjects/MiscObjects.cpp | 2 +- lib/mapObjects/ObjectTemplate.cpp | 4 +- lib/mapping/MapFormatJson.cpp | 18 +-- lib/rmg/CRmgTemplateStorage.cpp | 4 +- lib/serializer/JsonDeserializer.cpp | 2 +- lib/serializer/JsonSerializeFormat.cpp | 8 +- lib/serializer/JsonSerializeFormat.h | 4 +- lib/serializer/JsonSerializer.cpp | 4 +- lib/spells/AdventureSpellMechanics.cpp | 2 +- lib/spells/CSpellHandler.cpp | 6 +- server/CQuery.cpp | 2 +- test/map/MapComparer.cpp | 26 ++-- 31 files changed, 200 insertions(+), 200 deletions(-) diff --git a/AI/VCAI/VCAI.cpp b/AI/VCAI/VCAI.cpp index b57371574..76c0b4d13 100644 --- a/AI/VCAI/VCAI.cpp +++ b/AI/VCAI/VCAI.cpp @@ -2851,7 +2851,7 @@ void VCAI::requestSent(const CPackForServer *pack, int requestID) std::string VCAI::getBattleAIName() const { - if(settings["server"]["enemyAI"].getType() == JsonNode::DATA_STRING) + if(settings["server"]["enemyAI"].getType() == JsonNode::JsonType::DATA_STRING) return settings["server"]["enemyAI"].String(); else return "BattleAI"; diff --git a/CCallback.cpp b/CCallback.cpp index d5db3435a..21ffe6694 100644 --- a/CCallback.cpp +++ b/CCallback.cpp @@ -45,7 +45,7 @@ bool CCallback::moveHero(const CGHeroInstance *h, int3 dst, bool transit) int CCallback::selectionMade(int selection, QueryID queryID) { - JsonNode reply(JsonNode::DATA_INTEGER); + JsonNode reply(JsonNode::JsonType::DATA_INTEGER); reply.Integer() = selection; return sendQueryReply(reply, queryID); } diff --git a/client/CMT.cpp b/client/CMT.cpp index 461f08038..481f96d93 100644 --- a/client/CMT.cpp +++ b/client/CMT.cpp @@ -692,11 +692,11 @@ void processCommand(const std::string &message) auto extractVector = [=](const std::vector & source, const std::string & name) { - JsonNode data(JsonNode::DATA_VECTOR); + JsonNode data(JsonNode::JsonType::DATA_VECTOR); size_t index = 0; for(auto & line : source) { - JsonNode lineNode(JsonNode::DATA_STRUCT); + JsonNode lineNode(JsonNode::JsonType::DATA_STRUCT); lineNode["text"].String() = line; lineNode["index"].Integer() = index++; data.Vector().push_back(lineNode); diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index d65e122df..11c649ade 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -1207,14 +1207,14 @@ void CPlayerInterface::showMapObjectSelectDialog(QueryID askID, const Component auto selectCallback = [=](int selection) { - JsonNode reply(JsonNode::DATA_INTEGER); + JsonNode reply(JsonNode::JsonType::DATA_INTEGER); reply.Integer() = selection; cb->sendQueryReply(reply, askID); }; auto cancelCallback = [=]() { - JsonNode reply(JsonNode::DATA_NULL); + JsonNode reply(JsonNode::JsonType::DATA_NULL); cb->sendQueryReply(reply, askID); }; diff --git a/client/gui/CAnimation.cpp b/client/gui/CAnimation.cpp index 8cb33c9a3..1af1c3a6d 100644 --- a/client/gui/CAnimation.cpp +++ b/client/gui/CAnimation.cpp @@ -1356,7 +1356,7 @@ bool CAnimation::loadFrame(size_t frame, size_t group) } //try to get image from def - if(source[group][frame].getType() == JsonNode::DATA_NULL) + if(source[group][frame].getType() == JsonNode::JsonType::DATA_NULL) { if(defFile) { @@ -1411,7 +1411,7 @@ void CAnimation::initFromJson(const JsonNode & config) std::string basepath; basepath = config["basepath"].String(); - JsonNode base(JsonNode::DATA_STRUCT); + JsonNode base(JsonNode::JsonType::DATA_STRUCT); base["margins"] = config["margins"]; base["width"] = config["width"]; base["height"] = config["height"]; @@ -1423,7 +1423,7 @@ void CAnimation::initFromJson(const JsonNode & config) for(const JsonNode & frame : group["frames"].Vector()) { - JsonNode toAdd(JsonNode::DATA_STRUCT); + JsonNode toAdd(JsonNode::JsonType::DATA_STRUCT); JsonUtils::inherit(toAdd, base); toAdd["file"].String() = basepath + frame.String(); source[groupID].push_back(toAdd); @@ -1438,7 +1438,7 @@ void CAnimation::initFromJson(const JsonNode & config) if (source[group].size() <= frame) source[group].resize(frame+1); - JsonNode toAdd(JsonNode::DATA_STRUCT); + JsonNode toAdd(JsonNode::JsonType::DATA_STRUCT); JsonUtils::inherit(toAdd, base); toAdd["file"].String() = basepath + node["file"].String(); source[group][frame] = toAdd; @@ -1564,7 +1564,7 @@ void CAnimation::duplicateImage(const size_t sourceGroup, const size_t sourceFra //todo: clone actual loaded Image object JsonNode clone(source[sourceGroup][sourceFrame]); - if(clone.getType() == JsonNode::DATA_NULL) + if(clone.getType() == JsonNode::JsonType::DATA_NULL) { std::string temp = name+":"+boost::lexical_cast(sourceGroup)+":"+boost::lexical_cast(sourceFrame); clone["file"].String() = temp; diff --git a/launcher/jsonutils.cpp b/launcher/jsonutils.cpp index e47db3e7e..847b51347 100644 --- a/launcher/jsonutils.cpp +++ b/launcher/jsonutils.cpp @@ -58,12 +58,12 @@ QVariant toVariant(const JsonNode & node) { switch (node.getType()) { - break; case JsonNode::DATA_NULL: return QVariant(); - break; case JsonNode::DATA_BOOL: return QVariant(node.Bool()); - break; case JsonNode::DATA_FLOAT: return QVariant(node.Float()); - break; case JsonNode::DATA_STRING: return QVariant(QString::fromUtf8(node.String().c_str())); - break; case JsonNode::DATA_VECTOR: return JsonToList(node.Vector()); - break; case JsonNode::DATA_STRUCT: return JsonToMap(node.Struct()); + break; case JsonNode::JsonType::DATA_NULL: return QVariant(); + break; case JsonNode::JsonType::DATA_BOOL: return QVariant(node.Bool()); + break; case JsonNode::JsonType::DATA_FLOAT: return QVariant(node.Float()); + break; case JsonNode::JsonType::DATA_STRING: return QVariant(QString::fromUtf8(node.String().c_str())); + break; case JsonNode::JsonType::DATA_VECTOR: return JsonToList(node.Vector()); + break; case JsonNode::JsonType::DATA_STRUCT: return JsonToMap(node.Struct()); } return QVariant(); } diff --git a/lib/CArtHandler.cpp b/lib/CArtHandler.cpp index 6aade4fd9..563aadf9d 100644 --- a/lib/CArtHandler.cpp +++ b/lib/CArtHandler.cpp @@ -337,7 +337,7 @@ CArtifact * CArtHandler::loadFromJson(const JsonNode & node, const std::string & } const JsonNode & warMachine = node["warMachine"]; - if(warMachine.getType() == JsonNode::DATA_STRING && warMachine.String() != "") + if(warMachine.getType() == JsonNode::JsonType::DATA_STRING && warMachine.String() != "") { VLC->modh->identifiers.requestIdentifier("creature", warMachine, [=](si32 id) { @@ -396,7 +396,7 @@ void CArtHandler::loadSlots(CArtifact * art, const JsonNode & node) { if (!node["slot"].isNull()) //we assume non-hero slots are irrelevant? { - if (node["slot"].getType() == JsonNode::DATA_STRING) + if (node["slot"].getType() == JsonNode::JsonType::DATA_STRING) addSlot(art, node["slot"].String()); else { diff --git a/lib/CCreatureHandler.cpp b/lib/CCreatureHandler.cpp index 2edf41c69..85e7c33f4 100644 --- a/lib/CCreatureHandler.cpp +++ b/lib/CCreatureHandler.cpp @@ -735,7 +735,7 @@ void CCreatureHandler::loadCreatureJson(CCreature * creature, const JsonNode & c creature->animDefName = config["graphics"]["animation"].String(); //FIXME: MOD COMPATIBILITY - if (config["abilities"].getType() == JsonNode::DATA_STRUCT) + if (config["abilities"].getType() == JsonNode::JsonType::DATA_STRUCT) { for(auto &ability : config["abilities"].Struct()) { @@ -752,7 +752,7 @@ void CCreatureHandler::loadCreatureJson(CCreature * creature, const JsonNode & c { for(const JsonNode &ability : config["abilities"].Vector()) { - if (ability.getType() == JsonNode::DATA_VECTOR) + if (ability.getType() == JsonNode::JsonType::DATA_VECTOR) { assert(0); // should be unused now AddAbility(creature, ability.Vector()); // used only for H3 creatures diff --git a/lib/CCreatureSet.cpp b/lib/CCreatureSet.cpp index 4b7712fc7..4798f6a08 100644 --- a/lib/CCreatureSet.cpp +++ b/lib/CCreatureSet.cpp @@ -501,7 +501,7 @@ void CCreatureSet::serializeJson(JsonSerializeFormat & handler, const std::strin if(fixedSize) vstd::amax(sz, fixedSize.get()); - a.resize(sz, JsonNode::DATA_STRUCT); + a.resize(sz, JsonNode::JsonType::DATA_STRUCT); for(const auto & p : stacks) { diff --git a/lib/CModHandler.cpp b/lib/CModHandler.cpp index bf1c36ba8..5aa5bc04e 100644 --- a/lib/CModHandler.cpp +++ b/lib/CModHandler.cpp @@ -583,11 +583,11 @@ void CModInfo::loadLocalData(const JsonNode & data) bool validated = false; enabled = true; checksum = 0; - if (data.getType() == JsonNode::DATA_BOOL) + if (data.getType() == JsonNode::JsonType::DATA_BOOL) { enabled = data.Bool(); } - if (data.getType() == JsonNode::DATA_STRUCT) + if (data.getType() == JsonNode::JsonType::DATA_STRUCT) { enabled = data["active"].Bool(); validated = data["validated"].Bool(); diff --git a/lib/CSkillHandler.cpp b/lib/CSkillHandler.cpp index 46e37306e..0f3c4e175 100644 --- a/lib/CSkillHandler.cpp +++ b/lib/CSkillHandler.cpp @@ -128,7 +128,7 @@ std::vector CSkillHandler::loadLegacyData(size_t dataSize) std::vector legacyData; for(int id = 0; id < GameConstants::SKILL_QUANTITY; id++) { - JsonNode skillNode(JsonNode::DATA_STRUCT); + JsonNode skillNode(JsonNode::JsonType::DATA_STRUCT); skillNode["name"].String() = skillNames[id]; for(int level = 1; level < NSecondarySkill::levels.size(); level++) { diff --git a/lib/CTownHandler.cpp b/lib/CTownHandler.cpp index 8f12b1c4c..469ce1dab 100644 --- a/lib/CTownHandler.cpp +++ b/lib/CTownHandler.cpp @@ -354,7 +354,7 @@ void CTownHandler::loadBuilding(CTown * town, const std::string & stringID, cons ret->mode = CBuilding::BUILD_NORMAL; { - if(source["mode"].getType() == JsonNode::DATA_STRING) + if(source["mode"].getType() == JsonNode::JsonType::DATA_STRING) { auto rawMode = vstd::find_pos(MODES, source["mode"].String()); if(rawMode > 0) @@ -563,7 +563,7 @@ void CTownHandler::loadSiegeScreen(CTown &town, const JsonNode & source) static void readIcon(JsonNode source, std::string & small, std::string & large) { - if (source.getType() == JsonNode::DATA_STRUCT) // don't crash on old format + if (source.getType() == JsonNode::JsonType::DATA_STRUCT) // don't crash on old format { small = source["small"].String(); large = source["large"].String(); diff --git a/lib/JsonDetail.cpp b/lib/JsonDetail.cpp index b56b8d4b9..c16276c76 100644 --- a/lib/JsonDetail.cpp +++ b/lib/JsonDetail.cpp @@ -96,31 +96,31 @@ void JsonWriter::writeNode(const JsonNode &node) { switch(node.getType()) { - break; case JsonNode::DATA_NULL: + break; case JsonNode::JsonType::DATA_NULL: out << "null"; - break; case JsonNode::DATA_BOOL: + break; case JsonNode::JsonType::DATA_BOOL: if (node.Bool()) out << "true"; else out << "false"; - break; case JsonNode::DATA_FLOAT: + break; case JsonNode::JsonType::DATA_FLOAT: out << node.Float(); - break; case JsonNode::DATA_STRING: + break; case JsonNode::JsonType::DATA_STRING: writeString(node.String()); - break; case JsonNode::DATA_VECTOR: + break; case JsonNode::JsonType::DATA_VECTOR: out << "[" << "\n"; writeContainer(node.Vector().begin(), node.Vector().end()); out << prefix << "]"; - break; case JsonNode::DATA_STRUCT: + break; case JsonNode::JsonType::DATA_STRUCT: out << "{" << "\n"; writeContainer(node.Struct().begin(), node.Struct().end()); out << prefix << "}"; - break; case JsonNode::DATA_INTEGER: + break; case JsonNode::JsonType::DATA_INTEGER: out << node.Integer(); } } @@ -306,7 +306,7 @@ bool JsonParser::extractString(JsonNode &node) if (!extractString(str)) return false; - node.setType(JsonNode::DATA_STRING); + node.setType(JsonNode::JsonType::DATA_STRING); node.String() = str; return true; } @@ -354,7 +354,7 @@ bool JsonParser::extractFalse(JsonNode &node) bool JsonParser::extractStruct(JsonNode &node) { - node.setType(JsonNode::DATA_STRUCT); + node.setType(JsonNode::JsonType::DATA_STRUCT); pos++; if (!extractWhitespace()) @@ -396,7 +396,7 @@ bool JsonParser::extractStruct(JsonNode &node) bool JsonParser::extractArray(JsonNode &node) { pos++; - node.setType(JsonNode::DATA_VECTOR); + node.setType(JsonNode::JsonType::DATA_VECTOR); if (!extractWhitespace()) return false; @@ -536,7 +536,7 @@ bool JsonParser::extractFloat(JsonNode &node) if(negative) result = -result; - node.setType(JsonNode::DATA_FLOAT); + node.setType(JsonNode::JsonType::DATA_FLOAT); node.Float() = result; } else @@ -544,7 +544,7 @@ bool JsonParser::extractFloat(JsonNode &node) if(negative) integerPart = -integerPart; - node.setType(JsonNode::DATA_INTEGER); + node.setType(JsonNode::JsonType::DATA_INTEGER); node.Integer() = integerPart; } @@ -569,12 +569,12 @@ bool JsonParser::error(const std::string &message, bool warning) static const std::unordered_map stringToType = { - {"null", JsonNode::DATA_NULL}, - {"boolean", JsonNode::DATA_BOOL}, - {"number", JsonNode::DATA_FLOAT}, - {"string", JsonNode::DATA_STRING}, - {"array", JsonNode::DATA_VECTOR}, - {"object", JsonNode::DATA_STRUCT} + {"null", JsonNode::JsonType::DATA_NULL}, + {"boolean", JsonNode::JsonType::DATA_BOOL}, + {"number", JsonNode::JsonType::DATA_FLOAT}, + {"string", JsonNode::JsonType::DATA_STRING}, + {"array", JsonNode::JsonType::DATA_VECTOR}, + {"object", JsonNode::JsonType::DATA_STRUCT} }; namespace @@ -670,10 +670,10 @@ namespace JsonNode::JsonType type = it->second; //FIXME: hack for integer values - if(data.isNumber() && type == JsonNode::DATA_FLOAT) + if(data.isNumber() && type == JsonNode::JsonType::DATA_FLOAT) return ""; - if(type != data.getType() && data.getType() != JsonNode::DATA_NULL) + if(type != data.getType() && data.getType() != JsonNode::JsonType::DATA_NULL) return validator.makeErrorMessage("Type mismatch! Expected " + schema.String()); return ""; } @@ -785,7 +785,7 @@ namespace std::string errors; for (size_t i=0; i i) errors += itemEntryCheck(validator, data.Vector(), schema.Vector()[i], i); @@ -803,12 +803,12 @@ namespace std::string errors; // "items" is struct or empty (defaults to empty struct) - validation always successful const JsonNode & items = baseSchema["items"]; - if (items.getType() != JsonNode::DATA_VECTOR) + if (items.getType() != JsonNode::JsonType::DATA_VECTOR) return ""; for (size_t i=items.Vector().size(); i(static_cast(path.Float())); @@ -1187,12 +1187,12 @@ namespace Validation switch (type) { - case JsonNode::DATA_FLOAT: - case JsonNode::DATA_INTEGER: + case JsonNode::JsonType::DATA_FLOAT: + case JsonNode::JsonType::DATA_INTEGER: return numberFields; - case JsonNode::DATA_STRING: return stringFields; - case JsonNode::DATA_VECTOR: return vectorFields; - case JsonNode::DATA_STRUCT: return structFields; + case JsonNode::JsonType::DATA_STRING: return stringFields; + case JsonNode::JsonType::DATA_VECTOR: return vectorFields; + case JsonNode::JsonType::DATA_STRUCT: return structFields; default: return commonFields; } } diff --git a/lib/JsonNode.cpp b/lib/JsonNode.cpp index e00453ed4..09e8d5bd6 100644 --- a/lib/JsonNode.cpp +++ b/lib/JsonNode.cpp @@ -28,20 +28,20 @@ class CModHandler; static const JsonNode nullNode; JsonNode::JsonNode(JsonType Type): - type(DATA_NULL) + type(JsonType::DATA_NULL) { setType(Type); } JsonNode::JsonNode(const char *data, size_t datasize): - type(DATA_NULL) + type(JsonType::DATA_NULL) { JsonParser parser(data, datasize); *this = parser.parse(""); } JsonNode::JsonNode(ResourceID && fileURI): - type(DATA_NULL) + type(JsonType::DATA_NULL) { auto file = CResourceHandler::get()->load(fileURI)->readAll(); @@ -50,7 +50,7 @@ JsonNode::JsonNode(ResourceID && fileURI): } JsonNode::JsonNode(const ResourceID & fileURI): - type(DATA_NULL) + type(JsonType::DATA_NULL) { auto file = CResourceHandler::get()->load(fileURI)->readAll(); @@ -59,7 +59,7 @@ JsonNode::JsonNode(const ResourceID & fileURI): } JsonNode::JsonNode(ResourceID && fileURI, bool &isValidSyntax): - type(DATA_NULL) + type(JsonType::DATA_NULL) { auto file = CResourceHandler::get()->load(fileURI)->readAll(); @@ -69,25 +69,25 @@ JsonNode::JsonNode(ResourceID && fileURI, bool &isValidSyntax): } JsonNode::JsonNode(const JsonNode ©): - type(DATA_NULL), + type(JsonType::DATA_NULL), meta(copy.meta) { setType(copy.getType()); switch(type) { - break; case DATA_NULL: - break; case DATA_BOOL: Bool() = copy.Bool(); - break; case DATA_FLOAT: Float() = copy.Float(); - break; case DATA_STRING: String() = copy.String(); - break; case DATA_VECTOR: Vector() = copy.Vector(); - break; case DATA_STRUCT: Struct() = copy.Struct(); - break; case DATA_INTEGER:Integer() = copy.Integer(); + break; case JsonType::DATA_NULL: + break; case JsonType::DATA_BOOL: Bool() = copy.Bool(); + break; case JsonType::DATA_FLOAT: Float() = copy.Float(); + break; case JsonType::DATA_STRING: String() = copy.String(); + break; case JsonType::DATA_VECTOR: Vector() = copy.Vector(); + break; case JsonType::DATA_STRUCT: Struct() = copy.Struct(); + break; case JsonType::DATA_INTEGER:Integer() = copy.Integer(); } } JsonNode::~JsonNode() { - setType(DATA_NULL); + setType(JsonType::DATA_NULL); } void JsonNode::swap(JsonNode &b) @@ -110,13 +110,13 @@ bool JsonNode::operator == (const JsonNode &other) const { switch(type) { - case DATA_NULL: return true; - case DATA_BOOL: return Bool() == other.Bool(); - case DATA_FLOAT: return Float() == other.Float(); - case DATA_STRING: return String() == other.String(); - case DATA_VECTOR: return Vector() == other.Vector(); - case DATA_STRUCT: return Struct() == other.Struct(); - case DATA_INTEGER:return Integer()== other.Integer(); + case JsonType::DATA_NULL: return true; + case JsonType::DATA_BOOL: return Bool() == other.Bool(); + case JsonType::DATA_FLOAT: return Float() == other.Float(); + case JsonType::DATA_STRING: return String() == other.String(); + case JsonType::DATA_VECTOR: return Vector() == other.Vector(); + case JsonType::DATA_STRUCT: return Struct() == other.Struct(); + case JsonType::DATA_INTEGER:return Integer()== other.Integer(); } } return false; @@ -139,14 +139,14 @@ void JsonNode::setMeta(std::string metadata, bool recursive) { switch (type) { - break; case DATA_VECTOR: + break; case JsonType::DATA_VECTOR: { for(auto & node : Vector()) { node.setMeta(metadata); } } - break; case DATA_STRUCT: + break; case JsonType::DATA_STRUCT: { for(auto & node : Struct()) { @@ -163,14 +163,14 @@ void JsonNode::setType(JsonType Type) return; //float<->int conversion - if(type == DATA_FLOAT && Type == DATA_INTEGER) + if(type == JsonType::DATA_FLOAT && Type == JsonType::DATA_INTEGER) { si64 converted = data.Float; type = Type; data.Integer = converted; return; } - else if(type == DATA_INTEGER && Type == DATA_FLOAT) + else if(type == JsonType::DATA_INTEGER && Type == JsonType::DATA_FLOAT) { double converted = data.Integer; type = Type; @@ -179,14 +179,14 @@ void JsonNode::setType(JsonType Type) } //Reset node to nullptr - if (Type != DATA_NULL) - setType(DATA_NULL); + if (Type != JsonType::DATA_NULL) + setType(JsonType::DATA_NULL); switch (type) { - break; case DATA_STRING: delete data.String; - break; case DATA_VECTOR: delete data.Vector; - break; case DATA_STRUCT: delete data.Struct; + break; case JsonType::DATA_STRING: delete data.String; + break; case JsonType::DATA_VECTOR: delete data.Vector; + break; case JsonType::DATA_STRUCT: delete data.Struct; break; default: break; } @@ -194,124 +194,124 @@ void JsonNode::setType(JsonType Type) type = Type; switch(type) { - break; case DATA_NULL: - break; case DATA_BOOL: data.Bool = false; - break; case DATA_FLOAT: data.Float = 0; - break; case DATA_STRING: data.String = new std::string(); - break; case DATA_VECTOR: data.Vector = new JsonVector(); - break; case DATA_STRUCT: data.Struct = new JsonMap(); - break; case DATA_INTEGER: data.Integer = 0; + break; case JsonType::DATA_NULL: + break; case JsonType::DATA_BOOL: data.Bool = false; + break; case JsonType::DATA_FLOAT: data.Float = 0; + break; case JsonType::DATA_STRING: data.String = new std::string(); + break; case JsonType::DATA_VECTOR: data.Vector = new JsonVector(); + break; case JsonType::DATA_STRUCT: data.Struct = new JsonMap(); + break; case JsonType::DATA_INTEGER: data.Integer = 0; } } bool JsonNode::isNull() const { - return type == DATA_NULL; + return type == JsonType::DATA_NULL; } bool JsonNode::isNumber() const { - return type == DATA_INTEGER || type == DATA_FLOAT; + return type == JsonType::DATA_INTEGER || type == JsonType::DATA_FLOAT; } void JsonNode::clear() { - setType(DATA_NULL); + setType(JsonType::DATA_NULL); } bool & JsonNode::Bool() { - setType(DATA_BOOL); + setType(JsonType::DATA_BOOL); return data.Bool; } double & JsonNode::Float() { - setType(DATA_FLOAT); + setType(JsonType::DATA_FLOAT); return data.Float; } si64 & JsonNode::Integer() { - setType(DATA_INTEGER); + setType(JsonType::DATA_INTEGER); return data.Integer; } std::string & JsonNode::String() { - setType(DATA_STRING); + setType(JsonType::DATA_STRING); return *data.String; } JsonVector & JsonNode::Vector() { - setType(DATA_VECTOR); + setType(JsonType::DATA_VECTOR); return *data.Vector; } JsonMap & JsonNode::Struct() { - setType(DATA_STRUCT); + setType(JsonType::DATA_STRUCT); return *data.Struct; } const bool boolDefault = false; bool JsonNode::Bool() const { - if (type == DATA_NULL) + if (type == JsonType::DATA_NULL) return boolDefault; - assert(type == DATA_BOOL); + assert(type == JsonType::DATA_BOOL); return data.Bool; } const double floatDefault = 0; double JsonNode::Float() const { - if(type == DATA_NULL) + if(type == JsonType::DATA_NULL) return floatDefault; - else if(type == DATA_INTEGER) + else if(type == JsonType::DATA_INTEGER) return data.Integer; - assert(type == DATA_FLOAT); + assert(type == JsonType::DATA_FLOAT); return data.Float; } const si64 integetDefault = 0; si64 JsonNode::Integer() const { - if(type == DATA_NULL) + if(type == JsonType::DATA_NULL) return integetDefault; - else if(type == DATA_FLOAT) + else if(type == JsonType::DATA_FLOAT) return data.Float; - assert(type == DATA_INTEGER); + assert(type == JsonType::DATA_INTEGER); return data.Integer; } const std::string stringDefault = std::string(); const std::string & JsonNode::String() const { - if (type == DATA_NULL) + if (type == JsonType::DATA_NULL) return stringDefault; - assert(type == DATA_STRING); + assert(type == JsonType::DATA_STRING); return *data.String; } const JsonVector vectorDefault = JsonVector(); const JsonVector & JsonNode::Vector() const { - if (type == DATA_NULL) + if (type == JsonType::DATA_NULL) return vectorDefault; - assert(type == DATA_VECTOR); + assert(type == JsonType::DATA_VECTOR); return *data.Vector; } const JsonMap mapDefault = JsonMap(); const JsonMap & JsonNode::Struct() const { - if (type == DATA_NULL) + if (type == JsonType::DATA_NULL) return mapDefault; - assert(type == DATA_STRUCT); + assert(type == JsonType::DATA_STRUCT); return *data.Struct; } @@ -341,7 +341,7 @@ Node & resolvePointer(Node & in, const std::string & pointer) std::string entry = pointer.substr(1, splitPos -1); std::string remainer = splitPos == std::string::npos ? "" : pointer.substr(splitPos); - if (in.getType() == JsonNode::DATA_VECTOR) + if (in.getType() == JsonNode::JsonType::DATA_VECTOR) { if (entry.find_first_not_of("0123456789") != std::string::npos) // non-numbers in string throw std::runtime_error("Invalid Json pointer"); @@ -432,13 +432,13 @@ void JsonUtils::resolveIdentifier(si32 &var, const JsonNode &node, std::string n { switch (value.getType()) { - case JsonNode::DATA_INTEGER: + case JsonNode::JsonType::DATA_INTEGER: var = value.Integer(); break; - case JsonNode::DATA_FLOAT: + case JsonNode::JsonType::DATA_FLOAT: var = value.Float(); break; - case JsonNode::DATA_STRING: + case JsonNode::JsonType::DATA_STRING: VLC->modh->identifiers.requestIdentifier(value, [&](si32 identifier) { var = identifier; @@ -454,13 +454,13 @@ void JsonUtils::resolveIdentifier(const JsonNode &node, si32 &var) { switch (node.getType()) { - case JsonNode::DATA_INTEGER: + case JsonNode::JsonType::DATA_INTEGER: var = node.Integer(); break; - case JsonNode::DATA_FLOAT: + case JsonNode::JsonType::DATA_FLOAT: var = node.Float(); break; - case JsonNode::DATA_STRING: + case JsonNode::JsonType::DATA_STRING: VLC->modh->identifiers.requestIdentifier(node, [&](si32 identifier) { var = identifier; @@ -519,10 +519,10 @@ bool JsonUtils::parseBonus(const JsonNode &ability, Bonus *b) { switch (value->getType()) { - case JsonNode::DATA_STRING: + case JsonNode::JsonType::DATA_STRING: b->duration = parseByMap(bonusDurationMap, value, "duration type "); break; - case JsonNode::DATA_VECTOR: + case JsonNode::JsonType::DATA_VECTOR: { ui16 dur = 0; for (const JsonNode & d : value->Vector()) @@ -548,10 +548,10 @@ bool JsonUtils::parseBonus(const JsonNode &ability, Bonus *b) { switch (limiter.getType()) { - case JsonNode::DATA_STRING: //pre-defined limiters + case JsonNode::JsonType::DATA_STRING: //pre-defined limiters b->limiter = parseByMap(bonusLimiterMap, &limiter, "limiter type "); break; - case JsonNode::DATA_STRUCT: //customizable limiters + case JsonNode::JsonType::DATA_STRUCT: //customizable limiters { std::shared_ptr l; if (limiter["type"].String() == "CREATURE_TYPE_LIMITER") @@ -778,7 +778,7 @@ const JsonNode & JsonUtils::getSchema(std::string URI) void JsonUtils::merge(JsonNode & dest, JsonNode & source) { - if (dest.getType() == JsonNode::DATA_NULL) + if (dest.getType() == JsonNode::JsonType::DATA_NULL) { std::swap(dest, source); return; @@ -786,21 +786,21 @@ void JsonUtils::merge(JsonNode & dest, JsonNode & source) switch (source.getType()) { - case JsonNode::DATA_NULL: + case JsonNode::JsonType::DATA_NULL: { dest.clear(); break; } - case JsonNode::DATA_BOOL: - case JsonNode::DATA_FLOAT: - case JsonNode::DATA_INTEGER: - case JsonNode::DATA_STRING: - case JsonNode::DATA_VECTOR: + case JsonNode::JsonType::DATA_BOOL: + case JsonNode::JsonType::DATA_FLOAT: + case JsonNode::JsonType::DATA_INTEGER: + case JsonNode::JsonType::DATA_STRING: + case JsonNode::JsonType::DATA_VECTOR: { std::swap(dest, source); break; } - case JsonNode::DATA_STRUCT: + case JsonNode::JsonType::DATA_STRUCT: { //recursively merge all entries from struct for(auto & node : source.Struct()) diff --git a/lib/JsonNode.h b/lib/JsonNode.h index 1d526c674..f55f55606 100644 --- a/lib/JsonNode.h +++ b/lib/JsonNode.h @@ -19,7 +19,7 @@ class ResourceID; class DLL_LINKAGE JsonNode { public: - enum JsonType + enum class JsonType { DATA_NULL, DATA_BOOL, @@ -49,7 +49,7 @@ public: std::string meta; //Create empty node - JsonNode(JsonType Type = DATA_NULL); + JsonNode(JsonType Type = JsonType::DATA_NULL); //Create tree from Json-formatted input explicit JsonNode(const char * data, size_t datasize); //Create tree from JSON file @@ -117,16 +117,16 @@ public: h & meta; h & type; switch (type) { - break; case DATA_NULL: - break; case DATA_BOOL: h & data.Bool; - break; case DATA_FLOAT: h & data.Float; - break; case DATA_STRING: h & data.String; - break; case DATA_VECTOR: h & data.Vector; - break; case DATA_STRUCT: h & data.Struct; + break; case JsonType::DATA_NULL: + break; case JsonType::DATA_BOOL: h & data.Bool; + break; case JsonType::DATA_FLOAT: h & data.Float; + break; case JsonType::DATA_STRING: h & data.String; + break; case JsonType::DATA_VECTOR: h & data.Vector; + break; case JsonType::DATA_STRUCT: h & data.Struct; } if(version >= 770) { - if(type == DATA_INTEGER) + if(type == JsonType::DATA_INTEGER) h & data.Integer; } } diff --git a/lib/mapObjects/CGHeroInstance.cpp b/lib/mapObjects/CGHeroInstance.cpp index c78dba632..f090a9a36 100644 --- a/lib/mapObjects/CGHeroInstance.cpp +++ b/lib/mapObjects/CGHeroInstance.cpp @@ -1546,7 +1546,7 @@ void CGHeroInstance::serializeCommonOptions(JsonSerializeFormat & handler) { const JsonNode & portraitNode = handler.getCurrent()["portrait"]; - if(portraitNode.getType() == JsonNode::DATA_STRING) + if(portraitNode.getType() == JsonNode::JsonType::DATA_STRING) handler.serializeId("portrait", portrait, -1, &VLC->heroh->decodeHero, &VLC->heroh->encodeHero); else handler.serializeInt("portrait", portrait, -1); @@ -1574,7 +1574,7 @@ void CGHeroInstance::serializeCommonOptions(JsonSerializeFormat & handler) { auto primarySkills = handler.enterStruct("primarySkills"); - if(primarySkills.get().getType() == JsonNode::DATA_STRUCT) + if(primarySkills.get().getType() == JsonNode::JsonType::DATA_STRUCT) { for(int i = 0; i < GameConstants::PRIMARY_SKILLS; ++i) { @@ -1625,7 +1625,7 @@ void CGHeroInstance::serializeCommonOptions(JsonSerializeFormat & handler) const JsonNode & skillMap = handler.getCurrent(); secSkills.clear(); - if(skillMap.getType() == JsonNode::DATA_NULL) + if(skillMap.getType() == JsonNode::JsonType::DATA_NULL) { secSkills.push_back(std::pair(SecondarySkill::DEFAULT, -1)); } diff --git a/lib/mapObjects/CObjectClassesHandler.cpp b/lib/mapObjects/CObjectClassesHandler.cpp index 8d3428e6d..38ddb253d 100644 --- a/lib/mapObjects/CObjectClassesHandler.cpp +++ b/lib/mapObjects/CObjectClassesHandler.cpp @@ -221,7 +221,7 @@ void CObjectClassesHandler::loadObject(std::string scope, std::string name, cons void CObjectClassesHandler::loadSubObject(const std::string & identifier, JsonNode config, si32 ID, boost::optional subID) { - config.setType(JsonNode::DATA_STRUCT); // ensure that input is not NULL + config.setType(JsonNode::JsonType::DATA_STRUCT); // ensure that input is not NULL assert(objects.count(ID)); if (subID) { @@ -398,7 +398,7 @@ void AObjectTypeHandler::init(const JsonNode & input, boost::optionalmodh->identifiers.getIdentifier("artifact", value).get()); std::set allowedClasses; @@ -77,13 +77,13 @@ namespace JsonRandom ui32 minValue = 0; ui32 maxValue = std::numeric_limits::max(); - if (value["class"].getType() == JsonNode::DATA_STRING) + if (value["class"].getType() == JsonNode::JsonType::DATA_STRING) allowedClasses.insert(VLC->arth->stringToClass(value["class"].String())); else for (auto & entry : value["class"].Vector()) allowedClasses.insert(VLC->arth->stringToClass(entry.String())); - if (value["slot"].getType() == JsonNode::DATA_STRING) + if (value["slot"].getType() == JsonNode::JsonType::DATA_STRING) allowedPositions.insert(VLC->arth->stringToSlot(value["class"].String())); else for (auto & entry : value["slot"].Vector()) @@ -127,9 +127,9 @@ namespace JsonRandom SpellID loadSpell(const JsonNode & value, CRandomGenerator & rng, std::vector spells) { - if (value.getType() == JsonNode::DATA_STRING) + if (value.getType() == JsonNode::JsonType::DATA_STRING) return SpellID(VLC->modh->identifiers.getIdentifier("spell", value).get()); - if (value["type"].getType() == JsonNode::DATA_STRING) + if (value["type"].getType() == JsonNode::JsonType::DATA_STRING) return SpellID(VLC->modh->identifiers.getIdentifier("spell", value["type"]).get()); vstd::erase_if(spells, [=](SpellID spell) diff --git a/lib/mapObjects/MiscObjects.cpp b/lib/mapObjects/MiscObjects.cpp index 22c822b93..c25476214 100644 --- a/lib/mapObjects/MiscObjects.cpp +++ b/lib/mapObjects/MiscObjects.cpp @@ -788,7 +788,7 @@ void CGMine::serializeJsonOptions(JsonSerializeFormat & handler) for(int i = 0; i < PlayerColor::PLAYER_LIMIT_I; i++) if(tempOwner.getNum() & 1<modh->identifiers.getIdentifier(data["type"]); if(identifier) @@ -567,10 +567,10 @@ void CMapFormatJson::readTeams(JsonDeserializer & handler) auto teams = handler.enterArray("teams"); const JsonNode & src = teams.get(); - if(src.getType() != JsonNode::DATA_VECTOR) + if(src.getType() != JsonNode::JsonType::DATA_VECTOR) { // No alliances - if(src.getType() != JsonNode::DATA_NULL) + if(src.getType() != JsonNode::JsonType::DATA_NULL) logGlobal->error("Invalid teams field type"); mapHeader->howManyTeams = 0; @@ -625,14 +625,14 @@ void CMapFormatJson::writeTeams(JsonSerializer & handler) JsonNode & dest = teams.get(); //construct output - dest.setType(JsonNode::DATA_VECTOR); + dest.setType(JsonNode::JsonType::DATA_VECTOR); for(const std::set & teamData : teamsData) { - JsonNode team(JsonNode::DATA_VECTOR); + JsonNode team(JsonNode::JsonType::DATA_VECTOR); for(const PlayerColor & player : teamData) { - JsonNode member(JsonNode::DATA_STRING); + JsonNode member(JsonNode::JsonType::DATA_STRING); member.String() = GameConstants::PLAYER_COLOR_NAMES[player.getNum()]; team.Vector().push_back(std::move(member)); } @@ -747,7 +747,7 @@ void CMapFormatJson::writeDisposedHeroes(JsonSerializeFormat & handler) for(int playerNum = 0; playerNum < PlayerColor::PLAYER_LIMIT_I; playerNum++) if((1 << playerNum) & hero.players) { - JsonNode player(JsonNode::DATA_STRING); + JsonNode player(JsonNode::JsonType::DATA_STRING); player.String() = GameConstants::PLAYER_COLOR_NAMES[playerNum]; players.push_back(player); } @@ -1347,7 +1347,7 @@ void CMapSaverJson::writeTerrain() void CMapSaverJson::writeObjects() { logGlobal->trace("Saving objects"); - JsonNode data(JsonNode::DATA_STRUCT); + JsonNode data(JsonNode::JsonType::DATA_STRUCT); JsonSerializer handler(mapObjectResolver.get(), data); @@ -1361,7 +1361,7 @@ void CMapSaverJson::writeObjects() if(map->grailPos.valid()) { - JsonNode grail(JsonNode::DATA_STRUCT); + JsonNode grail(JsonNode::JsonType::DATA_STRUCT); grail["type"].String() = "grail"; grail["x"].Float() = map->grailPos.x; diff --git a/lib/rmg/CRmgTemplateStorage.cpp b/lib/rmg/CRmgTemplateStorage.cpp index c443d281a..eb4c05150 100644 --- a/lib/rmg/CRmgTemplateStorage.cpp +++ b/lib/rmg/CRmgTemplateStorage.cpp @@ -137,7 +137,7 @@ void CRmgTemplateStorage::loadObject(std::string scope, std::string name, const if (!zoneNode["treasure"].isNull()) { //TODO: parse vector of different treasure settings - if (zoneNode["treasure"].getType() == JsonNode::DATA_STRUCT) + if (zoneNode["treasure"].getType() == JsonNode::JsonType::DATA_STRUCT) { auto treasureInfo = zoneNode["treasure"].Struct(); { @@ -148,7 +148,7 @@ void CRmgTemplateStorage::loadObject(std::string scope, std::string name, const zone->addTreasureInfo(ti); } } - else if (zoneNode["treasure"].getType() == JsonNode::DATA_VECTOR) + else if (zoneNode["treasure"].getType() == JsonNode::JsonType::DATA_VECTOR) { for (auto treasureInfo : zoneNode["treasure"].Vector()) { diff --git a/lib/serializer/JsonDeserializer.cpp b/lib/serializer/JsonDeserializer.cpp index 43b086c68..071fd43d6 100644 --- a/lib/serializer/JsonDeserializer.cpp +++ b/lib/serializer/JsonDeserializer.cpp @@ -21,7 +21,7 @@ JsonDeserializer::JsonDeserializer(const IInstanceResolver * instanceResolver_, void JsonDeserializer::serializeInternal(const std::string & fieldName, boost::logic::tribool & value) { const JsonNode & data = current->operator[](fieldName); - if(data.getType() != JsonNode::DATA_BOOL) + if(data.getType() != JsonNode::JsonType::DATA_BOOL) value = boost::logic::indeterminate; else value = data.Bool(); diff --git a/lib/serializer/JsonSerializeFormat.cpp b/lib/serializer/JsonSerializeFormat.cpp index a46a74c49..74cbb60d7 100644 --- a/lib/serializer/JsonSerializeFormat.cpp +++ b/lib/serializer/JsonSerializeFormat.cpp @@ -79,7 +79,7 @@ JsonStructSerializer::JsonStructSerializer(JsonSerializeFormat & owner_, const s optional(false) { if(owner.saving) - thisNode->setType(JsonNode::DATA_STRUCT); + thisNode->setType(JsonNode::JsonType::DATA_STRUCT); } JsonStructSerializer::JsonStructSerializer(JsonSerializeHelper & parent, const std::string & fieldName): @@ -87,7 +87,7 @@ JsonStructSerializer::JsonStructSerializer(JsonSerializeHelper & parent, const s optional(false) { if(owner.saving) - thisNode->setType(JsonNode::DATA_STRUCT); + thisNode->setType(JsonNode::JsonType::DATA_STRUCT); } JsonStructSerializer::JsonStructSerializer(JsonSerializeFormat & owner_, JsonNode * thisNode_): @@ -95,7 +95,7 @@ JsonStructSerializer::JsonStructSerializer(JsonSerializeFormat & owner_, JsonNod optional(false) { if(owner.saving) - thisNode->setType(JsonNode::DATA_STRUCT); + thisNode->setType(JsonNode::JsonType::DATA_STRUCT); } JsonStructSerializer::~JsonStructSerializer() @@ -141,7 +141,7 @@ void JsonArraySerializer::resize(const size_t newSize, JsonNode::JsonType type) resize(newSize); for(JsonNode & n : thisNode->Vector()) - if(n.getType() == JsonNode::DATA_NULL) + if(n.getType() == JsonNode::JsonType::DATA_NULL) n.setType(type); } diff --git a/lib/serializer/JsonSerializeFormat.h b/lib/serializer/JsonSerializeFormat.h index 7043bf267..86a1a700f 100644 --- a/lib/serializer/JsonSerializeFormat.h +++ b/lib/serializer/JsonSerializeFormat.h @@ -75,13 +75,13 @@ public: JsonStructSerializer enterStruct(const size_t index); template - void syncSize(Container & c, JsonNode::JsonType type = JsonNode::DATA_NULL); + void syncSize(Container & c, JsonNode::JsonType type = JsonNode::JsonType::DATA_NULL); ///vector of serializable <-> Json vector of structs template void serializeStruct(std::vector & value) { - syncSize(value, JsonNode::DATA_STRUCT); + syncSize(value, JsonNode::JsonType::DATA_STRUCT); for(size_t idx = 0; idx < size(); idx++) { diff --git a/lib/serializer/JsonSerializer.cpp b/lib/serializer/JsonSerializer.cpp index 3d01b376b..446081ca9 100644 --- a/lib/serializer/JsonSerializer.cpp +++ b/lib/serializer/JsonSerializer.cpp @@ -61,7 +61,7 @@ void JsonSerializer::serializeInternal(const std::string & fieldName, std::vecto for(const si32 rawId : value) { - JsonNode jsonElement(JsonNode::DATA_STRING); + JsonNode jsonElement(JsonNode::JsonType::DATA_STRING); jsonElement.String() = encoder(rawId); data.push_back(std::move(jsonElement)); } @@ -133,7 +133,7 @@ void JsonSerializer::writeLICPartBuffer(const std::string & fieldName, const std for(auto & s : buffer) { - JsonNode val(JsonNode::DATA_STRING); + JsonNode val(JsonNode::JsonType::DATA_STRING); std::swap(val.String(), s); target.push_back(std::move(val)); } diff --git a/lib/spells/AdventureSpellMechanics.cpp b/lib/spells/AdventureSpellMechanics.cpp index 201075693..274697eb0 100644 --- a/lib/spells/AdventureSpellMechanics.cpp +++ b/lib/spells/AdventureSpellMechanics.cpp @@ -443,7 +443,7 @@ ESpellCastResult TownPortalMechanics::beginCast(const SpellCastEnvironment * env { auto queryCallback = [=](const JsonNode & reply) -> void { - if(reply.getType() == JsonNode::DATA_INTEGER) + if(reply.getType() == JsonNode::JsonType::DATA_INTEGER) { ObjectInstanceID townId(reply.Integer()); diff --git a/lib/spells/CSpellHandler.cpp b/lib/spells/CSpellHandler.cpp index bd0b72ed4..f850e54c8 100644 --- a/lib/spells/CSpellHandler.cpp +++ b/lib/spells/CSpellHandler.cpp @@ -708,7 +708,7 @@ std::vector CSpellHandler::loadLegacyData(size_t dataSize) { do { - JsonNode lineNode(JsonNode::DATA_STRUCT); + JsonNode lineNode(JsonNode::JsonType::DATA_STRUCT); const si32 id = legacyData.size(); @@ -951,9 +951,9 @@ CSpell * CSpellHandler::loadFromJson(const JsonNode & json, const std::string & { CSpell::TAnimation newItem; - if(item.getType() == JsonNode::DATA_STRING) + if(item.getType() == JsonNode::JsonType::DATA_STRING) newItem.resourceName = item.String(); - else if(item.getType() == JsonNode::DATA_STRUCT) + else if(item.getType() == JsonNode::JsonType::DATA_STRUCT) { newItem.resourceName = item["defName"].String(); diff --git a/server/CQuery.cpp b/server/CQuery.cpp index 58ad02a69..7106efd8d 100644 --- a/server/CQuery.cpp +++ b/server/CQuery.cpp @@ -426,7 +426,7 @@ bool CDialogQuery::blocksPack(const CPack * pack) const void CDialogQuery::setReply(const JsonNode & reply) { - if(reply.getType() == JsonNode::DATA_INTEGER) + if(reply.getType() == JsonNode::JsonType::DATA_INTEGER) answer = reply.Integer(); } diff --git a/test/map/MapComparer.cpp b/test/map/MapComparer.cpp index ec3ca7bb1..aa61873e7 100644 --- a/test/map/MapComparer.cpp +++ b/test/map/MapComparer.cpp @@ -305,17 +305,17 @@ bool JsonMapComparer::isEmpty(const JsonNode & value) { switch (value.getType()) { - case JsonNode::DATA_NULL: + case JsonNode::JsonType::DATA_NULL: return true; - case JsonNode::DATA_BOOL: + case JsonNode::JsonType::DATA_BOOL: return !value.Bool(); - case JsonNode::DATA_FLOAT: + case JsonNode::JsonType::DATA_FLOAT: return value.Float() == 0; - case JsonNode::DATA_STRING: + case JsonNode::JsonType::DATA_STRING: return value.String() == ""; - case JsonNode::DATA_VECTOR: + case JsonNode::JsonType::DATA_VECTOR: return value.Vector().empty(); - case JsonNode::DATA_STRUCT: + case JsonNode::JsonType::DATA_STRUCT: return value.Struct().empty(); break; default: @@ -392,24 +392,24 @@ void JsonMapComparer::checkEqualJson(const JsonNode & actual, const JsonNode & e { switch (actual.getType()) { - case JsonNode::DATA_NULL: + case JsonNode::JsonType::DATA_NULL: break; //do nothing - case JsonNode::DATA_BOOL: + case JsonNode::JsonType::DATA_BOOL: check(actual.Bool() == expected.Bool(), "mismatch"); break; - case JsonNode::DATA_FLOAT: + case JsonNode::JsonType::DATA_FLOAT: checkEqualFloat(actual.Float(),expected.Float()); break; - case JsonNode::DATA_STRING: + case JsonNode::JsonType::DATA_STRING: checkEqualString(actual.String(),expected.String()); break; - case JsonNode::DATA_VECTOR: + case JsonNode::JsonType::DATA_VECTOR: checkEqualJson(actual.Vector(), expected.Vector()); break; - case JsonNode::DATA_STRUCT: + case JsonNode::JsonType::DATA_STRUCT: checkEqualJson(actual.Struct(), expected.Struct()); break; - case JsonNode::DATA_INTEGER: + case JsonNode::JsonType::DATA_INTEGER: checkEqualInteger(actual.Integer(), expected.Integer()); break; default: