Move getRequiredParamAsInt into deviceAttachmentSpec.h

Make it accessible for all senseApis.
This commit is contained in:
2025-09-06 21:12:43 -04:00
parent 38b29ddfc0
commit 3b07a15e11
3 changed files with 42 additions and 32 deletions
+6 -29
View File
@@ -69,9 +69,12 @@ AttachedWindow::AttachedWindow(
": Required xcbXorg function pointers not available");
}
windowSelector.display = getRequiredParamAsInt(*spec, "display");
windowSelector.screen = getRequiredParamAsInt(*spec, "screen");
parseWindowSelector(*spec);
windowSelector.display = smo::device::DeviceAttachmentSpec
::parseRequiredParamAsInt(*spec, "display");
windowSelector.screen = smo::device::DeviceAttachmentSpec
::parseRequiredParamAsInt(*spec, "screen");
parseWindowSelector(*spec);
// Get connection from libxcbXorg
std::shared_ptr<xcb_xorg::XcbConnection> conn =
@@ -149,32 +152,6 @@ void AttachedWindow::parseWindowSelector(
}
}
int AttachedWindow::getRequiredParamAsInt(const smo::device::DeviceAttachmentSpec& spec,
const std::string& paramName)
{
auto it = std::find_if(
spec.providerParams.begin(),
spec.providerParams.end(),
[&paramName](const auto& param) {
return param.first == paramName;
}
);
if (it == spec.providerParams.end())
{
throw std::runtime_error(
"No " + paramName + " specified in provider params");
}
try {
return std::stoi(it->second);
} catch (const std::exception& e) {
throw std::runtime_error(
"Failed to parse '" + paramName + "' param value '"
+ it->second + "' as integer: " + e.what());
}
}
std::string AttachedWindow::stringify() const {
std::ostringstream os;