//==============================================================================
//
//  Bitstr.h
//
//  Library for bit strings manipulation design
//
//  developer: Henry Guennadi Levkin
//
//  ver. 0.03
//
//==============================================================================

#include <stdio.h>
#include <stdlib.h>

//------------------------------------------------------------------------------
typedef struct
{
  unsigned int* pS; // pointer to buffer with bit string

  int nBits;      // number of bits in bit string

  int nSize;      // number of used integers in buffer
  int nMaxSize;   // size of buffer

} SBitstr;


//------------------------------------------------------------------------------
// allocate new SBitstr object and buffer in it
SBitstr* BitstrAlloc(int nSize); // size in bits

//------------------------------------------------------------------------------
// pStr  - pointer to initializing object
// pArr  - array of integers with bit string
// nBits - total number of bits in integer array
void BitstrInit(SBitstr* pBitstr, int* pArr, int nBits);

//------------------------------------------------------------------------------
void BitstrFreeBuf(SBitstr* pBitstr);

//------------------------------------------------------------------------------
// pair to BitstrAlloc
void BitstrFree(SBitstr* pBitstr);

//------------------------------------------------------------------------------
int BitstrGetSize(SBitstr* pBitstr);

//------------------------------------------------------------------------------
int BitstrGetMaxSize(SBitstr* pBitstr);

//------------------------------------------------------------------------------
int* StrGetBuffer(SBitstr* pBitstr);

//------------------------------------------------------------------------------
int BitstrExpand(SBitstr* pBitstr, int nNewSize);

//------------------------------------------------------------------------------
int BitstrCopy(SBitstr* pSrc, SBitstr* pDest);

//------------------------------------------------------------------------------
// return number of copied integers
int BitstrCopyToArr(SBitstr* pBitstr, int* pArr);

//------------------------------------------------------------------------------
void BitstrDump(SBitstr* pBitstr);

//------------------------------------------------------------------------------
int BitstrCompare(SBitstr* pStr1, SBitstr* pStr2)

//------------------------------------------------------------------------------
int BitstrGetBit(SBitstr* pBitstr, int nBitPosition);

//------------------------------------------------------------------------------
int BitstrSetBit(SBitstr* pBitstr, int nBitPosition, int bitValue);

//------------------------------------------------------------------------------
void BitstrAddBit(SBitstr* pBitstr, int nBit);

//------------------------------------------------------------------------------
int BitstrMoveBit(SBitstr* pBitstr);

//------------------------------------------------------------------------------
int BitstrConcat(SBitstr* pBitstr1, SBitstr* pBitstr2);

//------------------------------------------------------------------------------
void BitstrCutTail(SBitstr* pBitstr, int nBitsNumber);

//------------------------------------------------------------------------------

//------------------------------------------------------------------------------

