pmt: add [] operators to Map_t and builder

This commit is contained in:
2025-09-07 10:53:59 +03:00
parent ab35740fb6
commit 1984825dec
3 changed files with 35 additions and 0 deletions

View File

@@ -416,6 +416,14 @@ const Map_t &basic_partition_map_builder::operator*() const {
return _current_map;
}
Info basic_partition_map_builder::operator[](const int index) const {
return _current_map[index];
}
BasicInf basic_partition_map_builder::operator[](const std::string_view& name) const {
return _current_map[name];
}
basic_partition_map_builder::operator std::vector<Info>() const {
return _current_map;
}

View File

@@ -229,6 +229,20 @@ bool basic_partition_map::operator!=(const basic_partition_map &other) const {
return !(*this == other);
}
Info basic_partition_map::operator[](const int index) const {
if (_count == 0 || index >= _count) return {};
return _data[index];
}
BasicInf basic_partition_map::operator[](const std::string_view& name) const {
if (_count == 0) return {};
if (const int i = _index_of(name); name == _data[i].name)
return {_data[i].props.size, _data[i].props.isLogical};
return {};
}
basic_partition_map::operator std::vector<Info>() const {
std::vector<Info> v;
if (_count == 0) return {};