-
Notifications
You must be signed in to change notification settings - Fork 18
/
WzNode.cpp
112 lines (94 loc) · 1.79 KB
/
WzNode.cpp
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include <assert.h>
#include "WzNode.h"
//////////////////////////////////////////////////////////////////////////
WzNode::WzNode() : m_pParent(0) {}
WzNode::~WzNode() {}
void WzNode::AddChild(const std::wstring & name, WzNode * node)
{
assert(node);
m_Childs[name].push_back(node);
node->m_pParent = this;
}
const WzNodeMap & WzNode::GetChilds() const
{
return m_Childs;
}
void WzNode::Delete()
{
delete this;
}
void WzNode::Free()
{
for(WzNodeMap::iterator it = m_Childs.begin();
it != m_Childs.end();
it++)
{
for(WzNodeList::iterator cit = it->second.begin();
cit != it->second.end();
cit++)
{
(*cit)->Free();
}
}
Delete();
}
bool WzNode::FreeChild(const std::wstring & name)
{
WzNodeMap::iterator it = m_Childs.find(name);
if(it != m_Childs.end())
{
for(WzNodeList::iterator cit = it->second.begin();
cit != it->second.end();
cit++)
{
(*cit)->Free();
}
m_Childs.erase(it);
return true;
}
return false;
}
void WzNode::FreeChilds()
{
for(WzNodeMap::iterator it = m_Childs.begin();
it != m_Childs.end();
it++)
{
for(WzNodeList::iterator cit = it->second.begin();
cit != it->second.end();
cit++)
{
(*cit)->Free();
}
}
m_Childs.clear();
}
WzNode * WzNode::GetParent()
{
return m_pParent;
}
WzNode * WzNode::New()
{
return new WzNode();
}
//////////////////////////////////////////////////////////////////////////
WzDirectory::WzDirectory() : m_bImage(false), m_Size(0), m_Checksum(0), m_Offset(0) {}
void WzDirectory::Set(bool img, int size ,int checksum ,unsigned int offset)
{
m_bImage = img;
m_Size = size;
m_Checksum = checksum;
m_Offset = offset;
}
unsigned int WzDirectory::GetOffset() const
{
return m_Offset;
}
bool WzDirectory::IsImage() const
{
return m_bImage;
}
WzDirectory * WzDirectory::New()
{
return new WzDirectory();
}