BitString Class Reference
a string of bits
More...
#include <BitString.h>
List of all members.
Detailed Description
This class provides a way to conveniently store and manipulate a string of bits. Various objects can be appended to a
BitString.
For data storage a vector of BYTEs is used with little endian bit encoding, i.e. the first bit is the least significant bit of the first byte and so on.
Constructor & Destructor Documentation
BitString::BitString |
( |
EmbValue |
arity = 2 |
) |
|
BitString::BitString |
( |
const BitString & |
bs |
) |
|
BitString::BitString |
( |
const unsigned long |
l |
) |
|
construct a BitString containing l bits with value zero
BitString::BitString |
( |
const std::vector< BYTE > & |
d |
) |
|
construct a BitString containing the data in d
BitString::BitString |
( |
const std::string & |
d |
) |
|
construct a BitString containing the characters in d as 8 bit unsigned chars
Member Function Documentation
void BitString::_append |
( |
BIT |
v |
) |
[private] |
append the vector v byte-wise to this BitString
BitString & BitString::append |
( |
const std::string & |
v |
) |
|
append n lower order bits of v to this BitString
- Parameters:
-
| v | the value to be appended |
| n | the number of bits to be appended |
append n lower order bits of v to this BitString
- Parameters:
-
| v | the value to be appended |
| n | the number of bits to be appended |
BitString & BitString::append |
( |
const BYTE |
v, |
|
|
const unsigned short |
n = 8 | |
|
) |
| | |
append n lower order bits of v to this BitString
- Parameters:
-
| v | the value to be appended |
| n | the number of bits to be appended |
void BitString::appendNAry |
( |
BYTE |
v |
) |
|
append an n-ary digit to this BitString
- Parameters:
-
| v | the n-ary value to be appended |
delete the contents of this Bitstring
void BitString::clearUnused |
( |
void |
|
) |
[private] |
clear unused part of last byte (_append depends on this)
BitString BitString::cutBits |
( |
const unsigned long |
s, |
|
|
const unsigned long |
l | |
|
) |
| | |
cut some bits out of this BitString
- Parameters:
-
| s | the index of the first bit to be removed from this BitString |
| l | the total number of bits to be removed |
- Returns:
- the BitString containing of the bits [s...s+(l-1)] of this BitString
After calling cutBits, this
BitString consists of the bits 0,...,s-1,s+l,... .
EmbValue BitString::getArity |
( |
void |
|
) |
const [inline] |
BitString BitString::getBits |
( |
const unsigned long |
s, |
|
|
const unsigned long |
l | |
|
) |
| | const |
get a BitString that is a part of this BitString
- Parameters:
-
| s | the index of the first bit to be copied from this BitString |
| l | the total number of bits to be used for the return value |
- Returns:
- the BitString containing of the bits [s...s+(l-1)] of this BitString
const std::vector< BYTE > & BitString::getBytes |
( |
void |
|
) |
const |
get the contents of this BitString as vector of bytes
- Returns:
- the contents of this BitString as vector of bytes
getLength() % 8 must be 0 to call this function
UWORD32 BitString::getLength |
( |
void |
|
) |
const [inline] |
BYTE BitString::getNAry |
( |
unsigned long |
p |
) |
const |
get an n-ary digit from this BitString
- Parameters:
-
| p | the position (in the n-ary representation of this BitString) |
- Returns:
- the p-th n-ary digit
UWORD32 BitString::getNAryLength |
( |
void |
|
) |
const [inline] |
get the number of EmbValues in this BitString (using this BitString's arity)
UWORD32 BitString::getValue |
( |
const unsigned long |
s, |
|
|
const unsigned short |
l | |
|
) |
| | const |
return a value composed from bits in this BitString
- Parameters:
-
| s | the index of the first bit to be used for the return value |
| l | the total number of bits to be used for the return value (must be <= 32) |
- Returns:
- the value (*this)[s],...,(*this)[s+l-1]
bool BitString::operator!= |
( |
const BitString & |
v |
) |
const |
compare this BitString with the BitString v
- Returns:
- true iff the lengths are not equal or there exists an index with different values
bool BitString::operator== |
( |
const BitString & |
v |
) |
const |
compare this BitString with the BitString v
- Returns:
- true iff the lengths are equal and for every valid index the value is equal
BIT BitString::operator[] |
( |
const unsigned long |
i |
) |
const |
get the value of the i-th bit
xor v with this BitString, saving the result in this Bitstring. The result has the same length as this BitString.
BitString & BitString::pad |
( |
const unsigned long |
mult, |
|
|
const BIT |
v | |
|
) |
| | |
pad this BitString with the value in v
- Parameters:
-
| mult | this BitString is padded until size is a multiple of mult (given in bits) |
| v | the value this BitString should be padded with |
BitString & BitString::padRandom |
( |
const unsigned long |
mult |
) |
|
pad this BitString with random data
- Parameters:
-
| mult | this BitString is padded until size is a multiple of mult (given in bits) |
void BitString::print |
( |
unsigned short |
spc = 0 |
) |
const |
void BitString::setArity |
( |
EmbValue |
arity |
) |
|
set the p-th bit to v
- Parameters:
-
BitString & BitString::truncate |
( |
const unsigned long |
s, |
|
|
const unsigned long |
e | |
|
) |
| | |
truncate this BitString
- Parameters:
-
- Returns:
- this BitString modified to contain only (*this)[s]...(*this)[e - 1]
Member Data Documentation
The documentation for this class was generated from the following files: