]> sigrok.org Git - libsigrok.git/commitdiff
bindings: Add QuantityFlag::mask_from_flags() method.
authorMartin Ling <redacted>
Wed, 12 Nov 2014 11:08:22 +0000 (11:08 +0000)
committerUwe Hermann <redacted>
Thu, 13 Nov 2014 17:37:57 +0000 (18:37 +0100)
bindings/cxx/QuantityFlag_methods.cpp
bindings/cxx/QuantityFlag_methods.hpp

index 0a5379079ad62483d845ed120ea6bc67fc082b18..e822b80430b5885c7b06bb25f39b8371cc941524 100644 (file)
@@ -11,3 +11,11 @@ vector<const QuantityFlag *>
     }
     return result;
 }
+
+unsigned int QuantityFlag::mask_from_flags(vector<const QuantityFlag *> flags)
+{
+    unsigned int result = 0;
+    for (auto flag : flags)
+        result |= flag->id();
+    return result;
+}
index dfb3c1e8b3fef2e184d7453fa9b367896dc1b44c..d07c37a1b325d9a5bb6285d407de6a3391958e4c 100644 (file)
@@ -1,3 +1,7 @@
        /** Get flags corresponding to a bitmask. */
        static vector<const QuantityFlag *>
                flags_from_mask(unsigned int mask);
+
+       /** Get bitmask corresponding to a set of flags. */
+       static unsigned int mask_from_flags(
+               vector<const QuantityFlag *> flags);