//Editor-Info: -*- C++ -*-
//
//Subject:  TOVE project / 
//
//File: bitstring.h
//
//Version: $Revision: 1.9 $
//
//State: $State: Exp $
//
//Date: $Date: 1998/06/23 06:38:02 $
//
//Organisation:
//      Helsinki University of Technology
//      Laboratory of Telecommunications Software and Multimedia
//
//Authors:
//      Sami Raatikainen
//
//Description:
//      Simple class for bit manipulation.
//      There's no limit with the number of bits, except the memory.
//
//Copyright:
//      Copyright 1999 Helsinki University of Technology
//      ALL RIGHTS RESERVED BETWEEN JANUARY 1996 AND JUNE 1999.
//      
//Licence:
//     
//
//History:
//
// 

#ifndef __PF_BITSTRING_H__
#define __PF_BITSTRING_H__
#include <typeinfo>
#include <string>
#include "pf/types.h"

//
//Class: pfBitString
// 
//Description:
//      See file description
//

class pfBitString
{
    public:
        pfBitString(void);
        pfBitString(const string &string_);
        pfBitString(const pfBitString &other_);
        virtual ~pfBitString(void);
        
        pfBoolean operator==(const pfBitString &other_) const;
        pfBoolean operator!=(const pfBitString &other_) const;
        friend ostream& operator<<(ostream &ostream_,
                                   const pfBitString &bitString_);
        pfUlong length(void) const;

        void putFirstBits(pfUlong value_, pfUlong length_);
        void putFirstBits(const string &string_);
        void putLastBits(pfUlong value_, pfUlong length_);
        void putLastBits(const string &string_);
        
        pfUlong getFirstBits(pfUlong length_);
        pfUlong getLastBits(pfUlong length_);
        
        pfUlong readBits(pfUlong offset_, pfUlong length_) const;

        string toString(pfUlong length_ = 0) const;
        
    private:
        string _bitString;
        
        void checkString(const string &string_) const;
        string longToString(pfUlong value_, pfUlong length_) const;
};

#endif // __PF_BITSTRING_H__
