Api improvements: ambience-count-[l|g]t-val and Comparator
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user