00001 /* bitXmask.h 00002 */ 00003 #ifndef _BITXMASK_H 00004 #define _BITXMASK_H 00005 00006 #include "osl/position.h" 00007 #include "osl/misc/carray.h" 00008 #include <iosfwd> 00009 00010 namespace osl 00011 { 00012 namespace container 00013 { 00017 class BitXmask 00018 { 00019 int mask; 00020 public: 00021 BitXmask() : mask(0) {} 00022 void clearAll() { mask = 0; } 00023 void set(int x) { mask |= (1 << x); } 00024 void clear(int x) { mask &= ~(1 << x); } 00025 00026 void set(Position position) { set(position.x()); } 00027 void clear(Position position) { clear(position.x()); } 00028 00029 bool isSet(int x) const { return mask & (1<<x); } 00030 00031 int intValue() const { return mask; } 00032 }; 00033 00034 inline bool operator==(BitXmask l, BitXmask r) 00035 { 00036 return l.intValue() == r.intValue(); 00037 } 00038 inline bool operator!=(BitXmask l, BitXmask r) 00039 { 00040 return ! (l == r); 00041 } 00042 inline bool operator<(BitXmask l, BitXmask r) 00043 { 00044 return l < r; 00045 } 00046 00047 std::ostream& operator<<(std::ostream&,const BitXmask); 00048 } // namespace container 00049 using container::BitXmask; 00050 } // namespace osl 00051 00052 #endif /* _BITXMASK_H */ 00053 // ;;; Local Variables: 00054 // ;;; mode:c++ 00055 // ;;; c-basic-offset:2 00056 // ;;; End: