Implement new intrin params; fix parseSynonyms

Previously parseSynonyms didn't properly return the last provided
synonym of the param in question, so fix it here to do that.
This commit is contained in:
2026-04-03 23:14:23 -04:00
parent 5811af7cb1
commit 3dd627c91c
3 changed files with 290 additions and 24 deletions
+17 -10
View File
@@ -121,24 +121,31 @@ public:
* @param synonymNames The collection of synonymous parameter names to try
* @param defaultValue The default value to return if no parameter is found
* @return The parsed integer value, or defaultValue if none found
* @note Synonyms are tried in reverse order; lattermost synonym wins if multiple are present
* @note The lattermost supplied matching param wins if multiple are present
*/
template <typename SynonymCollectionT>
static int parseOptionalParamAsIntWithSynonyms(
const std::vector<std::pair<std::string,std::string>>& params,
const std::vector<std::string>& synonymNames,
const SynonymCollectionT& synonymNames,
int defaultValue
)
{
// Loop through synonyms in reverse order; lattermost synonym wins.
for (auto synIt = synonymNames.rbegin();
synIt != synonymNames.rend(); ++synIt)
// Loop through params in reverse order; lattermost supplied param wins.
for (auto paramIt = params.rbegin(); paramIt != params.rend(); ++paramIt)
{
const auto& paramName = *synIt;
const auto& [paramName, paramValue] = *paramIt;
auto synonymIt = std::find(
synonymNames.begin(), synonymNames.end(), paramName);
if (synonymIt == synonymNames.end())
{ continue; }
try {
return parseRequiredParamAsInt(params, paramName);
} catch (const std::exception&) {
// Parameter not found or parse error, continue to next synonym
continue;
return std::stoi(paramValue);
} catch (const std::exception& e) {
throw std::runtime_error(
"Failed to parse '" + paramName + "' param value '"
+ paramValue + "' as integer: " + e.what());
}
}