]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/base.cpp
Remove unneeded Extensible inheritance and remove "age" field from classbase
[user/henk/code/inspircd.git] / src / base.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 /* $Core */
15
16 #include "inspircd_config.h"
17 #include "base.h"
18 #include <time.h>
19 #include "inspircd.h"
20
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};
23
24 classbase::classbase()
25 {
26 }
27
28 bool Extensible::Shrink(const std::string &key)
29 {
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
33          */
34         return this->Extension_Items.erase(key);
35 }
36
37 void Extensible::GetExtList(std::deque<std::string> &list)
38 {
39         for (ExtensibleStore::iterator u = Extension_Items.begin(); u != Extension_Items.end(); u++)
40         {
41                 list.push_back(u->first);
42         }
43 }
44
45 void BoolSet::Set(int number)
46 {
47         this->bits |= bitfields[number];
48 }
49
50 void BoolSet::Unset(int number)
51 {
52         this->bits &= inverted_bitfields[number];
53 }
54
55 void BoolSet::Invert(int number)
56 {
57         this->bits ^= bitfields[number];
58 }
59
60 bool BoolSet::Get(int number)
61 {
62         return ((this->bits | bitfields[number]) > 0);
63 }
64
65 bool BoolSet::operator==(BoolSet other)
66 {
67         return (this->bits == other.bits);
68 }
69
70 BoolSet BoolSet::operator|(BoolSet other)
71 {
72         BoolSet x(this->bits | other.bits);
73         return x;
74 }
75
76 BoolSet BoolSet::operator&(BoolSet other)
77 {
78         BoolSet x(this->bits & other.bits);
79         return x;
80 }
81
82 BoolSet::BoolSet()
83 {
84         this->bits = 0;
85 }
86
87 BoolSet::BoolSet(char bitmask)
88 {
89         this->bits = bitmask;
90 }
91
92 bool BoolSet::operator=(BoolSet other)
93 {
94         this->bits = other.bits;
95         return true;
96 }