#pragma once

#include <deque>
#include "Bit.h"

using std::deque;


class CWord
{
protected:

    unsigned m_nBitLength;
    deque<CBit> m_word;


public:
    CWord(unsigned nBitLength);
    virtual ~CWord();

    CBit *GetAt(unsigned nBitPos);

    void Set(unsigned data);
    void Set(const unsigned char *data, unsigned lengthInBits);
    void Rotate();

    bool Insert(unsigned npos, CBit b);
    bool Delete(unsigned npos);

    void Copy(unsigned char *ptr);

    void Append(CBit b);

    void Resize(unsigned nsize);

    bool PartShiftRight(unsigned nPos, unsigned nShift);

    inline unsigned GetLength() const
    {
        return m_nBitLength;
    };

    void Print();

    CWord &operator=(unsigned d)
    {
        Set(d);
        return *this;
    }

    CBit &operator[](unsigned nPos)
    {
        return m_word.at(nPos);
    }

    friend CWord operator >> (CWord l, const unsigned &r)
    {
        for (unsigned i = 0; i < r; i++) {
            l.m_word.pop_front();
            l.m_word.push_back(CBit(CBit::VALUE::ZERO));
        }
        return l;
    }
};

