Webparser: Added $...$ escape syntax for using the string value of another Webparser measure as input for the URL option.

Syntax: Url=http://www.[$SomeOtherWebparserMeasure$].com
This commit is contained in:
Brian Ferguson 2013-07-11 11:40:22 -06:00
parent c3987115ee
commit 2507b4fe2c

View File

@ -759,11 +759,14 @@ PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
std::unordered_map<std::wstring, std::wstring> replacedTokens;
for (auto iter : tokens)
{
if (iter[0] == L'[' && iter[iter.size() - 1] == L']' && iter.size() >= 3)
if (iter.size() >= 3 && iter[0] == L'[' && iter[iter.size() - 1] == L']')
{
std::wstring section = iter.substr(1, iter.size() - 2);
bool found = false;
// Check for "escaped" Webparser measures eg. [$WebparserMeasure$]
if (section[0] != L'$' && section[section.size() - 1] != L'$')
{
for (auto jter : g_Measures)
{
if (jter->section == section)
@ -772,11 +775,20 @@ PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
break;
}
}
}
else
{
section.erase(0,1);
section.erase(section.size() - 1, 1);
}
section.insert(0, L"[");
section.append(L"]");
// A non-WebParser measure was found, read a "dummy" key value
if (!found)
{
replacedTokens[iter] = RmReadString(rm, L"DUMMY", iter.c_str(), TRUE);
replacedTokens[iter] = RmReadString(rm, L"DUMMY", section.c_str(), TRUE);
}
}
}