DAPSpecs: Update parseRequiredParamAsInt to support all param lists

This commit is contained in:
2025-11-01 01:11:34 -04:00
parent e824685c19
commit 67af9f02da
4 changed files with 20 additions and 16 deletions
+8 -7
View File
@@ -81,28 +81,29 @@ public:
}
/**
* @brief Parse a required integer parameter from provider parameters
* @param spec The device attachment specification
* @brief Parse a required integer parameter from a parameter list
* @param params The parameter vector to search in
* @param paramName The name of the parameter to parse
* @return The parsed integer value
* @throws std::runtime_error if parameter is not found or cannot be parsed
*/
static int parseRequiredParamAsInt(
const DeviceAttachmentSpec& spec, const std::string& paramName
const std::vector<std::pair<std::string,std::string>>& params,
const std::string& paramName
)
{
auto it = std::find_if(
spec.providerParams.begin(),
spec.providerParams.end(),
params.begin(),
params.end(),
[&paramName](const auto& param) {
return param.first == paramName;
}
);
if (it == spec.providerParams.end())
if (it == params.end())
{
throw std::runtime_error(
"No " + paramName + " specified in provider params");
"No " + paramName + " specified in params");
}
try {