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