aboutsummaryrefslogtreecommitdiff
path: root/src/util.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.cc')
-rw-r--r--src/util.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/util.cc b/src/util.cc
index 0982cd7..4a3523b 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -167,6 +167,31 @@ char *findLast(char *s, char c){
return Last;
}
+// BitSet Utility
+// =============================================================================
+bool CheckBitIndex(int BitSetBytes, int Index){
+ return Index >= 0 && Index < (BitSetBytes * 8);
+}
+
+bool CheckBit(uint8 *BitSet, int Index){
+ int ByteIndex = (int)(Index / 8);
+ uint8 BitMask = (uint8)(1 << (Index % 8));
+ return (BitSet[ByteIndex] & BitMask) != 0;
+}
+
+void SetBit(uint8 *BitSet, int Index){
+ int ByteIndex = (int)(Index / 8);
+ uint8 BitMask = (uint8)(1 << (Index % 8));
+ BitSet[ByteIndex] |= BitMask;
+}
+
+void ClearBit(uint8 *BitSet, int Index){
+ int ByteIndex = (int)(Index / 8);
+ uint8 BitMask = (uint8)(1 << (Index % 8));
+ BitSet[ByteIndex] &= ~BitMask;
+}
+
+
// TReadStream
// =============================================================================
bool TReadStream::readFlag(void){