gCAD3D 2.35
ut_BitTab.h File Reference

Go to the source code of this file.

Macros

#define BitTab(bt, siz)   unsigned char bt[(siz >> 3) + 1]
 define bitArray; bt = arrayName; siz = number of bits. More...
 
#define BitTab_ini0(bt)   memset(bt,'\0',sizeof(bt))
 init bitArray. Fill bitArray with zeros. More...
 
#define BitTab_ini1(bt)   memset(bt,255,sizeof(bt))
 init bitArray. Fill bitArray with 1. More...
 
#define BitTab_set(bt, ii)   (bt[ii >> 3] |= 1 << ii % 8)
 set bit. bt = arrayName; bitnr = ii. More...
 
#define BitTab_get(bt, ii)   (bt[ii >> 3] & 1 << ii % 8)
 read bit. bt = arrayName; bitnr = ii. RetVal: 0 = not_set; else set. More...
 
#define BitTab_clr(bt, ii)   bt[ii >> 3] &= ~(1 << ii % 8)
 clear bit (reset bit). bt = arrayName; bitnr = ii. More...
 
#define BitTab_cpy(bt2, bt1)   memcpy (bt2, bt1, sizeof(bt1))
 copy bitArray. (bt2 = bt1) More...
 
#define BitTab_bNr(bt1)   (sizeof(bt1) << 3)
 get nr of bits More...
 

Functions

int BitTab_dump (unsigned char *bt, int bNr)
 

Detailed Description

Functions for bit-arrays
=====================================================
Liste_Funktionen_Beginn:
BitTab define bitarray
BitTab_ini0 init all bits to value 0
BitTab_ini1 init all bits to value 1
BitTab_set set bit
BitTab_get get bit
BitTab_clr reset (clear) bit
Liste_Funktionen_Ende:
=====================================================
Example:
#include "../ut/ut_BitTab.h" // bit-arrays
BitTab (ba,256); // define array of 256 bits; creates "char bt[32];"
BitTab_ini0 (ba); // init all bits to value 0;
BitTab_set (ba,20); // set bit nr 20
i1 = BitTab_get (ba,20); // test bit nr 20; returns != 0 (is set; 0=not set).
BitTab_clr (ba,20); // reset (clear) bit nr 20.

Macro Definition Documentation

#define BitTab (   bt,
  siz 
)    unsigned char bt[(siz >> 3) + 1]

define bitArray; bt = arrayName; siz = number of bits.

#define BitTab_ini0 (   bt)    memset(bt,'\0',sizeof(bt))

init bitArray. Fill bitArray with zeros.

#define BitTab_ini1 (   bt)    memset(bt,255,sizeof(bt))

init bitArray. Fill bitArray with 1.

#define BitTab_set (   bt,
  ii 
)    (bt[ii >> 3] |= 1 << ii % 8)

set bit. bt = arrayName; bitnr = ii.

#define BitTab_get (   bt,
  ii 
)    (bt[ii >> 3] & 1 << ii % 8)

read bit. bt = arrayName; bitnr = ii. RetVal: 0 = not_set; else set.

#define BitTab_clr (   bt,
  ii 
)    bt[ii >> 3] &= ~(1 << ii % 8)

clear bit (reset bit). bt = arrayName; bitnr = ii.

#define BitTab_cpy (   bt2,
  bt1 
)    memcpy (bt2, bt1, sizeof(bt1))

copy bitArray. (bt2 = bt1)

#define BitTab_bNr (   bt1)    (sizeof(bt1) << 3)

get nr of bits

Function Documentation

int BitTab_dump ( unsigned char *  bt,
int  bNr 
)