OpenClovis Logo

API Usage Examples

Code Examples.

Code Examples.

Create a bitmap of specified length

ClBitmapHandleT bitHdl = CL_BM_INVALID_BITMAP_HANDLE;
ClRcT rc = CL_OK;
ClUint32T bitNum = 10;
/*Creates a bitmap of length 10 (bit 0-9)*/
rc = clBitmapCreate(&bitHdl, bitNum);
if(CL_OK != rc)
{
clLogError("EXP","BIT", "Failed to create bitmap.");
return rc;
}
ClRcT clBitmapCreate(CL_OUT ClBitmapHandleT *phBitmap, CL_IN ClUint32T bitNum)
Create a bitmap.
ClUint32T ClRcT
Clovis return code type.
Definition: clCommon.h:168
#define CL_OK
Every thing is OK.
Definition: clCommonErrors.h:68

Set a bit of the bitmap

ClUint32T bitNum = 5;
/*Get bitHdl by calling clBitmapCreate()*/
rc = clBitmapBitSet(bitHdl, bitNum);
if(CL_OK != rc)
{
clLogError("EXP","BIT", "Failed to set the bit 5.");
return rc;
}
ClRcT clBitmapBitSet(CL_IN ClBitmapHandleT hBitmap, CL_IN ClUint32T bitNum)
Set a bit of the bitmap.

Check the status of a bit of the bitmap

ClUint32T bitNum = 5;
ClRcT retVal = CL_OK;
ClInt32T bitStatus = CL_BM_BIT_UNDEF;
/*Get bitHdl by calling clBitmapCreate()*/
bitStatus = clBitmapIsBitSet(bitHdl, bitNum, &retVal);
if(CL_OK != retVal)
{
clLogError("EXP","BIT", "Failed to check the bit status.");
return rc;
}
if(CL_BM_BIT_SET == bitStatus)
{
clLogInfo("EXP","BIT", "Bit 5 is set.");
}
else if(CL_BM_BIT_CLEAR == bitStatus)
{
clLogInfo("EXP","BIT", "Bit 5 is not set.");
}
else
{
clLogInfo("EXP","BIT", "Bit 5 is undefined.");
}
ClInt32T clBitmapIsBitSet(CL_IN ClBitmapHandleT hBitmap, CL_IN ClUint32T bitNum, CL_OUT ClRcT *pRetCode)
Find the status of a bit (Set or Clear) in a bitmap.

Clear a bit of the bitmap

ClUint32T bitNum = 3;
Clear a bit of the bitmap
/*Get bitHdl by calling clBitmapCreate()*/
rc = clBitmapBitClear(bitHdl, bitNum);
if(CL_OK != rc)
{
clLogError("EXP","BIT", "Failed to clear bit number 3.");
return rc;
}
ClRcT clBitmapBitClear(CL_IN ClBitmapHandleT hBitmap, CL_IN ClUint32T bitNum)
Clear a bit of the bitmap.

Get the length of the bitmap

ClUint32T bitmapLength = 0;
/*Get bitHdl by calling clBitmapCreate()*/
bitmapLength = clBitmapLen(bitHdl);
if(0 == bitmapLength)
{
clLogError("EXP","BIT", "Failed to get the bitmap length.");
}
else
{
clLogInfo("EXP","BIT", "Bitmap length = %d.", bitmapLength);
}
ClUint32T clBitmapLen(CL_IN ClBitmapHandleT hBitmap)
Get the length of a bitmap.

Get the number of bits set in the bitmap

ClUint32T numBitSet = 0;
/*Get bitHdl by calling clBitmapCreate()*/
rc = clBitmapNumBitsSet(bitHdl, &numBitSet);
if(CL_OK != rc)
{
clLogError("EXP","BIT", "Failed to get the bitmap length.");
return rc;
}
else
{
clLogInfo("EXP","BIT", "Number of bits set in the bitmap = %d.",
numBitSet);
}
ClRcT clBitmapNumBitsSet(CL_IN ClBitmapHandleT hBitmap, CL_OUT ClUint32T *pNumBits)
Number of bits set in a bitmap.

Destroy the Bitmap

/*Get bitHdl by calling clBitmapCreate()*/
rc = clBitmapDestroy(bitHdl);
if(CL_OK != rc)
{
clLogError("EXP","BIT", "Failed to destroy the bitmap.");
return rc;
}
ClRcT clBitmapDestroy(CL_IN ClBitmapHandleT hBitmap)
Destroy a bitmap.

Generated on Tue Jan 10 10:29:15 PST 2012 for OpenClovis SDK using Doxygen