Tidying
This commit is contained in:
@@ -27,25 +27,25 @@ namespace Targets::TargetDescription
|
||||
struct PropertyGroup
|
||||
{
|
||||
std::string key;
|
||||
std::map<std::string, Property, std::less<void>> propertiesMappedByKey;
|
||||
std::map<std::string, PropertyGroup, std::less<void>> subgroupsMappedByKey;
|
||||
std::map<std::string, Property, std::less<void>> propertiesByKey;
|
||||
std::map<std::string, PropertyGroup, std::less<void>> subgroupByKey;
|
||||
|
||||
PropertyGroup(
|
||||
const std::string& key,
|
||||
const std::map<std::string, Property, std::less<void>>& propertiesMappedByKey,
|
||||
const std::map<std::string, PropertyGroup, std::less<void>>& subgroupsMappedByKey
|
||||
const std::map<std::string, Property, std::less<void>>& propertiesByKey,
|
||||
const std::map<std::string, PropertyGroup, std::less<void>>& subgroupByKey
|
||||
)
|
||||
: key(key)
|
||||
, propertiesMappedByKey(propertiesMappedByKey)
|
||||
, subgroupsMappedByKey(subgroupsMappedByKey)
|
||||
, propertiesByKey(propertiesByKey)
|
||||
, subgroupByKey(subgroupByKey)
|
||||
{}
|
||||
|
||||
template <typename KeysType>
|
||||
requires
|
||||
std::ranges::sized_range<KeysType>
|
||||
std::optional<std::reference_wrapper<const PropertyGroup>> tryGetSubgroup(KeysType keys) const {
|
||||
auto firstSubgroupIt = this->subgroupsMappedByKey.find(*(keys.begin()));
|
||||
if (firstSubgroupIt == this->subgroupsMappedByKey.end()) {
|
||||
auto firstSubgroupIt = this->subgroupByKey.find(*(keys.begin()));
|
||||
if (firstSubgroupIt == this->subgroupByKey.end()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
@@ -78,9 +78,9 @@ namespace Targets::TargetDescription
|
||||
}
|
||||
|
||||
std::optional<std::reference_wrapper<const Property>> tryGetProperty(std::string_view key) const {
|
||||
const auto propertyIt = this->propertiesMappedByKey.find(key);
|
||||
const auto propertyIt = this->propertiesByKey.find(key);
|
||||
|
||||
if (propertyIt == this->propertiesMappedByKey.end()) {
|
||||
if (propertyIt == this->propertiesByKey.end()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,10 +53,10 @@ namespace Targets::TargetDescription
|
||||
std::optional<std::reference_wrapper<const PropertyGroup>> TargetDescriptionFile::tryGetPropertyGroup(
|
||||
std::string_view keyStr
|
||||
) const {
|
||||
auto keys = StringService::split(keyStr, '.');
|
||||
const auto keys = StringService::split(keyStr, '.');
|
||||
|
||||
const auto firstSubgroupIt = this->propertyGroupsMappedByKey.find(*keys.begin());
|
||||
return firstSubgroupIt != this->propertyGroupsMappedByKey.end()
|
||||
const auto firstSubgroupIt = this->propertyGroupsByKey.find(*keys.begin());
|
||||
return firstSubgroupIt != this->propertyGroupsByKey.end()
|
||||
? keys.size() > 1
|
||||
? firstSubgroupIt->second.tryGetSubgroup(keys | std::ranges::views::drop(1))
|
||||
: std::optional(std::cref(firstSubgroupIt->second))
|
||||
@@ -136,7 +136,7 @@ namespace Targets::TargetDescription
|
||||
element = element.nextSiblingElement("property-group")
|
||||
) {
|
||||
auto propertyGroup = TargetDescriptionFile::propertyGroupFromXml(element);
|
||||
this->propertyGroupsMappedByKey.insert(
|
||||
this->propertyGroupsByKey.insert(
|
||||
std::pair(propertyGroup.key, std::move(propertyGroup))
|
||||
);
|
||||
}
|
||||
@@ -190,7 +190,7 @@ namespace Targets::TargetDescription
|
||||
element = element.nextSiblingElement("property")
|
||||
) {
|
||||
auto property = TargetDescriptionFile::propertyFromXml(element);
|
||||
output.propertiesMappedByKey.insert(std::pair(property.key, std::move(property)));
|
||||
output.propertiesByKey.insert(std::pair(property.key, std::move(property)));
|
||||
}
|
||||
|
||||
for (
|
||||
@@ -199,7 +199,7 @@ namespace Targets::TargetDescription
|
||||
element = element.nextSiblingElement("property-group")
|
||||
) {
|
||||
auto subgroup = TargetDescriptionFile::propertyGroupFromXml(element);
|
||||
output.subgroupsMappedByKey.insert(std::pair(subgroup.key, std::move(subgroup)));
|
||||
output.subgroupByKey.insert(std::pair(subgroup.key, std::move(subgroup)));
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "PropertyGroup.hpp"
|
||||
#include "AddressSpace.hpp"
|
||||
#include "MemorySegment.hpp"
|
||||
#include "PropertyGroup.hpp"
|
||||
#include "MemorySegmentSection.hpp"
|
||||
#include "RegisterGroup.hpp"
|
||||
#include "Module.hpp"
|
||||
@@ -102,7 +102,7 @@ namespace Targets::TargetDescription
|
||||
protected:
|
||||
std::map<std::string, std::string> deviceAttributesByName;
|
||||
std::map<std::string, AddressSpace, std::less<void>> addressSpacesByKey;
|
||||
std::map<std::string, PropertyGroup, std::less<void>> propertyGroupsMappedByKey;
|
||||
std::map<std::string, PropertyGroup, std::less<void>> propertyGroupsByKey;
|
||||
std::map<std::string, Module> modulesMappedByName;
|
||||
std::map<std::string, Module> peripheralModulesMappedByName;
|
||||
std::map<std::string, std::vector<RegisterGroup>> peripheralRegisterGroupsMappedByModuleRegisterGroupName;
|
||||
|
||||
Reference in New Issue
Block a user