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