From 5e2a22a0061cd9b80993514e626085ea1d5915b0 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 1 May 2015 15:58:22 -0700 Subject: [PATCH] perform requested interpolation when unpacking --- libraries/networking/src/JSONBreakableMarshal.cpp | 14 +++++++++++++- libraries/networking/src/LimitedNodeList.h | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/libraries/networking/src/JSONBreakableMarshal.cpp b/libraries/networking/src/JSONBreakableMarshal.cpp index e3d79693aa..27b3248c8d 100644 --- a/libraries/networking/src/JSONBreakableMarshal.cpp +++ b/libraries/networking/src/JSONBreakableMarshal.cpp @@ -153,6 +153,7 @@ QVariantMap JSONBreakableMarshal::fromStringList(const QStringList& stringList) QVariant* currentValue = &result; // pull the key (everything left of the equality sign) + QString parentKeypath; QString keypath = marshalString.left(equalityIndex); // setup for array index checking @@ -161,6 +162,8 @@ QVariantMap JSONBreakableMarshal::fromStringList(const QStringList& stringList) // as long as we have a keypath we need to recurse downwards while (!keypath.isEmpty()) { + parentKeypath = keypath; + int arrayBracketIndex = arrayRegex.indexIn(keypath); // is this an array index @@ -255,10 +258,19 @@ QVariantMap JSONBreakableMarshal::fromStringList(const QStringList& stringList) // change the currentValue to the QJsonValue for this key currentValue = ¤tMap[subKey]; - } + } } *currentValue = fromString(marshalString.mid(equalityIndex + 1)); + + if (_interpolationMap.contains(parentKeypath)) { + // we expect the currentValue here to be a string, that's the key we use for interpolation + // bail if it isn't + if (currentValue->canConvert(QMetaType::QString) + && _interpolationMap[parentKeypath].canConvert(QMetaType::QVariantMap)) { + *currentValue = _interpolationMap[parentKeypath].toMap()[currentValue->toString()]; + } + } } } diff --git a/libraries/networking/src/LimitedNodeList.h b/libraries/networking/src/LimitedNodeList.h index a9f9b86bad..8d05fa8fab 100644 --- a/libraries/networking/src/LimitedNodeList.h +++ b/libraries/networking/src/LimitedNodeList.h @@ -55,7 +55,7 @@ const QString ASSIGNMENT_CLIENT_MONITOR_LOCAL_PORT_SMEM_KEY = "assignment-client const char DEFAULT_ASSIGNMENT_CLIENT_MONITOR_HOSTNAME[] = "localhost"; const unsigned short DEFAULT_ASSIGNMENT_CLIENT_MONITOR_PORT = 40104; -const QString USERNAME_UUID_REPLACEMENT_STATS_KEY = "$username_for_uuid"; +const QString USERNAME_UUID_REPLACEMENT_STATS_KEY = "$username"; class HifiSockAddr;