Bluenet  5.7.0
Bluenet, firmware for nRF52 smart home devices
Loading...
Searching...
No Matches
cs_BitmaskVarSize.h
Go to the documentation of this file.
1/*
2 * Author: Crownstone Team
3 * Copyright: Crownstone (https://crownstone.rocks)
4 * Date: Apr 1, 2020
5 * License: LGPLv3+, Apache License 2.0, and/or MIT (triple-licensed)
6 */
7
8#pragma once
9
10#include <cstdint>
11
18public:
21
30 bool setNumBits(uint8_t numBits);
31
35 bool setBit(uint8_t bit);
36
40 bool clearBit(uint8_t bit);
41
45 bool isSet(uint8_t bit);
46
51
56
57protected:
58 uint8_t _numBits = 0;
59
69 uint8_t* _bitmask = nullptr;
70
74 uint8_t getNumBytes(uint8_t numBits);
75};
Class that holds a bitmask of variable size.
Definition: cs_BitmaskVarSize.h:17
void clearAllBits()
Clear all bits.
bool setNumBits(uint8_t numBits)
Set new number of bits.
bool isSet(uint8_t bit)
Check if Nth bit is set.
bool setBit(uint8_t bit)
Set Nth bit.
bool clearBit(uint8_t bit)
Clear Nth bit.
bool isAllBitsSet()
Check if all bits are set.
uint8_t _numBits
Definition: cs_BitmaskVarSize.h:58
uint8_t * _bitmask
Bitmask.
Definition: cs_BitmaskVarSize.h:69
uint8_t getNumBytes(uint8_t numBits)
Get number of bytes required to store given number of bits.