DAPSpecs: Update parseRequiredParamAsInt to support all param lists
This commit is contained in:
@@ -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(),
|
||||
[¶mName](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 {
|
||||
|
||||
Reference in New Issue
Block a user