Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __CS_FLAGS_H__
00020 #define __CS_FLAGS_H__
00021
00026 #include "csextern.h"
00027
00031 class csFlags
00032 {
00033 private:
00035 uint32 flags;
00036
00037 public:
00039 csFlags (uint32 value = 0) : flags (value) { }
00040
00047 void SetAll (uint32 value)
00048 { flags = value; }
00049
00056 void Set (uint32 mask)
00057 { flags = (flags & ~mask) | mask; }
00058
00065 void Reset (uint32 mask)
00066 { flags = (flags & ~mask); }
00067
00073 void Set (uint32 mask, uint32 value)
00074 { flags = (flags & ~mask) | (value & mask); }
00075
00081 void SetBool (uint32 mask, bool value)
00082 {
00083 if (value)
00084 flags |= mask;
00085 else
00086 flags &= ~mask;
00087 }
00088
00090 uint32 Get () const
00091 { return flags; }
00092
00094 bool Check (uint32 mask) const
00095 { return (flags & mask) != 0; }
00096
00098 bool CheckAll (uint32 mask) const
00099 { return (flags & mask) == mask; }
00100
00101
00103 bool operator== (const csFlags& other) const
00104 { return flags == other.flags; }
00106 bool operator!= (const csFlags& other) const
00107 { return flags != other.flags; }
00109 csFlags operator& (const csFlags& other) const
00110 { return csFlags (flags & other.flags); }
00111
00112 csFlags operator~() const
00113 { return csFlags (~flags); }
00114 };
00115
00116 #endif // __CS_FLAGS_H__
00117