diff -r 62356e3ecb84 -r 70907579a3b6 BitArray.h --- a/BitArray.h Tue Aug 26 19:24:57 2014 +0200 +++ b/BitArray.h Fri Aug 29 22:32:13 2014 +0200 @@ -71,26 +71,39 @@ /*************************************************************************** * TYPE DEFINITIONS ***************************************************************************/ +typedef unsigned char (*TBitInChar)(const unsigned int aBit); +template class BitArray; + +//Bits are indexed: 76543210 +inline unsigned char HighBitHighIndex(const unsigned int aBit) { return (1 << (((aBit) % CHAR_BIT)));}; + +//Bits are indexed: 01234567 +inline unsigned char HighBitLowIndex(const unsigned int aBit) { return (1 << (CHAR_BIT - 1 - ((aBit) % CHAR_BIT)));}; + + + /** */ +template class BitArrayIndex { public: - BitArrayIndex(BitArray *array, const unsigned int index); + BitArrayIndex(BitArray *array, const unsigned int index); /* assignment */ void operator=(const bool src); private: - BitArray *m_BitArray; /* array index applies to */ + BitArray *m_BitArray; /* array index applies to */ unsigned int m_Index; /* index of bit in array */ }; /** TODO: Derive a Bit Frame class from this one for X Y access to pixels. */ +template class BitArray { public: @@ -111,42 +124,42 @@ void SetBitValue(const unsigned int bit, bool aValue); void ClearBit(const unsigned int bit); - BitArrayIndex operator()(const unsigned int bit); + BitArrayIndex operator()(const unsigned int bit); /* boolean operator */ bool operator[](const unsigned int bit) const; - bool operator==(const BitArray &other) const; - bool operator!=(const BitArray &other) const; - bool operator<(const BitArray &other) const; - bool operator<=(const BitArray &other) const; - bool operator>(const BitArray &other) const; - bool operator>=(const BitArray &other) const; + bool operator==(const BitArray &other) const; + bool operator!=(const BitArray &other) const; + bool operator<(const BitArray &other) const; + bool operator<=(const BitArray &other) const; + bool operator>(const BitArray &other) const; + bool operator>=(const BitArray &other) const; /* bitwise operators */ - BitArray operator&(const BitArray &other) const; - BitArray operator^(const BitArray &other) const; - BitArray operator|(const BitArray &other) const; - BitArray operator~(void) const; + BitArray operator&(const BitArray &other) const; + BitArray operator^(const BitArray &other) const; + BitArray operator|(const BitArray &other) const; + BitArray operator~(void) const; - BitArray operator<<(const unsigned int count) const; - BitArray operator>>(const unsigned int count) const; + BitArray operator<<(const unsigned int count) const; + BitArray operator>>(const unsigned int count) const; /* increment/decrement */ - BitArray& operator++(void); /* prefix */ - BitArray& operator++(int dummy); /* postfix */ - BitArray& operator--(void); /* prefix */ - BitArray& operator--(int dummy); /* postfix */ + BitArray& operator++(void); /* prefix */ + BitArray& operator++(int dummy); /* postfix */ + BitArray& operator--(void); /* prefix */ + BitArray& operator--(int dummy); /* postfix */ /* assignments */ - BitArray& operator=(const BitArray &src); + BitArray& operator=(const BitArray &src); - BitArray& operator&=(const BitArray &src); - BitArray& operator^=(const BitArray &src); - BitArray& operator|=(const BitArray &src); - BitArray& Not(void); /* negate (~=) */ + BitArray& operator&=(const BitArray &src); + BitArray& operator^=(const BitArray &src); + BitArray& operator|=(const BitArray &src); + BitArray& Not(void); /* negate (~=) */ - BitArray& operator<<=(unsigned const int shifts); - BitArray& operator>>=(unsigned const int shifts); + BitArray& operator<<=(unsigned const int shifts); + BitArray& operator>>=(unsigned const int shifts); unsigned char* Ptr(){return m_Array;} const unsigned char* Ptr() const{return m_Array;} @@ -158,4 +171,7 @@ bool m_OwnsBuffer; }; +typedef BitArray BitArrayHigh; +typedef BitArray BitArrayLow; + #endif /* ndef BIT_ARRAY_H */