Print

NOCL_Bit_List

(Concept - Properties - Functions

Version: 1.0 (Older Versions)

Location: cl_objects.php

This class breaks a byte into bits (up to 64 of them) and enables manipulation at the bit level or the byte level.

 

Concept

There is a need to hold onto a number, and be able to access the individual bits within it. 

This class will hold that number and allow updating of individual bits, which all effect the total as well

 

Properties

 

Functions

 

__construct()

Version: 1.0

Called when class is instantiated

Usage:

$byteObject = new NOCL_Bit_List( [ $integerValue ] );

 

Paramenters:

 

Returns:

Silently after setting property values internally.  Actually, returns this class as an object.

 

Process:

 

Peek()

Version: 1.0

Have a look at, and get the value of an individual bit

Usage:

$boolVar = $bitListObject->peek( $bitNumber );

 

Paramenters:

 

Returns:

0 or 1 depending on value, or -1 if there's a failure

 

Process:

 

turnBitOn()

Version: 1.0

Turn on the value of a bit.

Usage:

$byteObj->turnBitOn( $bit Number );

 

Paramenters:

 

Returns:

False on unsuccessful completion, otherwise silent.

 

Process:

 

turnBitOff()

Version: 1.0

Turn on the value of a bit.

Usage:

$byteObj->turnBitOff( $bit Number );

 

Paramenters:

 

Returns:

False on unsuccessful completion, otherwise silent.

 

Process:

 

toggleBit()

Version: 1.0

Turn on the value of a bit, or off, depending on whether its alreay off or on..

Usage:

$ResultInt = $byteObj->toggleBit( $bit Number );

 

Paramenters:

Returns:

False on unsuccessful completion, otherwise silent.

 

Process:

 

byteSize()

Version: 1.0

Returns the number of bits, rounded up to the nearest multiple of 8,  This way if the byte is 3 bytes long, there will be 24 bits.

Usage:

$numberOfBits = $byteObj->byteSize( $maxBit );

 

Paramenters:

 

Returns:

The number of bits that make up the byte(s)

 

Process:

 

ensureSize()

Version: 1.0

Make sure a byte is no larger or smaller than needed by a given byte number

Usage:

$bitList->ensureSize( $bitNumber );

 

Paramenters:

 

Returns:

Silently

 

Process:

 

modifyBit()

Version: 1.0

Change the value of a bit to on, off, or the opposite of what it is now

Usage:

$bitList->modifyBit( $bitNumber, $newValue );

 

Paramenters:

 

Returns:

Silently

 

Process:

 

calculateInteger()

Version: 1.0

Calculate and set the current integer, based on current bit values

Usage:

$bitList->calculateInteger();

 

Paramenters:

None

 

Returns:

Silently

 

Process:

 

decIntValue()

Version: 1.0

The value of this byte expressed as a decimal (base 10) integer

Usage:

$decimalInteger = $bitListObject->decIntValue();

 

Paramenters:

 None

 

Returns:

The decimal integer value of this byte

 

Process:

 

setNewValue()

Version: 1.0

Set bit values based on an input number

Usage:

$bitListObject->setNewValue( $newValue );

 

Paramenters:

 

Returns:

Silently

 

Process:

 

 

 

onBits()

Version: 1.0

An array containing the indexes of any bits that are turned on.

Usage:

$arrayOfIDsOfBitsThatAreOn = $bitListObject->onBits();

 

Paramenters:

None

 

Returns:

An array where the values are the bit number (starting at 1) from this object of each true value

 

Process: