Core/Flags: Add Clear methods

This commit is contained in:
Lynix 2019-11-09 13:37:40 +01:00
parent c668d02747
commit a4bff0968b
3 changed files with 31 additions and 0 deletions

View File

@ -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<E>::Clear(Flags) helper method, to clear one or more flags.
- Add Flags<E>::Clear() helper method, to reset flags
Nazara Development Kit:
- Added ImageWidget (#139)

View File

@ -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;

View File

@ -39,9 +39,35 @@ namespace Nz
{
}
/*!
* \brief Clear all flags
*
* \see Test
*/
template<typename E>
void Flags<E>::Clear()
{
m_value = 0;
}
/*!
* \brief Clear some flags
*
* \param flags Flags to be cleared
*
* \see Test
*/
template<typename E>
void Flags<E>::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<typename E>
constexpr bool Flags<E>::Test(const Flags& flags) const