1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 #include "inspircd_config.h"
21 const int bitfields[] = {1,2,4,8,16,32,64,128};
22 const int inverted_bitfields[] = {~1,~2,~4,~8,~16,~32,~64,~128};
24 classbase::classbase()
28 bool Extensible::Shrink(const std::string &key)
30 /* map::size_type map::erase( const key_type& key );
31 * returns the number of elements removed, std::map
32 * is single-associative so this should only be 0 or 1
34 return this->Extension_Items.erase(key);
37 void Extensible::GetExtList(std::deque<std::string> &list)
39 for (ExtensibleStore::iterator u = Extension_Items.begin(); u != Extension_Items.end(); u++)
41 list.push_back(u->first);
45 void BoolSet::Set(int number)
47 this->bits |= bitfields[number];
50 void BoolSet::Unset(int number)
52 this->bits &= inverted_bitfields[number];
55 void BoolSet::Invert(int number)
57 this->bits ^= bitfields[number];
60 bool BoolSet::Get(int number)
62 return ((this->bits | bitfields[number]) > 0);
65 bool BoolSet::operator==(BoolSet other)
67 return (this->bits == other.bits);
70 BoolSet BoolSet::operator|(BoolSet other)
72 BoolSet x(this->bits | other.bits);
76 BoolSet BoolSet::operator&(BoolSet other)
78 BoolSet x(this->bits & other.bits);
87 BoolSet::BoolSet(char bitmask)
92 bool BoolSet::operator=(BoolSet other)
94 this->bits = other.bits;