1//----------------------------------------------------------------------------
2// Anti-Grain Geometry - Version 2.4
3// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
4//
5// Permission to copy, use, modify, sell and distribute this software
6// is granted provided this copyright notice appears in all copies.
7// This software is provided "as is" without express or implied
8// warranty, and with no claim as to its suitability for any purpose.
9//
10//----------------------------------------------------------------------------
11// Contact: mcseem@antigrain.com
12//          mcseemagg@yahoo.com
13//          http://www.antigrain.com
14//----------------------------------------------------------------------------
15
16#ifndef AGG_BITSET_ITERATOR_INCLUDED
17#define AGG_BITSET_ITERATOR_INCLUDED
18
19#include "agg_basics.h"
20
21namespace agg
22{
23
24    class bitset_iterator
25    {
26    public:
27        bitset_iterator(const int8u* bits, unsigned offset = 0) :
28            m_bits(bits + (offset >> 3)),
29            m_mask(0x80 >> (offset & 7))
30        {}
31
32        void operator ++ ()
33        {
34            m_mask >>= 1;
35            if(m_mask == 0)
36            {
37                ++m_bits;
38                m_mask = 0x80;
39            }
40        }
41
42        unsigned bit() const
43        {
44            return (*m_bits) & m_mask;
45        }
46
47    private:
48        const int8u* m_bits;
49        int8u        m_mask;
50    };
51
52}
53
54#endif
55