summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-05-30 05:06:12 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-05-30 05:06:12 +0000
commit02c18fcb826e63ce7c654d44e9f0afe1eafa7a64 (patch)
tree4b664cea541657858cdccb4a275092cba62d0960 /src
parent571542d1f0fad81963afb81640118dc7d06547ba (diff)
Added BoolSet utility class
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1564 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/base.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/base.cpp b/src/base.cpp
index a6edcb22c..81aea40e2 100644
--- a/src/base.cpp
+++ b/src/base.cpp
@@ -60,3 +60,55 @@ char* Extensible::GetExt(std::string key)
return NULL;
}
+void BoolSet::Set(int number)
+{
+ this->bits |= bitfields[number];
+}
+
+void BoolSet::Unset(int number)
+{
+ this->bits &= inverted_bitfields[number];
+}
+
+void BoolSet::Invert(int number)
+{
+ this->bits ^= bitfields[number];
+}
+
+bool BoolSet::Get(int number)
+{
+ return ((this->bits | bitfields[number]) > 0);
+}
+
+bool BoolSet::operator==(BoolSet other)
+{
+ return (this->bits == other.bits);
+}
+
+BoolSet BoolSet::operator|(BoolSet other)
+{
+ BoolSet x(this->bits | other.bits);
+ return x;
+}
+
+BoolSet BoolSet::operator&(BoolSet other)
+{
+ BoolSet x(this->bits & other.bits);
+ return x;
+}
+
+BoolSet::BoolSet()
+{
+ this->bits = 0;
+}
+
+BoolSet::BoolSet(char bitmask)
+{
+ this->bits = bitmask;
+}
+
+bool operator=(BoolSet other)
+{
+ this->bits = other.bits;
+ return true;
+}