summaryrefslogtreecommitdiff
path: root/src/base.cpp
blob: f1f66bd93d383bee51e801cd26c82a8d85c15ffa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "base.h"
#include "inspircd_config.h" 
#include <time.h>
#include <map>
#include <string>
#include "inspircd.h"
#include "modules.h"

bool Extensible::Extend(std::string key, char* p)
{
	// only add an item if it doesnt already exist
	if (this->Extension_Items.find(key) == this->Extension_Items.end())
	{
		this->Extension_Items[key] = p;
		log(DEBUG,"Extending object with item %s",key.c_str());
		return true;
	}
	// item already exists, return false
	return false;
}

bool Extensible::Shrink(std::string key)
{
	// only attempt to remove a map item that exists
	if (this->Extension_Items.find(key) != this->Extension_Items.end())
	{
		this->Extension_Items.erase(this->Extension_Items.find(key));
		log(DEBUG,"Shrinking object with item %s",key.c_str());
		return true;
	}
	return false;
}

char* Extensible::GetExt(std::string key)
{
	log(DEBUG,"Checking extension items for %s",key.c_str());
	if (this->Extension_Items.find(key) != this->Extension_Items.end())
	{
		log(DEBUG,"Found item %s %s",key.c_str(),(this->Extension_Items.find(key))->second);
		return (this->Extension_Items.find(key))->second;
	}
	log(DEBUG,"Cant find item %s",key.c_str());
	return NULL;
}