From 11c0106fd6be56a3e4f3bdf74845411b1d15a059 Mon Sep 17 00:00:00 2001 From: Nav Date: Mon, 26 Feb 2024 19:29:53 +0000 Subject: [PATCH] Tidying --- src/Services/StringService.cpp | 2 +- .../TargetDescriptionFile.cpp | 19 +++--- .../TargetDescriptionFile.hpp | 63 ------------------- 3 files changed, 10 insertions(+), 74 deletions(-) diff --git a/src/Services/StringService.cpp b/src/Services/StringService.cpp index a0385d69..1995ba2f 100644 --- a/src/Services/StringService.cpp +++ b/src/Services/StringService.cpp @@ -91,7 +91,7 @@ namespace Services std::vector StringService::split(std::string_view str, char delimiter) { auto range = str | std::ranges::views::split(delimiter) | - std::ranges::views::transform([](auto&& subRange) -> std::string_view { + std::ranges::views::transform([] (auto&& subRange) -> std::string_view { return std::string_view( subRange.begin(), static_cast(std::ranges::distance(subRange)) diff --git a/src/Targets/TargetDescription/TargetDescriptionFile.cpp b/src/Targets/TargetDescription/TargetDescriptionFile.cpp index b37f963e..b0f89cf4 100644 --- a/src/Targets/TargetDescription/TargetDescriptionFile.cpp +++ b/src/Targets/TargetDescription/TargetDescriptionFile.cpp @@ -37,18 +37,17 @@ namespace Targets::TargetDescription } TargetFamily TargetDescriptionFile::getFamily() const { - static const auto familiesByName = std::map { - {"AVR8", TargetFamily::AVR_8}, - {"RISCV", TargetFamily::RISC_V}, - }; + const auto& family = this->deviceAttribute("family"); - const auto familyIt = familiesByName.find(this->deviceAttribute("family")); - - if (familyIt == familiesByName.end()) { - throw InvalidTargetDescriptionDataException("Failed to resolve target family - invalid family name"); + if (family == "AVR8") { + return TargetFamily::AVR_8; } - return familyIt->second; + if (family == "RISCV") { + return TargetFamily::RISC_V; + } + + throw InvalidTargetDescriptionDataException("Failed to resolve target family - invalid family name"); } std::optional> TargetDescriptionFile::tryGetPropertyGroup( @@ -278,7 +277,7 @@ namespace Targets::TargetDescription ); } - AddressSpace TargetDescriptionFile::addressSpaceFromXml(const QDomElement &xmlElement) { + AddressSpace TargetDescriptionFile::addressSpaceFromXml(const QDomElement& xmlElement) { static const auto endiannessByName = BiMap({ {"big", TargetMemoryEndianness::BIG}, {"little", TargetMemoryEndianness::LITTLE}, diff --git a/src/Targets/TargetDescription/TargetDescriptionFile.hpp b/src/Targets/TargetDescription/TargetDescriptionFile.hpp index c8295a18..ed293b1f 100644 --- a/src/Targets/TargetDescription/TargetDescriptionFile.hpp +++ b/src/Targets/TargetDescription/TargetDescriptionFile.hpp @@ -135,77 +135,14 @@ namespace Targets::TargetDescription static PropertyGroup propertyGroupFromXml(const QDomElement& xmlElement); static Property propertyFromXml(const QDomElement& xmlElement); - - /** - * Constructs an AddressSpace object from an XML element. - * - * @param xmlElement - * @return - */ static AddressSpace addressSpaceFromXml(const QDomElement& xmlElement); - - /** - * Constructs a MemorySegment object from an XML element. - * - * @param xmlElement - * @return - */ static MemorySegment memorySegmentFromXml(const QDomElement& xmlElement); - - /** - * Constructs a MemorySegmentSection from an XML element. - * - * @param xmlElement - * @return - */ static MemorySegmentSection memorySegmentSectionFromXml(const QDomElement& xmlElement); - - /** - * Constructs a PhysicalInterface from al XML element. - * - * @param xmlElement - * @return - */ static PhysicalInterface physicalInterfaceFromXml(const QDomElement& xmlElement); - - /** - * Constructs a Module object from an XML element. - * - * @param xmlElement - * @return - */ static Module moduleFromXml(const QDomElement& xmlElement); - - /** - * Constructs a RegisterGroup object from an XML element. - * - * @param xmlElement - * @return - */ static RegisterGroup registerGroupFromXml(const QDomElement& xmlElement); - - /** - * Constructs a RegisterGroupReference object from an XML element. - * - * @param xmlElement - * @return - */ static RegisterGroupReference registerGroupReferenceFromXml(const QDomElement& xmlElement); - - /** - * Constructs a Register object from an XML element. - * - * @param xmlElement - * @return - */ static Register registerFromXml(const QDomElement& xmlElement); - - /** - * Constructs a BitField object from an XML element. - * - * @param xmlElement - * @return - */ static BitField bitFieldFromXml(const QDomElement& xmlElement); /**