bitstring(3)

NAME

BitString - a string of bits

SYNOPSIS

#include <BitString.h>
Public Member Functions
BitString (EmbValue arity=2)
BitString (const BitString &bs)
BitString (const unsigned long l)
BitString (const std::vector< BYTE > &d)
BitString (const std::string &d)
void setArity (EmbValue arity)
EmbValue getArity (void) const
UWORD32 getLength (void) const
UWORD32 getNAryLength (void) const
BitString & clear (void)
BitString & append (const BIT v)
BitString & append (const BYTE v, const unsigned short n=8)
BitString & append (const UWORD16 v, const unsigned short n=16)
BitString & append (const UWORD32 v, const unsigned short n=32)
BitString & append (const std::string &v)
BitString & append (const std::vector< BYTE > &v)
BitString & append (const BitString &v)
BitString & setBit (unsigned long i, BIT v)
BitString getBits (const unsigned long s, const unsigned long l) const
BitString cutBits (const unsigned long s, const unsigned long l)
UWORD32 getValue (const unsigned long s, const unsigned short l) const
const std::vector< BYTE > & getBytes (void) const
BitString & truncate (const unsigned long s, const unsigned long e)
BitString & pad (const unsigned long mult, const BIT v)
BitString & padRandom (const unsigned long mult)
BYTE getNAry (unsigned long p) const
void appendNAry (BYTE v)
BIT operator[] (const unsigned long i) const
BitString & operator^= (const BitString &v)
bool operator== (const BitString &v) const
bool operator!= (const BitString &v) const
void print (unsigned short spc=0) const
Private Member Functions
void _append (BIT v)
void clearUnused (void)
Private Attributes
UWORD32 Length
    the number of bits in Data
EmbValue Arity
    the arity that will be used for getLength/getNAry/appendNAry
unsigned short ArityNBits
    the number of Bits per n-ary digit (where n is Arity)
std::vector< BYTE > Data
    the actual data

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)
construct an empty BitString
BitString::BitString (const BitString & bs)
copy constructor
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::setArity (EmbValue arity) EmbValue BitString::getArity (void) const [inline] UWORD32 BitString::getLength (void) const [inline]
get the number of bits in this BitString
UWORD32 BitString::getNAryLength (void) const [inline]
get the number of EmbValues in this BitString (using this BitString's arity)
BitString & BitString::clear (void)
delete the contents of this Bitstring
BitString & BitString::append (const BIT v)
append the bit v to this BitString
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
BitString & BitString::append (const UWORD16 v, const unsigned short n =
16)
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 UWORD32 v, const unsigned short n =
32)
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 std::string & v)
append the string v to this BitString
BitString & BitString::append (const std::vector< BYTE > & v)
append the vector v byte-wise to this BitString
BitString & BitString::append (const BitString & v)
append the BitString v to this BitString
Parameters:
v the BitString to be appended
BitString & BitString::setBit (unsigned long i, BIT v)
set the p-th bit to v
Parameters:
i the index (must be < getLength())
v the value
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
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,... .
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]
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
BitString & BitString::truncate (const unsigned long s, const unsigned long
e)
truncate this BitString
Parameters:
s start
e end
Returns:
this BitString modified to contain only (*this)[s]...(*this)[e - 1]
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)
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
void BitString::appendNAry (BYTE v)
append an n-ary digit to this BitString
Parameters:
v the n-ary value to be appended
BIT BitString::operator[] (const unsigned long i) const
get the value of the i-th bit
BitString & BitString::operator^= (const BitString & v)
xor v with this BitString, saving the result in this Bitstring. The result has the same length as this BitString.
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
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
void BitString::print (unsigned short spc = 0) const void BitString::_append (BIT v) [private] void BitString::clearUnused (void) [private]
clear unused part of last byte (_append depends on this)

Member Data Documentation

UWORD32 BitString::Length [private] EmbValue BitString::Arity [private] unsigned short BitString::ArityNBits [private] std::vector<BYTE> BitString::Data [private]

Author

Generated automatically by Doxygen for steghide from the source code.
Copyright © 2010-2025 Platon Technologies, s.r.o.           Home | Man pages | tLDP | Documents | Utilities | About
Design by styleshout