aboutsummaryrefslogtreecommitdiff
path: root/src/tafnode.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tafnode.cpp')
-rw-r--r--src/tafnode.cpp165
1 files changed, 165 insertions, 0 deletions
diff --git a/src/tafnode.cpp b/src/tafnode.cpp
new file mode 100644
index 0000000..53b782e
--- /dev/null
+++ b/src/tafnode.cpp
@@ -0,0 +1,165 @@
1#include "tafnode.h"
2
3Bu::TafNode::TafNode( NodeType eType ) :
4 eType( eType )
5{
6}
7
8Bu::TafNode::~TafNode()
9{
10}
11
12const Bu::TafNode::NodeType Bu::TafNode::getType() const
13{
14 return eType;
15}
16
17/*
18const Bu::TafNode::PropList &Bu::TafNode::getProperties( const Bu::FString &sName ) const
19{
20 return hProp.get( sName );
21}
22
23const Bu::TafNode::NodeList &Bu::TafNode::getChildren( const Bu::FString &sName ) const
24{
25 return hChildren.get( sName );
26}
27
28const Bu::FString &Bu::TafNode::getProperty( const Bu::FString &sName ) const
29{
30 return getProperties( sName ).first();
31}
32
33const Bu::TafNode *Bu::TafNode::getChild( const Bu::FString &sName ) const
34{
35 return getChildren( sName ).first();
36}
37*/
38
39Bu::TafGroup::TafGroup( const Bu::FString &sName ) :
40 TafNode( typeGroup ),
41 sName( sName )
42{
43}
44
45Bu::TafGroup::~TafGroup()
46{
47 //printf("Entering Bu::TafNode::~TafNode() \"%s\"\n", sName.getStr() );
48 for( NodeList::iterator i = lChildren.begin(); i != lChildren.end(); i++ )
49 {
50 delete (*i);
51 }
52}
53
54const Bu::FString &Bu::TafGroup::getName() const
55{
56 return sName;
57}
58
59Bu::TafNode *Bu::TafGroup::addChild( Bu::TafNode *pNode )
60{
61 switch( pNode->getType() )
62 {
63 case typeGroup:
64 addChild( (Bu::TafGroup *)pNode );
65 break;
66
67 case typeProperty:
68 addChild( (Bu::TafProperty *)pNode );
69 break;
70
71 case typeComment:
72 addChild( (Bu::TafComment *)pNode );
73 break;
74 }
75
76 return pNode;
77}
78
79Bu::TafGroup *Bu::TafGroup::addChild( TafGroup *pNode )
80{
81 TafGroup *pGroup = (TafGroup *)pNode;
82 if( !hChildren.has( pGroup->getName() ) )
83 hChildren.insert( pGroup->getName(), GroupList() );
84 hChildren.get( pGroup->getName() ).append( pGroup );
85 lChildren.append( pNode );
86 return pNode;
87}
88
89Bu::TafProperty *Bu::TafGroup::addChild( TafProperty *pNode )
90{
91 TafProperty *pProperty = (TafProperty *)pNode;
92 if( !hProp.has( pProperty->getName() ) )
93 hProp.insert( pProperty->getName(), PropList() );
94 hProp.get( pProperty->getName() ).append( pProperty->getValue() );
95 lChildren.append( pNode );
96 return pNode;
97}
98
99Bu::TafComment *Bu::TafGroup::addChild( TafComment *pNode )
100{
101 lChildren.append( pNode );
102 return pNode;
103}
104
105const Bu::TafGroup::GroupList &Bu::TafGroup::getChildren( const Bu::FString &sName ) const
106{
107 return hChildren.get( sName );
108}
109
110const Bu::TafGroup::NodeList &Bu::TafGroup::getChildren() const
111{
112 return lChildren;
113}
114
115const Bu::TafGroup *Bu::TafGroup::getChild( const Bu::FString &sName ) const
116{
117 return hChildren.get( sName ).first();
118}
119
120const Bu::TafGroup::PropList &Bu::TafGroup::getProperties( const Bu::FString &sName ) const
121{
122 return hProp.get( sName );
123}
124
125const Bu::FString &Bu::TafGroup::getProperty( const Bu::FString &sName ) const
126{
127 return hProp.get( sName ).first();
128}
129
130Bu::TafProperty::TafProperty( const Bu::FString &sName, const Bu::FString &sValue ) :
131 TafNode( typeProperty ),
132 sName( sName ),
133 sValue( sValue )
134{
135}
136
137Bu::TafProperty::~TafProperty()
138{
139}
140
141const Bu::FString &Bu::TafProperty::getName() const
142{
143 return sName;
144}
145
146const Bu::FString &Bu::TafProperty::getValue() const
147{
148 return sValue;
149}
150
151Bu::TafComment::TafComment( const Bu::FString &sText ) :
152 TafNode( typeComment ),
153 sText( sText )
154{
155}
156
157Bu::TafComment::~TafComment()
158{
159}
160
161const Bu::FString &Bu::TafComment::getText() const
162{
163 return sText;
164}
165