Bitset is a basic class for handling bit sequences More...
#include <Bitset.h>
Public Member Functions | |
void | clear () |
Clear the bits. | |
void | fill_zeros_left (const size_t bit_count) |
Fill the Bitset with non-meaningful zeros. | |
void | flip (size_t pos) |
Flip the selected bit. | |
std::deque< bool > & | GetBits () |
The Bitset as 'deque<bool>'. | |
std::string | hex () |
The Bitset as a hex string. | |
int | Length () |
The length of the Bitset. | |
std::ostream & | Output (std::ostream &os) const |
Output the bits to selected ostream. | |
bool | pop_back () |
Pop the back bit. | |
bool | pop_front () |
Pop the front bit. | |
void | push_back (const bool bit) |
Push back one bit. | |
void | push_back (const unsigned char b, const int bit_count=8) |
Push back bit_count bits from 'byte' b. | |
void | push_back (const unsigned short s, const int bit_count=16) |
Push back bit_count bits from 'short' s. | |
void | push_back (const unsigned long l, const int bit_count=32) |
Push back bit_count bits from 'long' l. | |
void | push_back (std::string s) |
Push back a string of characters. | |
void | push_back_meaningful (const unsigned long l) |
Push back meaningful bits from 'long' l. | |
unsigned char | uchar () |
The Bitset as 'unsigned char'. | |
unsigned long | ulong () |
The Bitset as 'unsigned long'. | |
Protected Attributes | |
std::deque< bool > | bits |
Bitset is a basic class for handling bit sequences
The bits are stored internally using deque<bool> (See http://osdir.com/ml/gis.geos.devel/2006-04/msg00142.html). The bitset is assumed to have most significant bits left i.e. the push_back() methods add to the least significant end of the bit sequence. The usage is clarified by the following example.
Bitset b; b.push_back(true); b.push_back(false); b.push_back(false); b.push_back(false); b.push_back(8, 4); b.push_back(0x88, 8); b.fill_zeros_left(32); b.Output(std::cout); // b contains now: 00000000 00000000 10001000 10001000
void alvar::Bitset::clear | ( | ) |
Clear the bits.
Definition at line 43 of file Bitset.cpp.
void alvar::Bitset::fill_zeros_left | ( | const size_t | bit_count | ) |
Fill the Bitset with non-meaningful zeros.
bit_count | Non-meaningful zeros are added until this given bit_count is reached. |
Definition at line 69 of file Bitset.cpp.
void alvar::Bitset::flip | ( | size_t | pos | ) |
Flip the selected bit.
pos | The bit in this given position is flipped. |
Definition at line 96 of file Bitset.cpp.
std::deque<bool>& alvar::Bitset::GetBits | ( | ) | [inline] |
string alvar::Bitset::hex | ( | ) |
The Bitset as a hex string.
Definition at line 100 of file Bitset.cpp.
int alvar::Bitset::Length | ( | ) |
The length of the Bitset.
Definition at line 31 of file Bitset.cpp.
ostream & alvar::Bitset::Output | ( | std::ostream & | os | ) | const |
Output the bits to selected ostream.
os | The output stream to be used for outputting e.g. std::cout |
Definition at line 34 of file Bitset.cpp.
bool alvar::Bitset::pop_back | ( | ) |
Pop the back bit.
Definition at line 89 of file Bitset.cpp.
bool alvar::Bitset::pop_front | ( | ) |
Pop the front bit.
Definition at line 83 of file Bitset.cpp.
void alvar::Bitset::push_back | ( | const bool | bit | ) |
Push back one bit.
bit | Boolean (true/false) to be pushed to the end of bit sequence. |
Definition at line 44 of file Bitset.cpp.
void alvar::Bitset::push_back | ( | const unsigned char | b, |
const int | bit_count = 8 |
||
) |
Push back bit_count bits from 'byte' b.
b | Unsigned character (8-bits) to be pushed to the end of bit sequence. |
bit_count | Number of bits to be pushed (default/max is 8 bits) |
Definition at line 45 of file Bitset.cpp.
void alvar::Bitset::push_back | ( | const unsigned short | s, |
const int | bit_count = 16 |
||
) |
Push back bit_count bits from 'short' s.
s | Unsigned short (16-bits) to be pushed to the end of bit sequence. |
bit_count | Number of bits to be pushed (default/max is 16 bits) |
Definition at line 48 of file Bitset.cpp.
void alvar::Bitset::push_back | ( | const unsigned long | l, |
const int | bit_count = 32 |
||
) |
Push back bit_count bits from 'long' l.
l | Unsigned long (32-bits) to be pushed to the end of bit sequence. |
bit_count | Number of bits to be pushed (default/max is 32 bits) |
Definition at line 51 of file Bitset.cpp.
void alvar::Bitset::push_back | ( | std::string | s | ) |
Push back a string of characters.
s | String of characters to be pushed to the end of bit sequence. |
void alvar::Bitset::push_back_meaningful | ( | const unsigned long | l | ) |
Push back meaningful bits from 'long' l.
l | The meaningful bits of the given unsigned long (32-bits) are pushed to the end of bit sequence. |
Definition at line 61 of file Bitset.cpp.
unsigned char alvar::Bitset::uchar | ( | ) |
The Bitset as 'unsigned char'.
Definition at line 131 of file Bitset.cpp.
unsigned long alvar::Bitset::ulong | ( | ) |
The Bitset as 'unsigned long'.
Definition at line 120 of file Bitset.cpp.
std::deque<bool> alvar::Bitset::bits [protected] |