]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/base.cpp
7e545694bc9f5aa988ef94060f051dc52e905fef
[user/henk/code/inspircd.git] / src / base.cpp
1 #include "base.h"
2 #include "inspircd_config.h" 
3 #include <time.h>
4 #include <map>
5 #include <string>
6
7 bool Extensible::Extend(std::string key, VoidPointer p)
8 {
9         // only add an item if it doesnt already exist
10         if (this->Extension_Items.find(key) == this->Extension_Items.end())
11         {
12                 this->Extension_Items[key] == p;
13                 return true;
14         }
15         // item already exists, return false
16         return false;
17 }
18
19 bool Extensible::Shrink(std::string key)
20 {
21         // only attempt to remove a map item that exists
22         if (this->Extension_Items.find(key) != this->Extension_Items.end())
23         {
24                 this->Extension_Items.erase(this->Extension_Items.find(key));
25                 return true;
26         }
27         return false;
28 }
29
30 VoidPointer Extensible::GetExt(std::string key)
31 {
32         if (this->Extension_Items.find(key) != this->Extension_Items.end())
33         {
34                 return (this->Extension_Items.find(key))->second;
35         }
36         return NULL;
37 }
38