VIPER REFERENCE MANUAL


NAME
iflBitArray - limited subscriptable bit array class

HEADER FILE
#include <ifl/iflBitArray.h>

PUBLIC METHOD SUMMARY

   Constructor
iflBitArray ( void* dp);

   Subscripted access
iflBitArray& operator[] ( int idx);
void operator= ( int rhs);
operator int (  );

CLASS DESCRIPTION
This class implements a very limited functionality subscriptable bit array that is used by the image data type converter (iflConverter). The constructor requires a void* initializer, so a form such as
    int from[1024], to[1024];
    iflBitArray f = from, t = to;
declares bit "pointers" referencing the \f3int\fP arrays. The bit array can then be accessed with contructs of the form
    floatVal = (float)f[i];
and deposits made with statements such as
    t[i] = floatVal;        // no cast needed

NOTES
Due to limitations of the implementation, the same bit "pointer" must not occur twice in the same assignment (with different subscripts):
    t[i] = ~(long)t[j];  // bogus result (depends on order of evaluation)
    t[i] = f[j];         // ok even if 't' and 'f' point to same data array

METHOD DESCRIPTIONS

   iflBitArray()
iflBitArray ( void* dp);

Constructs a bit "pointer" that accesses the bit array pointed to by dp. Use the subscript operator to access elements of the array off this pseudo-pointer on either the left-hand or right-hand side of an assignment.

   operator int()
operator int (  );

The cast operator extracts the (previously remembered) subscripted bit. Again, C++ fills in all the other type conversions.

   operator=()
void operator= ( int rhs);

The assignment operator clears or sets the bit pointed to by the left-hand side of the assigment. The bit is set if rhs is nonzero, otherwise it is cleared. By only allowing a long for the right-hand side, a bit subscript on the right is automatically extracted by going through the cast operator. C++ converts other types such as float and short to long without complaining.

   operator[]()
iflBitArray& operator[] ( int idx);

The subscript operator stores the byte and bit offsets needed to access the element specified by idx. This function returns a self-reference so the real work can be done with the cast and assigment operators for this class. It works with certain restrictions noted below.