From b2db9f3bbeaa26bb63f8adfabf47ff7e068b1952 Mon Sep 17 00:00:00 2001 From: Martin Ling Date: Wed, 12 Nov 2014 11:08:22 +0000 Subject: [PATCH] bindings: Add QuantityFlag::mask_from_flags() method. --- bindings/cxx/QuantityFlag_methods.cpp | 8 ++++++++ bindings/cxx/QuantityFlag_methods.hpp | 4 ++++ 2 files changed, 12 insertions(+) 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);