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 /* $Core: libIRCDbase */
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()
26 this->age = time(NULL);
29 bool Extensible::Shrink(const std::string &key)
31 /* map::size_type map::erase( const key_type& key );
32 * returns the number of elements removed, std::map
33 * is single-associative so this should only be 0 or 1
35 return this->Extension_Items.erase(key);
38 void Extensible::GetExtList(std::deque<std::string> &list)
40 for (ExtensibleStore::iterator u = Extension_Items.begin(); u != Extension_Items.end(); u++)
42 list.push_back(u->first);
46 void BoolSet::Set(int number)
48 this->bits |= bitfields[number];
51 void BoolSet::Unset(int number)
53 this->bits &= inverted_bitfields[number];
56 void BoolSet::Invert(int number)
58 this->bits ^= bitfields[number];
61 bool BoolSet::Get(int number)
63 return ((this->bits | bitfields[number]) > 0);
66 bool BoolSet::operator==(BoolSet other)
68 return (this->bits == other.bits);
71 BoolSet BoolSet::operator|(BoolSet other)
73 BoolSet x(this->bits | other.bits);
77 BoolSet BoolSet::operator&(BoolSet other)
79 BoolSet x(this->bits & other.bits);
88 BoolSet::BoolSet(char bitmask)
93 bool BoolSet::operator=(BoolSet other)
95 this->bits = other.bits;