# HG changeset patch # User Alain Mazy # Date 1558011881 -7200 # Node ID e8b83fe55a3305007f9c8e2758a19098c0bb9bec # Parent 077f28e3ea3d5e99508389ff40812d00dc5e85ee added support for float + map instead of only map diff -r 077f28e3ea3d -r e8b83fe55a33 Resources/CodeGeneration/template.in.h.j2 --- a/Resources/CodeGeneration/template.in.h.j2 Thu May 16 10:46:35 2019 +0200 +++ b/Resources/CodeGeneration/template.in.h.j2 Thu May 16 15:04:41 2019 +0200 @@ -109,6 +109,21 @@ } /** Throws in case of problem */ + inline void _StoneDeserializeValue(float& destValue, const Json::Value& jsonValue) + { + if (!jsonValue.isNull()) + { + destValue = jsonValue.asFloat(); + } + } + + inline Json::Value _StoneSerializeValue(float value) + { + Json::Value result(value); + return result; + } + + /** Throws in case of problem */ inline void _StoneDeserializeValue(bool& destValue, const Json::Value& jsonValue) { if (!jsonValue.isNull()) @@ -168,9 +183,9 @@ } /** Throws in case of problem */ - template + template void _StoneDeserializeValue( - std::map& destValue, const Json::Value& jsonValue) + std::map& destValue, const Json::Value& jsonValue) { if (!jsonValue.isNull()) { @@ -180,23 +195,22 @@ itr != jsonValue.end(); itr++) { - std::string key; + TK key; _StoneDeserializeValue(key, itr.key()); - T innerDestValue; + TV innerDestValue; _StoneDeserializeValue(innerDestValue, *itr); destValue[key] = innerDestValue; } } } - - template - Json::Value _StoneSerializeValue(const std::map& value) + template + Json::Value _StoneSerializeValue(const std::map& value) { Json::Value result(Json::objectValue); - for (typename std::map::const_iterator it = value.cbegin(); + for (typename std::map::const_iterator it = value.cbegin(); it != value.cend(); ++it) { // it->first it->second @@ -205,11 +219,11 @@ return result; } - template - std::ostream& StoneDumpValue(std::ostream& out, const std::map& value, size_t indent) + template + std::ostream& StoneDumpValue(std::ostream& out, const std::map& value, size_t indent) { out << MakeIndent(indent) << "{\n"; - for (typename std::map::const_iterator it = value.cbegin(); + for (typename std::map::const_iterator it = value.cbegin(); it != value.cend(); ++it) { out << MakeIndent(indent+2) << "\"" << it->first << "\" : ";