base.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "inspircd_config.h"
00017 #include "base.h"
00018 #include <time.h>
00019 #include "inspircd.h"
00020
00021 const int bitfields[] = {1,2,4,8,16,32,64,128};
00022 const int inverted_bitfields[] = {~1,~2,~4,~8,~16,~32,~64,~128};
00023
00024 classbase::classbase()
00025 {
00026 this->age = time(NULL);
00027 }
00028
00029 bool Extensible::Shrink(const std::string &key)
00030 {
00031
00032
00033
00034
00035 return this->Extension_Items.erase(key);
00036 }
00037
00038 void Extensible::GetExtList(std::deque<std::string> &list)
00039 {
00040 for (ExtensibleStore::iterator u = Extension_Items.begin(); u != Extension_Items.end(); u++)
00041 {
00042 list.push_back(u->first);
00043 }
00044 }
00045
00046 void BoolSet::Set(int number)
00047 {
00048 this->bits |= bitfields[number];
00049 }
00050
00051 void BoolSet::Unset(int number)
00052 {
00053 this->bits &= inverted_bitfields[number];
00054 }
00055
00056 void BoolSet::Invert(int number)
00057 {
00058 this->bits ^= bitfields[number];
00059 }
00060
00061 bool BoolSet::Get(int number)
00062 {
00063 return ((this->bits | bitfields[number]) > 0);
00064 }
00065
00066 bool BoolSet::operator==(BoolSet other)
00067 {
00068 return (this->bits == other.bits);
00069 }
00070
00071 BoolSet BoolSet::operator|(BoolSet other)
00072 {
00073 BoolSet x(this->bits | other.bits);
00074 return x;
00075 }
00076
00077 BoolSet BoolSet::operator&(BoolSet other)
00078 {
00079 BoolSet x(this->bits & other.bits);
00080 return x;
00081 }
00082
00083 BoolSet::BoolSet()
00084 {
00085 this->bits = 0;
00086 }
00087
00088 BoolSet::BoolSet(char bitmask)
00089 {
00090 this->bits = bitmask;
00091 }
00092
00093 bool BoolSet::operator=(BoolSet other)
00094 {
00095 this->bits = other.bits;
00096 return true;
00097 }