# HG changeset patch # User Alain Mazy # Date 1553092024 -3600 # Node ID 75664eeacae5da53d54da89a0289364802b59675 # Parent b336dfa71f128c7324f0286c2e649e249c28670b added sets in code generation (not tested yet in TS) diff -r b336dfa71f12 -r 75664eeacae5 Resources/CodeGeneration/stonegentool.py --- a/Resources/CodeGeneration/stonegentool.py Wed Mar 20 10:11:53 2019 +0100 +++ b/Resources/CodeGeneration/stonegentool.py Wed Mar 20 15:27:04 2019 +0100 @@ -82,6 +82,7 @@ retVal = canonicalTypename retVal = retVal.replace("map", "std::map") retVal = retVal.replace("vector", "std::vector") + retVal = retVal.replace("set", "std::set") retVal = retVal.replace("string", "std::string") retVal = retVal.replace("int32", "int32_t") retVal = retVal.replace("float32", "float") @@ -98,6 +99,7 @@ retVal = canonicalTypename retVal = retVal.replace("map", "Map") retVal = retVal.replace("vector", "Array") + retVal = retVal.replace("set", "Set") retVal = retVal.replace("int32", "number") retVal = retVal.replace("float32", "number") retVal = retVal.replace("float64", "number") diff -r b336dfa71f12 -r 75664eeacae5 Resources/CodeGeneration/template.in.h.j2 --- a/Resources/CodeGeneration/template.in.h.j2 Wed Mar 20 10:11:53 2019 +0100 +++ b/Resources/CodeGeneration/template.in.h.j2 Wed Mar 20 15:27:04 2019 +0100 @@ -13,6 +13,7 @@ #include #include #include +#include #include //#define STONEGEN_NO_CPP11 1 @@ -199,6 +200,43 @@ return out; } + /** Throws in case of problem */ + template + void _StoneDeserializeValue( + std::set& destValue, const Json::Value& jsonValue) + { + destValue.clear(); + for (Json::Value::ArrayIndex i = 0; i != jsonValue.size(); i++) + { + T innerDestValue; + _StoneDeserializeValue(innerDestValue, jsonValue[i]); + destValue.insert(innerDestValue); + } + } + + template + Json::Value _StoneSerializeValue(const std::set& value) + { + Json::Value result(Json::arrayValue); + for (typename std::set::const_iterator it = value.begin(); it != value.end(); ++it) + { + result.append(_StoneSerializeValue(*it)); + } + return result; + } + + template + std::ostream& StoneDumpValue(std::ostream& out, const std::set& value, size_t indent) + { + out << MakeIndent(indent) << "[\n"; + for (typename std::set::const_iterator it = value.begin(); it != value.end(); ++it) + { + StoneDumpValue(out, *it, indent+2); + } + out << MakeIndent(indent) << "]\n"; + return out; + } + inline void StoneCheckSerializedValueTypeGeneric(const Json::Value& value) { if ((!value.isMember("type")) || (!value["type"].isString()))