| 92 | const USHORT USR_sysdba = 4; // User detected as SYSDBA |
| 93 | |
| 94 | class UserId |
| 95 | { |
| 96 | public: |
| 97 | // Arbitrary size bitmask |
| 98 | template <unsigned N> |
| 99 | class Bits |
| 100 | { |
| 101 | static const unsigned shift = 3; |
| 102 | static const unsigned bitmask = (1 << shift) - 1; |
| 103 | |
| 104 | static const unsigned L = (N >> shift) + (N & bitmask ? 1 : 0); |
| 105 | |
| 106 | public: |
| 107 | static const unsigned BYTES_COUNT = L; |
| 108 | |
| 109 | Bits() |
| 110 | { |
| 111 | clearAll(); |
| 112 | } |
| 113 | |
| 114 | Bits(const Bits& b) |
| 115 | { |
| 116 | assign(b); |
| 117 | } |
| 118 | |
| 119 | Bits& operator=(const Bits& b) |
| 120 | { |
| 121 | assign(b); |
| 122 | return *this; |
| 123 | } |
| 124 | |
| 125 | Bits& set(unsigned i) |
| 126 | { |
| 127 | fb_assert(i < N); |
| 128 | if (i < N) |
| 129 | data[index(i)] |= mask(i); |
| 130 | return *this; |
| 131 | } |
| 132 | |
| 133 | Bits& setAll() |
| 134 | { |
| 135 | memset(data, ~0, sizeof data); |
| 136 | return *this; |
| 137 | } |
| 138 | |
| 139 | Bits& clear(unsigned i) |
| 140 | { |
| 141 | fb_assert(i < N); |
| 142 | if (i < N) |
| 143 | data[index(i)] &= ~mask(i); |
| 144 | return *this; |
| 145 | } |
| 146 | |
| 147 | Bits& clearAll() |
| 148 | { |
| 149 | memset(data, 0, sizeof data); |
| 150 | return *this; |
| 151 | } |
no test coverage detected