summaryrefslogtreecommitdiff
path: root/src/tafnode.cpp
blob: b9a4a24300f18fa6926b50fd151488b3a175e81b (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
#include "tafnode.h"

Bu::TafNode::TafNode()
{
}

Bu::TafNode::~TafNode()
{
	//printf("Entering Bu::TafNode::~TafNode() \"%s\"\n", sName.getStr() );
	for( NodeHash::iterator i = hChildren.begin(); i != hChildren.end(); i++ )
	{
		NodeList &l = i.getValue();
		for( NodeList::iterator k = l.begin(); k != l.end(); k++ )
		{
			//printf("deleting:  [%08X] %s\n", *k, "" );//(*k)->getName().getStr() );
			delete (*k);
		}
	}
}

void Bu::TafNode::setProperty( Bu::FString sName, Bu::FString sValue )
{
	if( !hProp.has( sName ) )
	{
		hProp.insert( sName, PropList() );
	}

	hProp.get( sName ).append( sValue );
}

void Bu::TafNode::addChild( TafNode *pNode )
{
	if( !hChildren.has( pNode->getName() ) )
	{
		hChildren.insert( pNode->getName(), NodeList() );
	}

	//printf("Appending \"%s\"\n", pNode->getName().getStr() );
	hChildren.get( pNode->getName() ).append( pNode );
	//printf("[%08X]\n", hChildren.get( pNode->getName() ).last() );
}

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();
}

void Bu::TafNode::setName( const Bu::FString &sName )
{
	this->sName = sName;
}

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