]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/base.cpp
9cecc71f23e77f4b391d7cecbcd5b794aca4f174
[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 "base.h"
18 #include "inspircd_config.h" 
19 #include <time.h>
20 #include <map>
21 #include <string>
22 #include "inspircd.h"
23 #include "modules.h"
24
25 extern time_t TIME;
26
27 bool Extensible::Extend(std::string key, char* p)
28 {
29         // only add an item if it doesnt already exist
30         if (this->Extension_Items.find(key) == this->Extension_Items.end())
31         {
32                 this->Extension_Items[key] = p;
33                 log(DEBUG,"Extending object with item %s",key.c_str());
34                 return true;
35         }
36         // item already exists, return false
37         return false;
38 }
39
40 bool Extensible::Shrink(std::string key)
41 {
42         // only attempt to remove a map item that exists
43         if (this->Extension_Items.find(key) != this->Extension_Items.end())
44         {
45                 this->Extension_Items.erase(this->Extension_Items.find(key));
46                 log(DEBUG,"Shrinking object with item %s",key.c_str());
47                 return true;
48         }
49         return false;
50 }
51
52 char* Extensible::GetExt(std::string key)
53 {
54         if (this->Extension_Items.find(key) != this->Extension_Items.end())
55         {
56                 return (this->Extension_Items.find(key))->second;
57         }
58         log(DEBUG,"Cant find item %s",key.c_str());
59         return NULL;
60 }
61