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