libsigrok/bindings/cxx/QuantityFlag_methods.cpp

22 lines
569 B
C++
Raw Normal View History

std::vector<const QuantityFlag *>
2014-07-17 17:39:49 +00:00
QuantityFlag::flags_from_mask(unsigned int mask)
{
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;
}
unsigned int QuantityFlag::mask_from_flags(std::vector<const QuantityFlag *> flags)
{
unsigned int result = 0;
for (auto flag : flags)
result |= flag->id();
return result;
}