1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
14 #include "inspircd_config.h"
19 const int bitfields[] = {1,2,4,8,16,32,64,128};
20 const int inverted_bitfields[] = {~1,~2,~4,~8,~16,~32,~64,~128};
22 classbase::classbase()
24 this->age = time(NULL);
27 bool Extensible::Shrink(const std::string &key)
29 /* map::size_type map::erase( const key_type& key );
30 * returns the number of elements removed, std::map
31 * is single-associative so this should only be 0 or 1
33 return this->Extension_Items.erase(key);
36 void Extensible::GetExtList(std::deque<std::string> &list)
38 for (ExtensibleStore::iterator u = Extension_Items.begin(); u != Extension_Items.end(); u++)
40 list.push_back(u->first);
44 void BoolSet::Set(int number)
46 this->bits |= bitfields[number];
49 void BoolSet::Unset(int number)
51 this->bits &= inverted_bitfields[number];
54 void BoolSet::Invert(int number)
56 this->bits ^= bitfields[number];
59 bool BoolSet::Get(int number)
61 return ((this->bits | bitfields[number]) > 0);
64 bool BoolSet::operator==(BoolSet other)
66 return (this->bits == other.bits);
69 BoolSet BoolSet::operator|(BoolSet other)
71 BoolSet x(this->bits | other.bits);
75 BoolSet BoolSet::operator&(BoolSet other)
77 BoolSet x(this->bits & other.bits);
86 BoolSet::BoolSet(char bitmask)
91 bool BoolSet::operator=(BoolSet other)
93 this->bits = other.bits;