pmt: add [] operators to Map_t and builder
This commit is contained in:
@@ -84,6 +84,9 @@ public:
|
||||
bool operator==(const basic_partition_map &other) const;
|
||||
bool operator!=(const basic_partition_map &other) const;
|
||||
|
||||
Info operator[](int index) const;
|
||||
BasicInf operator[](const std::string_view& name) const;
|
||||
|
||||
operator std::vector<Info>() const;
|
||||
operator int() const;
|
||||
|
||||
@@ -350,6 +353,16 @@ public:
|
||||
*/
|
||||
const Map_t &operator*() const;
|
||||
|
||||
/**
|
||||
* Get Info structure with given index
|
||||
*/
|
||||
Info operator[](int index) const;
|
||||
|
||||
/**
|
||||
* Get BasicInfo structure with given index
|
||||
*/
|
||||
BasicInf operator[](const std::string_view& name) const;
|
||||
|
||||
/**
|
||||
* Get map contents as vector (PartitionManager::Info type).
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 {};
|
||||
|
||||
Reference in New Issue
Block a user