1 /***************************************************************************
3 * Copyright (C) 2006 David Brodsky *
5 * This program is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU General Public License as *
7 * published by the Free Software Foundation and appearing *
8 * in the file LICENSE.GPL included in the packaging of this file. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
13 * General Public License for more details. *
15 ***************************************************************************/
17 #ifndef _core_bitfield_h
18 #define _core_bitfield_h
22 #include <tairon/core/string.h>
30 /** \brief BitField is an array of bits.
35 /** Constructs an empty BitField object of specific length.
37 * \param len Length of the bitfield (i.e. number of bits).
41 /** Constructs a BitField object from a memory.
43 BitField(const char *mem
, size_t len
);
45 /** Destroys the object.
49 /** Returns bit value at specific position.
51 * \param index Position of the bit.
53 bool getBit(size_t index
);
55 /** Returns pointer to the internal data structure.
57 const char *getData() {
61 /** Returns length of this bitfield.
67 /** Returns number of bits that are not set.
69 size_t getRemaining() {
73 /** Sets a bit at specific position.
75 * \param index Position of the bit.
76 * \param value Value of the new bit.
78 void setBit(size_t index
, bool value
= true);
85 /** Length of the bitfield.
89 /** Number of bits that are still unset.
96 }; // namespace Tairent
100 // vim: ai sw=4 ts=4 noet fdm=marker