Api improvements: ambience-count-[l|g]t-val and Comparator

This commit is contained in:
2026-04-03 23:54:22 -04:00
parent bedcf78b29
commit 7516da6aa8
4 changed files with 111 additions and 19 deletions
+22 -2
View File
@@ -6,6 +6,7 @@
#include <iostream>
#include <sstream>
#include <algorithm>
#include <iterator>
#include <stdexcept>
namespace smo {
@@ -115,6 +116,25 @@ public:
}
}
/**
* @brief Parse an optional integer parameter from a parameter list
* @param params The parameter vector to search in
* @param paramName The name of the parameter to parse
* @param defaultValue The default value to return if no parameter is found
* @return The parsed integer value, or defaultValue if none found
* @note The lattermost supplied matching param wins if multiple are present
*/
static int parseOptionalParamAsInt(
const std::vector<std::pair<std::string,std::string>>& params,
const std::string& paramName,
int defaultValue
)
{
const std::string paramNames[] = {paramName};
return parseOptionalParamAsIntWithSynonyms(
params, paramNames, defaultValue);
}
/**
* @brief Parse an optional integer parameter from a parameter list using synonyms
* @param params The parameter vector to search in
@@ -135,9 +155,9 @@ public:
{
const auto& [paramName, paramValue] = *paramIt;
auto synonymIt = std::find(
synonymNames.begin(), synonymNames.end(), paramName);
std::begin(synonymNames), std::end(synonymNames), paramName);
if (synonymIt == synonymNames.end())
if (synonymIt == std::end(synonymNames))
{ continue; }
try {