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