Public Member Functions | Protected Attributes
alvar::Bitset Class Reference

Bitset is a basic class for handling bit sequences More...

#include <Bitset.h>

Inheritance diagram for alvar::Bitset:
Inheritance graph
[legend]

List of all members.

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

Detailed Description

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.

Usage

 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

Definition at line 62 of file Bitset.h.


Member Function Documentation

void alvar::Bitset::clear ( void  )

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.

Parameters:
bit_countNon-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.

Parameters:
posThe bit in this given position is flipped.

Definition at line 96 of file Bitset.cpp.

std::deque<bool>& alvar::Bitset::GetBits ( ) [inline]

The Bitset as 'deque<bool>'.

Definition at line 121 of file Bitset.h.

string alvar::Bitset::hex ( )

The Bitset as a hex string.

Definition at line 100 of file Bitset.cpp.

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.

Parameters:
osThe output stream to be used for outputting e.g. std::cout

Definition at line 34 of file Bitset.cpp.

Pop the back bit.

Definition at line 89 of file Bitset.cpp.

Pop the front bit.

Definition at line 83 of file Bitset.cpp.

void alvar::Bitset::push_back ( const bool  bit)

Push back one bit.

Parameters:
bitBoolean (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.

Parameters:
bUnsigned character (8-bits) to be pushed to the end of bit sequence.
bit_countNumber 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.

Parameters:
sUnsigned short (16-bits) to be pushed to the end of bit sequence.
bit_countNumber 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.

Parameters:
lUnsigned long (32-bits) to be pushed to the end of bit sequence.
bit_countNumber 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.

Parameters:
sString 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.

Parameters:
lThe 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.


Member Data Documentation

std::deque<bool> alvar::Bitset::bits [protected]

Definition at line 64 of file Bitset.h.


The documentation for this class was generated from the following files:


ar_track_alvar
Author(s): Scott Niekum
autogenerated on Sun Oct 5 2014 22:16:27