1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
17 #include "inspircd_config.h"
25 #include "helperfuncs.h"
27 const int bitfields[] = {1,2,4,8,16,32,64,128};
28 const int inverted_bitfields[] = {~1,~2,~4,~8,~16,~32,~64,~128};
30 bool Extensible::Shrink(const std::string &key)
32 /* map::size_type map::erase( const key_type& key );
33 * returns the number of elements removed, std::map
34 * is single-associative so this should only be 0 or 1
36 if(this->Extension_Items.erase(key))
38 log(DEBUG, "Shrinking object with item %s",key.c_str());
43 log(DEBUG, "Tried to shrink object with item %s but no items removed", key.c_str());
48 void Extensible::GetExtList(std::deque<std::string> &list)
50 for (ExtensibleStore::iterator u = Extension_Items.begin(); u != Extension_Items.end(); u++)
52 list.push_back(u->first);
56 void BoolSet::Set(int number)
58 this->bits |= bitfields[number];
61 void BoolSet::Unset(int number)
63 this->bits &= inverted_bitfields[number];
66 void BoolSet::Invert(int number)
68 this->bits ^= bitfields[number];
71 bool BoolSet::Get(int number)
73 return ((this->bits | bitfields[number]) > 0);
76 bool BoolSet::operator==(BoolSet other)
78 return (this->bits == other.bits);
81 BoolSet BoolSet::operator|(BoolSet other)
83 BoolSet x(this->bits | other.bits);
87 BoolSet BoolSet::operator&(BoolSet other)
89 BoolSet x(this->bits & other.bits);
98 BoolSet::BoolSet(char bitmask)
100 this->bits = bitmask;
103 bool BoolSet::operator=(BoolSet other)
105 this->bits = other.bits;