diff --git a/ChangeLog.md b/ChangeLog.md index 938757cd1..186e1be04 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -197,6 +197,8 @@ Nazara Engine: - StackArray and StackVector are now movable - Fixed RigidBody2D::Copy not copying kinematic/dynamic/static status - Fixed out-of-bounds access in LuaInstance::LoadLibraries +- Add Flags::Clear(Flags) helper method, to clear one or more flags. +- Add Flags::Clear() helper method, to reset flags Nazara Development Kit: - Added ImageWidget (#139) diff --git a/include/Nazara/Core/Flags.hpp b/include/Nazara/Core/Flags.hpp index 84c201775..c2e2dc8db 100644 --- a/include/Nazara/Core/Flags.hpp +++ b/include/Nazara/Core/Flags.hpp @@ -48,6 +48,9 @@ namespace Nz constexpr Flags(BitField value = 0); constexpr Flags(E enumVal); + void Clear(); + void Clear(const Flags& flags); + constexpr bool Test(const Flags& flags) const; explicit constexpr operator bool() const; diff --git a/include/Nazara/Core/Flags.inl b/include/Nazara/Core/Flags.inl index 2b57a59a8..b3db17e47 100644 --- a/include/Nazara/Core/Flags.inl +++ b/include/Nazara/Core/Flags.inl @@ -39,9 +39,35 @@ namespace Nz { } + /*! + * \brief Clear all flags + * + * \see Test + */ + template + void Flags::Clear() + { + m_value = 0; + } + + /*! + * \brief Clear some flags + * + * \param flags Flags to be cleared + * + * \see Test + */ + template + void Flags::Clear(const Flags& flags) + { + m_value &= ~flags; + } + /*! * \brief Tests if all flags from a Flags object are enabled * \return True if all tested flags are enabled. + * + * \see Clear */ template constexpr bool Flags::Test(const Flags& flags) const