From: Martin Ling Date: Wed, 12 Nov 2014 11:08:22 +0000 (+0000) Subject: bindings: Add QuantityFlag::mask_from_flags() method. X-Git-Tag: libsigrok-0.4.0~784 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=b2db9f3bbeaa26bb63f8adfabf47ff7e068b1952;p=libsigrok.git bindings: Add QuantityFlag::mask_from_flags() method. --- diff --git a/bindings/cxx/QuantityFlag_methods.cpp b/bindings/cxx/QuantityFlag_methods.cpp index 0a537907..e822b804 100644 --- a/bindings/cxx/QuantityFlag_methods.cpp +++ b/bindings/cxx/QuantityFlag_methods.cpp @@ -11,3 +11,11 @@ vector } return result; } + +unsigned int QuantityFlag::mask_from_flags(vector flags) +{ + unsigned int result = 0; + for (auto flag : flags) + result |= flag->id(); + return result; +} diff --git a/bindings/cxx/QuantityFlag_methods.hpp b/bindings/cxx/QuantityFlag_methods.hpp index dfb3c1e8..d07c37a1 100644 --- a/bindings/cxx/QuantityFlag_methods.hpp +++ b/bindings/cxx/QuantityFlag_methods.hpp @@ -1,3 +1,7 @@ /** Get flags corresponding to a bitmask. */ static vector flags_from_mask(unsigned int mask); + + /** Get bitmask corresponding to a set of flags. */ + static unsigned int mask_from_flags( + vector flags);