Working on GP1212A02 support.
1 /***************************************************************************
2 * Arrays of Arbitrary Bit Length
5 * Purpose : Header file for class supporting the creation and
6 * manipulation of arbitrary length arrays of bits.
7 * Author : Michael Dipperstein
10 ****************************************************************************
13 * $Id: bitarray.h,v 1.5 2010/02/04 03:31:43 michael Exp $
14 * $Log: bitarray.h,v $
15 * Revision 1.5 2010/02/04 03:31:43 michael
16 * Replaced vector<unsigned char> with an array of unsigned char.
18 * Made updates for GCC 4.4.
20 * Revision 1.4 2007/08/06 05:23:12 michael
21 * Updated for LGPL Version 3.
23 * All methods that don't modify object have been made
24 * const to increase functionality of const bit_array_c.
26 * All assignment operators return a reference to the object being assigned a value so that operator chaining will work.
28 * Added >> and << operators.
30 * Revision 1.3 2006/04/30 23:34:07 michael
31 * Improved performance by incorporating Benjamin Schindler's
32 * <bschindler@student.ethz.ch> changes to pass arguments as a reference.
34 * Revision 1.2 2004/08/05 22:17:04 michael
35 * Add overloads for bitwise operators returning values.
36 * Add a more natural looking way to set bit values.
38 * Revision 1.1.1.1 2004/08/04 13:28:20 michael
41 ****************************************************************************
43 * Bitarray: An ANSI C++ class for manipulating arbitrary length bit arrays
44 * Copyright (C) 2004, 2006-2007, 2010 by
45 * Michael Dipperstein (mdipper@alumni.engr.ucsb.edu)
47 * This file is part of the bit array library.
49 * The bit array library is free software; you can redistribute it and/or
50 * modify it under the terms of the GNU Lesser General Public License as
51 * published by the Free Software Foundation; either version 3 of the
52 * License, or (at your option) any later version.
54 * The bit array library is distributed in the hope that it will be useful,
55 * but WITHOUT ANY WARRANTY; without even the implied warranty of
56 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
57 * General Public License for more details.
59 * You should have received a copy of the GNU Lesser General Public License
60 * along with this program. If not, see <http://www.gnu.org/licenses/>.
62 ***************************************************************************/
66 /***************************************************************************
68 ***************************************************************************/
71 /***************************************************************************
73 ***************************************************************************/
81 BitArrayIndex(BitArray *array, const unsigned int index);
84 void operator=(const bool src);
87 BitArray *m_BitArray; /* array index applies to */
88 unsigned int m_Index; /* index of bit in array */
92 TODO: Derive a Bit Frame class from this one for X Y access to pixels.
97 BitArray(const int numBits);
98 BitArray(unsigned char *array, const int numBits, bool aOwnsBuffer);
100 virtual ~BitArray(void);
102 void Dump(std::ostream &outStream);
104 const unsigned int SizeInBits() { return m_NumBits; }
105 const unsigned int SizeInBytes() { return m_SizeInBytes; }
107 /* set/clear functions */
110 void SetBit(const unsigned int bit);
111 void SetBitValue(const unsigned int bit, bool aValue);
112 void ClearBit(const unsigned int bit);
114 BitArrayIndex operator()(const unsigned int bit);
116 /* boolean operator */
117 bool operator[](const unsigned int bit) const;
118 bool operator==(const BitArray &other) const;
119 bool operator!=(const BitArray &other) const;
120 bool operator<(const BitArray &other) const;
121 bool operator<=(const BitArray &other) const;
122 bool operator>(const BitArray &other) const;
123 bool operator>=(const BitArray &other) const;
125 /* bitwise operators */
126 BitArray operator&(const BitArray &other) const;
127 BitArray operator^(const BitArray &other) const;
128 BitArray operator|(const BitArray &other) const;
129 BitArray operator~(void) const;
131 BitArray operator<<(const unsigned int count) const;
132 BitArray operator>>(const unsigned int count) const;
134 /* increment/decrement */
135 BitArray& operator++(void); /* prefix */
136 BitArray& operator++(int dummy); /* postfix */
137 BitArray& operator--(void); /* prefix */
138 BitArray& operator--(int dummy); /* postfix */
141 BitArray& operator=(const BitArray &src);
143 BitArray& operator&=(const BitArray &src);
144 BitArray& operator^=(const BitArray &src);
145 BitArray& operator|=(const BitArray &src);
146 BitArray& Not(void); /* negate (~=) */
148 BitArray& operator<<=(unsigned const int shifts);
149 BitArray& operator>>=(unsigned const int shifts);
151 unsigned char* Ptr(){return m_Array;}
152 const unsigned char* Ptr() const{return m_Array;}
155 unsigned int m_NumBits; /* number of bits in the array */
156 unsigned int m_SizeInBytes;
157 unsigned char *m_Array; /* vector of characters */
161 #endif /* ndef BIT_ARRAY_H */