Public Member Functions | Static Public Member Functions | Protected Attributes

zeus::TBitCodedValue Class Reference

#include <BitCodedValue.h>

List of all members.

Public Member Functions

 TBitCodedValue ()
 TBitCodedValue (const TBitCodedValue &rValue)
 TBitCodedValue (int iValue, Int iMaxSize=64)
 TBitCodedValue (unsigned int uiValue, Int iMaxSize=64)
 TBitCodedValue (Int8 cValue, Int iMaxSize=8)
 TBitCodedValue (Int16 sValue, Int iMaxSize=16)
 TBitCodedValue (Int32 lValue, Int iMaxSize=32)
 TBitCodedValue (Int64 ldValue, Int iMaxSize=64)
 TBitCodedValue (Uint8 ucValue, Int iMaxSize=8)
 TBitCodedValue (Uint16 usValue, Int iMaxSize=16)
 TBitCodedValue (Uint32 ulValue, Int iMaxSize=32)
 TBitCodedValue (Uint64 uldValue, Int iMaxSize=64)
virtual ~TBitCodedValue ()
TString toBinary (bool bTrimZeros=false, bool bAddPreamble=true) const
TString toHex (bool bTrimZeros=false, bool bAddPreamble=true) const
Int8 getInt8 () const
Int16 getInt16 () const
Int32 getInt32 () const
Int64 getInt64 () const
Uint8 getUint8 () const
Uint16 getUint16 () const
Uint32 getUint32 () const
Uint64 getUint64 () const
bool getBit (Int iIndex, bool *pError=NULL) const
Int getFirstBitSet () const
Int getFirstBitSet (Uint64 uldMask) const
Int getLastBitSet () const
Int getLastBitSet (Uint64 uldMask) const
void invertAll ()
bool invertBit (Int iIndex)
bool setBit (Int iIndex, bool bState)
bool setBitRange (Int iFromIndex, Int iToIndex, Uint64 uldValue, bool bForce=false)
bool setBitRange (Int iFromIndex, Int iToIndex, Int64 ldValue, bool bForce=false)
bool setBitRange (Int iFromIndex, Int iToIndex, int iValue, bool bForce=false)
bool setBitRange (Int iFromIndex, Int iToIndex, unsigned int uiValue, bool bForce=false)
bool operator== (Int64 ldValue) const
bool operator== (Uint64 uldValue) const
bool operator== (const TBitCodedValue &rValue) const
bool operator== (int iValue) const
bool operator== (unsigned int uiValue) const
bool operator!= (Int64 ldValue) const
bool operator!= (Uint64 uldValue) const
bool operator!= (const TBitCodedValue &rValue) const
bool operator!= (int iValue) const
bool operator!= (unsigned int uiValue) const
TBitCodedValueoperator= (Int64 ldValue)
TBitCodedValueoperator= (Uint64 uldValue)
TBitCodedValueoperator= (const TBitCodedValue &rValue)
TBitCodedValueoperator= (int iValue)
TBitCodedValueoperator= (unsigned int uiValue)
bool operator[] (Int iIndex) const

Static Public Member Functions

static TString convertToBinary (const TBitCodedValue &rValue, bool bTrimZeros, bool bAddPreamble)
static TString convertToBinary (Uint64 uldValue, Int iMaxSize, bool bTrimZeros, bool bAddPreamble)
static TString convertToHex (const TBitCodedValue &rValue, bool bTrimZeros, bool bAddPreamble)
static TString convertToHex (const IByteArray &rValue, bool bTrimZeros, bool bAddPreamble)
static TString convertToHex (Uint64 uldValue, Int iMaxSize, bool bTrimZeros, bool bAddPreamble)
static Int64 convertHexToInt64 (const TString &rString, bool &rError, Int64 ldPredef=0)
static Int64 convertBinaryToInt64 (const TString &rString, bool &rError, Int64 ldPredef=0)
static void convertDecimalToByteArray (const TString &rString, bool &rError, IByteArray &rValue)
static void convertHexToByteArray (const TString &rString, bool &rError, IByteArray &rValue)

Protected Attributes

Uint64 m_uldBitArray
 Bit coded value.
Int m_iMaxSize
 Max bit code size.

Detailed Description

This class implements a bit coded value as a stack type. The bit coded value is used as helper class for setting bits or event bytes inside a 64 bit array.

Todo:
: We might extend this class for larger bit arrays than 64 bits.

Constructor & Destructor Documentation

TBitCodedValue::TBitCodedValue (  )

Creates an empty bit coded value

TBitCodedValue::TBitCodedValue ( const TBitCodedValue rValue )

Copy constructor of the bit coded value

Parameters:
rValue: Value to copy
TBitCodedValue::TBitCodedValue ( int  iValue,
Int  iMaxSize = 64 
)

Creates a bit coded value out of an int value

Parameters:
iValue: Value to copy
iMaxSize: Max bit code value
TBitCodedValue::TBitCodedValue ( unsigned int  uiValue,
Int  iMaxSize = 64 
)

Creates a bit coded value out of an unsigned int value

Parameters:
uiValue: Value to copy
iMaxSize: Max bit code value
TBitCodedValue::TBitCodedValue ( Int8  cValue,
Int  iMaxSize = 8 
)

Creates a bit coded value out of an signed int8 value

Parameters:
cValue: Value to copy
iMaxSize: Max bit code value
TBitCodedValue::TBitCodedValue ( Int16  sValue,
Int  iMaxSize = 16 
)

Creates a bit coded value out of an signed int16 value

Parameters:
sValue: Value to copy
iMaxSize: Max bit code value
TBitCodedValue::TBitCodedValue ( Int32  lValue,
Int  iMaxSize = 32 
)

Creates a bit coded value out of an signed int32 value

Parameters:
lValue: Value to copy
iMaxSize: Max bit code value
TBitCodedValue::TBitCodedValue ( Int64  ldValue,
Int  iMaxSize = 64 
)

Creates a bit coded value out of an signed int64 value

Parameters:
ldValue: Value to copy
iMaxSize: Max bit code value
TBitCodedValue::TBitCodedValue ( Uint8  ucValue,
Int  iMaxSize = 8 
)

Creates a bit coded value out of an unsigned int8 value

Parameters:
ucValue: Value to copy
iMaxSize: Max bit code value
TBitCodedValue::TBitCodedValue ( Uint16  usValue,
Int  iMaxSize = 16 
)

Creates a bit coded value out of an unsigned int16 value

Parameters:
usValue: Value to copy
iMaxSize: Max bit code value
TBitCodedValue::TBitCodedValue ( Uint32  ulValue,
Int  iMaxSize = 32 
)

Creates a bit coded value out of an unsigned int32 value

Parameters:
ulValue: Value to copy
iMaxSize: Max bit code value
TBitCodedValue::TBitCodedValue ( Uint64  uldValue,
Int  iMaxSize = 64 
)

Creates a bit coded value out of an unsigned int64 value

Parameters:
uldValue: Value to copy
iMaxSize: Max bit code value
TBitCodedValue::~TBitCodedValue (  ) [virtual]

Destroys the bit coded value


Member Function Documentation

Int64 TBitCodedValue::convertBinaryToInt64 ( const TString rString,
bool &  rError,
Int64  ldPredef = 0 
) [static]

converts a string in binary notation into a int64 value

Parameters:
rString: string to convert
rError: return value. True = Convertion was successfully
ldPredef: pre definition value to return if the string is not valid
Returns:
int64 value
void TBitCodedValue::convertDecimalToByteArray ( const TString rString,
bool &  rError,
IByteArray rValue 
) [static]

Converts a big decimal number stored in a string into a byte array (binary data).

Parameters:
rString: string containing the decimal number
rError: returns error value. True = Convertion was successfully
rValue,:generated binary data
void TBitCodedValue::convertHexToByteArray ( const TString rString,
bool &  rError,
IByteArray rValue 
) [static]

converts a string in hex notation into a byte array value

Parameters:
rString: string to convert
rError: return error value. True = Convertion was successfully
rValue: generated value
Int64 TBitCodedValue::convertHexToInt64 ( const TString rString,
bool &  rError,
Int64  ldPredef = 0 
) [static]

converts a string in hex notation into a int64 value

Parameters:
rString: string to convert
rError: return value. True = Convertion was successfully
ldPredef: pre definition value to return if the string is not valid
Returns:
int64 value
TString TBitCodedValue::convertToBinary ( Uint64  uldValue,
Int  iMaxSize,
bool  bTrimZeros,
bool  bAddPreamble 
) [static]

converts a bit coded value into a binary output

Parameters:
uldValue: Value to convert
iMaxSize: How many bits must be considered
bTrimZeros: Trim leading zeros.
bAddPreamble: add the preamble "0b".
Returns:
binary notation as string
TString zeus::TBitCodedValue::convertToBinary ( const TBitCodedValue rValue,
bool  bTrimZeros,
bool  bAddPreamble 
) [inline, static]

converts a bit coded value into a binary output

TString TBitCodedValue::convertToHex ( const IByteArray rValue,
bool  bTrimZeros,
bool  bAddPreamble 
) [static]

Converts a byte array into a hex notation

TString TBitCodedValue::convertToHex ( Uint64  uldValue,
Int  iMaxSize,
bool  bTrimZeros,
bool  bAddPreamble 
) [static]

converts a bit coded value into a hex output

Parameters:
uldValue: Value to convert
iMaxSize: How many bits must be considered
bTrimZeros: Trim leading zeros.
bAddPreamble: add the preamble "0x".
Returns:
hex notation as string
TString zeus::TBitCodedValue::convertToHex ( const TBitCodedValue rValue,
bool  bTrimZeros,
bool  bAddPreamble 
) [inline, static]

converts a bit coded value into a hexadecimal output

bool TBitCodedValue::getBit ( Int  iIndex,
bool *  pError = NULL 
) const

returns the state of a bit

Parameters:
iIndex: Index of the bit (0 to 63)
pError: Optional parameter to receive the error (wrong index)
Return values:
true: Bit is set
false,:Bit is not set
Int TBitCodedValue::getFirstBitSet (  ) const

Returns the first bit index of a bit set to 1. This method implements the de Bruijn algorithm (see http://supertech.csail.mit.edu/papers/debruijn.pdf).

Return values:
>=0 : Index of bit set
INVALID_INDEX: No bit is set
Int TBitCodedValue::getFirstBitSet ( Uint64  uldMask ) const

Returns the first bit index of a bit set to 1. This method implements the de Bruijn algorithm (see http://supertech.csail.mit.edu/papers/debruijn.pdf).

Parameters:
uldMask: Mask to mask out the interesting bits
Return values:
>=0 : Index of bit set
INVALID_INDEX: No bit is set
Int16 zeus::TBitCodedValue::getInt16 (  ) const [inline]

Returns a int16 value

Int32 zeus::TBitCodedValue::getInt32 (  ) const [inline]

Returns a int32 value

Int64 zeus::TBitCodedValue::getInt64 (  ) const [inline]

Returns a int64 value

Int8 zeus::TBitCodedValue::getInt8 (  ) const [inline]

Returns a int8 value

Int TBitCodedValue::getLastBitSet (  ) const

Returns the last bit index of a bit set to 1

Return values:
>=0 : Index of bit set
INVALID_INDEX: No bit is set
Int TBitCodedValue::getLastBitSet ( Uint64  uldMask ) const

Returns the last bit index of a bit set to 1

Parameters:
uldMask: Mask to mask out the interesting bits
Return values:
>=0 : Index of bit set
INVALID_INDEX: No bit is set
Uint16 zeus::TBitCodedValue::getUint16 (  ) const [inline]

Returns a Uint16 value

Uint32 zeus::TBitCodedValue::getUint32 (  ) const [inline]

Returns a Uint32 value

Uint64 zeus::TBitCodedValue::getUint64 (  ) const [inline]

Returns a Uint64 value

Uint8 zeus::TBitCodedValue::getUint8 (  ) const [inline]

Returns a Uint8 value

void zeus::TBitCodedValue::invertAll (  ) [inline]

inverts all bits

bool TBitCodedValue::invertBit ( Int  iIndex )

inverts an indexed bit

Parameters:
iIndex: Index of the bit
bool zeus::TBitCodedValue::operator!= ( unsigned int  uiValue ) const [inline]

compares a value with the bit coded value

bool zeus::TBitCodedValue::operator!= ( Uint64  uldValue ) const [inline]

compares a value with the bit coded value

bool zeus::TBitCodedValue::operator!= ( int  iValue ) const [inline]

compares a value with the bit coded value

bool zeus::TBitCodedValue::operator!= ( Int64  ldValue ) const [inline]

compares a value with the bit coded value

bool zeus::TBitCodedValue::operator!= ( const TBitCodedValue rValue ) const [inline]

compares a value with the bit coded value

TBitCodedValue & zeus::TBitCodedValue::operator= ( Uint64  uldValue ) [inline]

assigns a new bit coded value

TBitCodedValue & zeus::TBitCodedValue::operator= ( Int64  ldValue ) [inline]

assigns a new bit coded value

TBitCodedValue & zeus::TBitCodedValue::operator= ( int  iValue ) [inline]

assigns a new bit coded value

TBitCodedValue & zeus::TBitCodedValue::operator= ( const TBitCodedValue rValue ) [inline]

assigns a new bit coded value

TBitCodedValue & zeus::TBitCodedValue::operator= ( unsigned int  uiValue ) [inline]

assigns a new bit coded value

bool zeus::TBitCodedValue::operator== ( const TBitCodedValue rValue ) const [inline]

compares a value with the bit coded value

bool zeus::TBitCodedValue::operator== ( Int64  ldValue ) const [inline]

compares a value with the bit coded value

bool zeus::TBitCodedValue::operator== ( Uint64  uldValue ) const [inline]

compares a value with the bit coded value

bool zeus::TBitCodedValue::operator== ( int  iValue ) const [inline]

compares a value with the bit coded value

bool zeus::TBitCodedValue::operator== ( unsigned int  uiValue ) const [inline]

compares a value with the bit coded value

bool zeus::TBitCodedValue::operator[] ( Int  iIndex ) const [inline]

returns an indexed value

bool TBitCodedValue::setBit ( Int  iIndex,
bool  bState 
)

sets the state of a bit

Parameters:
iIndex: Index of the bit (0 to 63)
bState: state of the bit
Return values:
true: Bit state has been set
false,:wrong index
bool TBitCodedValue::setBitRange ( Int  iFromIndex,
Int  iToIndex,
Uint64  uldValue,
bool  bForce = false 
)

sets a bit range from iFromIndex to iToIndex. If the range is too small for the given value not all bit can be set. The method returns false. The content of the bit coded value does not change, if this method returned false. If the force-flag is set this method will ignore if not all bits could be set.

Parameters:
iFromIndex,:from index
iToIndex: to index
uldValue: Value to set
bForce: force setting range even bits are not completly set
Return values:
false: wrong index or bits can not be set (value unchanged)
true: changes has been performed
Parameters:
bForce= false
bool zeus::TBitCodedValue::setBitRange ( Int  iFromIndex,
Int  iToIndex,
int  iValue,
bool  bForce = false 
) [inline]

sets a bit range from iFromIndex to iToIndex.

Parameters:
iFromIndex,:from index
iToIndex: to index
iValue: Value to set
bForce: force setting range even bits are not completly set
Return values:
false: wrong index or bits can not be set (value unchanged)
true: changes has been performed
Parameters:
bForce= false
bool zeus::TBitCodedValue::setBitRange ( Int  iFromIndex,
Int  iToIndex,
unsigned int  uiValue,
bool  bForce = false 
) [inline]

sets a bit range from iFromIndex to iToIndex.

Parameters:
iFromIndex,:from index
iToIndex: to index
uiValue: Value to set
bForce: force setting range even bits are not completly set
Return values:
false: wrong index or bits can not be set (value unchanged)
true: changes has been performed
Parameters:
bForce= false
bool zeus::TBitCodedValue::setBitRange ( Int  iFromIndex,
Int  iToIndex,
Int64  ldValue,
bool  bForce = false 
) [inline]

sets a bit range from iFromIndex to iToIndex.

Parameters:
iFromIndex,:from index
iToIndex: to index
ldValue: Value to set
bForce: force setting range even bits are not completly set
Return values:
false: wrong index or bits can not be set (value unchanged)
true: changes has been performed
Parameters:
bForce= false
TString zeus::TBitCodedValue::toBinary ( bool  bTrimZeros = false,
bool  bAddPreamble = true 
) const [inline]

converts the bit coded value into a binary output

TString zeus::TBitCodedValue::toHex ( bool  bTrimZeros = false,
bool  bAddPreamble = true 
) const [inline]

converts the bit coded value into a hexadecimal output


Member Data Documentation

Max bit code size.

Bit coded value.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


Written by Benjamin Hadorn http://www.xatlantis.ch.
Last change made on Sun Jan 22 2012 15:28:33