00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00024 #ifndef SHBITSET_HPP
00025 #define SHBITSET_HPP
00026
00027 #include <cstddef>
00028 #include <iosfwd>
00029 #include "ShDllExport.hpp"
00030
00031 namespace SH {
00032
00033
00034
00035
00036 class
00037 SH_DLLEXPORT ShBitRef {
00038 public:
00039 operator bool() const;
00040 ShBitRef& operator=(bool b);
00041
00042 private:
00043 friend class ShBitSet;
00044
00045 ShBitRef(unsigned int* byte, unsigned int mask);
00046
00047 unsigned int* m_byte;
00048 unsigned int m_mask;
00049
00050 ShBitRef(const ShBitRef& other);
00051 ShBitRef& operator=(const ShBitRef& other);
00052 };
00053
00059 class
00060 SH_DLLEXPORT ShBitSet {
00061 public:
00066 ShBitSet();
00067 explicit ShBitSet(std::size_t size);
00068 ShBitSet(const ShBitSet& other);
00069
00070 ~ShBitSet();
00071
00072 ShBitSet& operator=(const ShBitSet& other);
00073 ShBitSet& operator&=(const ShBitSet& other);
00074 ShBitSet& operator|=(const ShBitSet& other);
00075 ShBitSet& operator^=(const ShBitSet& other);
00076
00077 ShBitSet operator&(const ShBitSet& other) const;
00078 ShBitSet operator|(const ShBitSet& other) const;
00079 ShBitSet operator^(const ShBitSet& other) const;
00080
00081 ShBitSet operator~() const;
00082
00083 bool operator==(const ShBitSet& other) const;
00084 bool operator!=(const ShBitSet& other) const;
00085
00086
00087 bool full() const;
00088
00089 bool empty() const;
00090
00091 std::size_t size() const;
00092
00093 bool operator[](std::size_t i) const;
00094 ShBitRef operator[](std::size_t i);
00095
00096 private:
00097 std::size_t m_size;
00098 unsigned int* m_data;
00099 };
00100
00101 SH_DLLEXPORT
00102 std::ostream& operator<<(std::ostream& out, const ShBitSet& bitset);
00103
00104 }
00105
00106 #endif