aboutsummaryrefslogtreecommitdiff
path: root/src/tafnode.cpp
blob: 7e171c9afca7e2ef0e81cf395fc0b2f3f90ee635 (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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#include "tafnode.h"

Bu::TafNode::TafNode( NodeType eType ) :
	eType( eType )
{
}

Bu::TafNode::~TafNode()
{
}

const Bu::TafNode::NodeType Bu::TafNode::getType() const
{
	return eType;
}

/*
const Bu::TafNode::PropList &Bu::TafNode::getProperties( const Bu::FString &sName ) const
{
	return hProp.get( sName );
}

const Bu::TafNode::NodeList &Bu::TafNode::getChildren( const Bu::FString &sName ) const
{
	return hChildren.get( sName );
}

const Bu::FString &Bu::TafNode::getProperty( const Bu::FString &sName ) const
{
	return getProperties( sName ).first();
}

const Bu::TafNode *Bu::TafNode::getChild( const Bu::FString &sName ) const
{
	return getChildren( sName ).first();
}
*/

Bu::TafGroup::TafGroup( const Bu::FString &sName ) :
	TafNode( typeGroup ),
	sName( sName )
{
}

Bu::TafGroup::~TafGroup()
{
	//printf("Entering Bu::TafNode::~TafNode() \"%s\"\n", sName.getStr() );
	for( NodeList::iterator i = lChildren.begin(); i != lChildren.end(); i++ )
	{
		delete (*i);
	}
}

const Bu::FString &Bu::TafGroup::getName() const
{
	return sName;
}

Bu::TafNode *Bu::TafGroup::addChild( Bu::TafNode *pNode )
{
	switch( pNode->getType() )
	{
		case typeGroup:
			{
				TafGroup *pGroup = (TafGroup *)pNode;
				if( !hChildren.has( pGroup->getName() ) )
					hChildren.insert( pGroup->getName(), GroupList() );
				hChildren.get( pGroup->getName() ).append( pGroup );
			}
			break;

		case typeProperty:
			{
				TafProperty *pProperty = (TafProperty *)pNode;
				if( !hProp.has( pProperty->getName() ) )
					hProp.insert( pProperty->getName(), PropList() );
				hProp.get( pProperty->getName() ).append( pProperty->getValue() );
			}
			break;

		case typeComment:
			break;
	}

	lChildren.append( pNode );

	return pNode;
}

const Bu::TafGroup::GroupList &Bu::TafGroup::getChildren( const Bu::FString &sName ) const
{
	return hChildren.get( sName );
}

const Bu::TafGroup::NodeList &Bu::TafGroup::getChildren() const
{
	return lChildren;
}

const Bu::TafGroup *Bu::TafGroup::getChild( const Bu::FString &sName ) const
{
	return hChildren.get( sName ).first();
}

const Bu::TafGroup::PropList &Bu::TafGroup::getProperties( const Bu::FString &sName ) const
{
	return hProp.get( sName );
}

const Bu::FString &Bu::TafGroup::getProperty( const Bu::FString &sName ) const
{
	return hProp.get( sName ).first();
}

Bu::TafProperty::TafProperty( const Bu::FString &sName, const Bu::FString &sValue ) :
	TafNode( typeProperty ),
	sName( sName ),
	sValue( sValue )
{
}

Bu::TafProperty::~TafProperty()
{
}

const Bu::FString &Bu::TafProperty::getName() const
{
	return sName;
}

const Bu::FString &Bu::TafProperty::getValue() const
{
	return sValue;
}

Bu::TafComment::TafComment( const Bu::FString &sText ) :
	TafNode( typeComment ),
	sText( sText )
{
}

Bu::TafComment::~TafComment()
{
}

const Bu::FString &Bu::TafComment::getText() const
{
	return sText;
}