/* ----------------------------------------------------------------------------- GSFramework Copyright 2001-2013 Emmanuel Julien. All Rights Reserved. ----------------------------------------------------------------------------- */ #ifndef __NBITFIELD__ #define __NBITFIELD__ #include "ntypes.h" namespace GS { class BitField { uint v; public: BitField &operator &= (uint b) { v &= b; return *this; } BitField &operator |= (uint b) { v |= b; return *this; } BitField &operator = (uint b) { v = b; return *this; } BitField &operator &= (const BitField &b) { v &= b.v; return *this; } BitField &operator |= (const BitField &b) { v |= b.v; return *this; } BitField &operator = (const BitField &b) { v = b.v; return *this; } bool operator == (const BitField &b) const { return v == b.v; } bool operator != (const BitField &b) const { return v != b.v; } inline uint Get() const { return v; } inline uint Set(uint b) { v |= b; return v; } inline uint Remove(uint b) { v &= ~b; return v; } inline uint Raise(uint b, bool raise = true) { return raise ? Set(b) : Remove(b); } inline bool IsSet(uint b) const { return asbool(v & b); } BitField() : v(0) {} }; } #endif // __NBITFIELD__