]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/base.cpp
a6edcb22c70b4112186b6b0cacc9e738ea4587c4
[user/henk/code/inspircd.git] / src / base.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *     
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 #include "inspircd_config.h"
18 #include "base.h"
19 #include <time.h>
20 #include <map>
21 #include <string>
22 #include "inspircd.h"
23 #include "modules.h"
24 #include "helperfuncs.h"
25
26 extern time_t TIME;
27
28 bool Extensible::Extend(std::string key, char* p)
29 {
30         // only add an item if it doesnt already exist
31         if (this->Extension_Items.find(key) == this->Extension_Items.end())
32         {
33                 this->Extension_Items[key] = p;
34                 log(DEBUG,"Extending object with item %s",key.c_str());
35                 return true;
36         }
37         // item already exists, return false
38         return false;
39 }
40
41 bool Extensible::Shrink(std::string key)
42 {
43         // only attempt to remove a map item that exists
44         if (this->Extension_Items.find(key) != this->Extension_Items.end())
45         {
46                 this->Extension_Items.erase(this->Extension_Items.find(key));
47                 log(DEBUG,"Shrinking object with item %s",key.c_str());
48                 return true;
49         }
50         return false;
51 }
52
53 char* Extensible::GetExt(std::string key)
54 {
55         if (this->Extension_Items.find(key) != this->Extension_Items.end())
56         {
57                 return (this->Extension_Items.find(key))->second;
58         }
59         log(DEBUG,"Cant find item %s",key.c_str());
60         return NULL;
61 }
62