00001
00002 #ifndef UTIL_BitSet32_H
00003 #define UTIL_BitSet32_H 1
00004
00005
00006 #include <bitset>
00007 #include <stdarg.h>
00008
00009
00010 namespace UTIL {
00011
00012
00031 class BitSet32 : public std::bitset<32>{
00032
00033 public:
00035 BitSet32(int val ) : std::bitset<32>( val ) {}
00036
00038 BitSet32& operator=(int val){
00039 std::bitset<32>::operator=( val ) ;
00040 return *this ;
00041 }
00042
00044 operator int() { return (int) to_ulong() ; }
00045 } ;
00046
00047
00049 inline BitSet32 make_bitset32( int bit0 ) {
00050 return BitSet32( 1 << bit0 ) ;
00051 }
00053 inline BitSet32 make_bitset32( int bit0, int bit1) {
00054 return BitSet32( 1 << bit0 |
00055 1 << bit1 ) ;
00056 }
00058 inline BitSet32 make_bitset32( int bit0, int bit1, int bit2) {
00059 return BitSet32( 1 << bit0 |
00060 1 << bit1 |
00061 1 << bit2 ) ;
00062 }
00064 inline BitSet32 make_bitset32( int bit0, int bit1, int bit2, int bit3) {
00065 return BitSet32( 1 << bit0 |
00066 1 << bit1 |
00067 1 << bit2 |
00068 1 << bit3 ) ;
00069 }
00071 inline BitSet32 make_bitset32( int bit0, int bit1, int bit2, int bit3, int bit4) {
00072 return BitSet32( 1 << bit0 |
00073 1 << bit1 |
00074 1 << bit2 |
00075 1 << bit3 |
00076 1 << bit4 ) ;
00077 }
00078
00082 inline int set_bit( int flag , int bit ){
00083 BitSet32 bs( flag ) ;
00084 bs.set( bit ) ;
00085 return (int) bs ;
00086 }
00087
00091 inline int unset_bit( int flag , int bit ){
00092 BitSet32 bs( flag ) ;
00093 bs.set( bit, 0 ) ;
00094 return (int) bs ;
00095 }
00096
00097
00098
00099 }
00100 #endif