diff --git a/src/Targets/TargetDescription/TargetDescriptionFile.cpp b/src/Targets/TargetDescription/TargetDescriptionFile.cpp index 807a080d..3987f70c 100644 --- a/src/Targets/TargetDescription/TargetDescriptionFile.cpp +++ b/src/Targets/TargetDescription/TargetDescriptionFile.cpp @@ -255,6 +255,16 @@ namespace Targets::TargetDescription this->loadPinouts(document); } + const std::string& TargetDescriptionFile::deviceAttribute(const std::string& attributeName) const { + const auto attributeIt = this->deviceAttributesByName.find(attributeName); + + if (attributeIt == this->deviceAttributesByName.end()) { + throw Exception("Missing target device attribute (\"" + attributeName + "\")"); + } + + return attributeIt->second; + } + std::optional TargetDescriptionFile::tryGetAttribute( const QDomElement& element, const QString& attributeName @@ -594,16 +604,6 @@ namespace Targets::TargetDescription ); } - const std::string& TargetDescriptionFile::deviceAttribute(const std::string& attributeName) const { - const auto attributeIt = this->deviceAttributesByName.find(attributeName); - - if (attributeIt == this->deviceAttributesByName.end()) { - throw Exception("Missing target device attribute (\"" + attributeName + "\")"); - } - - return attributeIt->second; - } - void TargetDescriptionFile::loadVariants(const QDomDocument& document) { const auto deviceElement = document.elementsByTagName("device").item(0).toElement(); diff --git a/src/Targets/TargetDescription/TargetDescriptionFile.hpp b/src/Targets/TargetDescription/TargetDescriptionFile.hpp index 736ae1bd..6f87e957 100644 --- a/src/Targets/TargetDescription/TargetDescriptionFile.hpp +++ b/src/Targets/TargetDescription/TargetDescriptionFile.hpp @@ -140,6 +140,8 @@ namespace Targets::TargetDescription void init(const std::string& xmlFilePath); void init(const QDomDocument& document); + const std::string& deviceAttribute(const std::string& attributeName) const; + static std::optional tryGetAttribute(const QDomElement& element, const QString& attributeName); static std::string getAttribute(const QDomElement& element, const QString& attributeName); @@ -158,14 +160,6 @@ namespace Targets::TargetDescription static RegisterGroupInstance registerGroupInstanceFromXml(const QDomElement& xmlElement); static Signal signalFromXml(const QDomElement& xmlElement); - /** - * Fetches a device attribute value by name. Throws an exception if the attribute is not found. - * - * @param attributeName - * @return - */ - const std::string& deviceAttribute(const std::string& attributeName) const; - /** * Extracts all variants and loads them into this->variants. */