2019-01-30 11:27:23 +00:00
|
|
|
std::vector<const QuantityFlag *>
|
2014-07-17 17:39:49 +00:00
|
|
|
QuantityFlag::flags_from_mask(unsigned int mask)
|
|
|
|
{
|
2019-01-30 11:27:23 +00:00
|
|
|
auto result = std::vector<const QuantityFlag *>();
|
2014-07-17 17:39:49 +00:00
|
|
|
while (mask)
|
|
|
|
{
|
|
|
|
unsigned int new_mask = mask & (mask - 1);
|
|
|
|
result.push_back(QuantityFlag::get(
|
|
|
|
static_cast<enum sr_mqflag>(mask ^ new_mask)));
|
|
|
|
mask = new_mask;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2014-11-12 11:08:22 +00:00
|
|
|
|
2019-01-30 11:27:23 +00:00
|
|
|
unsigned int QuantityFlag::mask_from_flags(std::vector<const QuantityFlag *> flags)
|
2014-11-12 11:08:22 +00:00
|
|
|
{
|
|
|
|
unsigned int result = 0;
|
|
|
|
for (auto flag : flags)
|
|
|
|
result |= flag->id();
|
|
|
|
return result;
|
|
|
|
}
|