-
Notifications
You must be signed in to change notification settings - Fork 1
/
winxedxx_namespace.cxx
65 lines (50 loc) · 1.37 KB
/
winxedxx_namespace.cxx
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// winxedxx_namespace.cxx
// (C) 2012 Julián Albo "NotFound"
#include "winxedxx_namespace.h"
namespace WinxedXX
{
typedef std::map<std::string, WxxObjectPtr> symbols_t;
typedef std::map<std::string, WxxNamespace *> childs_t;
WxxNamespace::WxxNamespace() :
parentns(0)
{
}
WxxNamespace::WxxNamespace(const std::string &name, WxxNamespace *parent) :
parentns(parent)
{
}
WxxObjectPtr WxxNamespace::get(const std::string &name)
{
symbols_t::const_iterator it = symbols.find(name);
if (it == symbols.end())
return winxedxxnull;
return WxxObjectPtr(it->second);
}
WxxNamespace &WxxNamespace::childNamespace(const std::string &name)
{
childs_t::const_iterator it = childs.find(name);
if (it == childs.end()) {
WxxNamespace *child = new WxxNamespace(name, this);
childs[name] = child;
return *child;
}
return *it->second;
}
void WxxNamespace::set(const std::string &name, const WxxObjectPtr &value)
{
symbols[name] = value;
}
//**************************************************************
class WxxRootNamespace : WxxNamespace
{
friend WxxNamespace &getRootNamespace();
};
static WxxRootNamespace *rootnamespace = 0;
WxxNamespace &getRootNamespace()
{
if (! rootnamespace)
rootnamespace = new WxxRootNamespace();
return *rootnamespace;
}
} // namespace WinxedXX
// End of winxedxx_namespace.cxx