aboutsummaryrefslogtreecommitdiff
path: root/src/tafnode.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tafnode.cpp')
-rw-r--r--src/tafnode.cpp195
1 files changed, 0 insertions, 195 deletions
diff --git a/src/tafnode.cpp b/src/tafnode.cpp
index 8ea2e95..e7711fb 100644
--- a/src/tafnode.cpp
+++ b/src/tafnode.cpp
@@ -23,198 +23,3 @@ Bu::TafNode::NodeType Bu::TafNode::getType() const
23 return eType; 23 return eType;
24} 24}
25 25
26Bu::TafGroup::TafGroup( const Bu::FString &sName ) :
27 TafNode( typeGroup ),
28 sName( sName )
29{
30}
31
32Bu::TafGroup::~TafGroup()
33{
34 for( NodeList::iterator i = lChildren.begin(); i != lChildren.end(); i++ )
35 {
36 delete (*i);
37 }
38}
39
40const Bu::FString &Bu::TafGroup::getName() const
41{
42 return sName;
43}
44
45void Bu::TafGroup::setName( const Bu::FString &sName )
46{
47 this->sName = sName;
48}
49
50Bu::TafNode *Bu::TafGroup::addChild( Bu::TafNode *pNode )
51{
52 switch( pNode->getType() )
53 {
54 case typeGroup:
55 addChild( (Bu::TafGroup *)pNode );
56 break;
57
58 case typeProperty:
59 addChild( (Bu::TafProperty *)pNode );
60 break;
61
62 case typeComment:
63 addChild( (Bu::TafComment *)pNode );
64 break;
65 }
66
67 return pNode;
68}
69
70Bu::TafGroup *Bu::TafGroup::addChild( TafGroup *pNode )
71{
72 TafGroup *pGroup = (TafGroup *)pNode;
73 if( !hChildren.has( pGroup->getName() ) )
74 hChildren.insert( pGroup->getName(), GroupList() );
75 hChildren.get( pGroup->getName() ).append( pGroup );
76 lChildren.append( pNode );
77 return pNode;
78}
79
80Bu::TafProperty *Bu::TafGroup::addChild( TafProperty *pNode )
81{
82 TafProperty *pProperty = (TafProperty *)pNode;
83 if( !hProp.has( pProperty->getName() ) )
84 hProp.insert( pProperty->getName(), PropList() );
85 hProp.get( pProperty->getName() ).append( pProperty->getValue() );
86 lChildren.append( pNode );
87 return pNode;
88}
89
90Bu::TafComment *Bu::TafGroup::addChild( TafComment *pNode )
91{
92 lChildren.append( pNode );
93 return pNode;
94}
95
96Bu::TafGroup *Bu::TafGroup::addGroup( const Bu::FString &sName )
97{
98 return addChild( new TafGroup( sName ) );
99}
100
101Bu::TafProperty *Bu::TafGroup::addProperty(
102 const Bu::FString &sName, const Bu::FString &sValue )
103{
104 return addChild( new TafProperty( sName, sValue ) );
105}
106
107bool Bu::TafGroup::hasChild( const Bu::FString &sName ) const
108{
109 return hChildren.has( sName );
110}
111
112const Bu::TafGroup::GroupList &Bu::TafGroup::getChildren( const Bu::FString &sName ) const
113{
114 try {
115 return hChildren.get( sName );
116 } catch( Bu::HashException &e )
117 {
118 throw Bu::TafException("No children of group \"%s\" match \"%s\".",
119 this->sName.getStr(), sName.getStr() );
120 }
121}
122
123const Bu::TafGroup::NodeList &Bu::TafGroup::getChildren() const
124{
125 return lChildren;
126}
127
128const Bu::TafGroup *Bu::TafGroup::getChild( const Bu::FString &sName ) const
129{
130 try {
131 return hChildren.get( sName ).first();
132 } catch( Bu::HashException &e )
133 {
134 throw Bu::TafException("No children of group \"%s\" match \"%s\".",
135 this->sName.getStr(), sName.getStr() );
136 }
137}
138
139bool Bu::TafGroup::hasProperty( const Bu::FString &sName ) const
140{
141 return hProp.has( sName );
142}
143
144const Bu::TafGroup::PropList &Bu::TafGroup::getProperties( const Bu::FString &sName ) const
145{
146 try {
147 return hProp.get( sName );
148 } catch( Bu::HashException &e )
149 {
150 throw Bu::TafException("No properties of group \"%s\" match \"%s\".",
151 this->sName.getStr(), sName.getStr() );
152 }
153}
154
155const Bu::FString &Bu::TafGroup::getProperty( const Bu::FString &sName ) const
156{
157 try {
158 return hProp.get( sName ).first();
159 } catch( Bu::HashException &e )
160 {
161 throw Bu::TafException("No properties of group \"%s\" match \"%s\".",
162 this->sName.getStr(), sName.getStr() );
163 }
164}
165
166const Bu::FString &Bu::TafGroup::getProperty( const Bu::FString &sName,
167 const Bu::FString &sDef ) const
168{
169 try
170 {
171 return hProp.get( sName ).first();
172 }
173 catch( Bu::HashException &e )
174 {
175 return sDef;
176 }
177}
178
179Bu::TafProperty::TafProperty( const Bu::FString &sName, const Bu::FString &sValue ) :
180 TafNode( typeProperty ),
181 sName( sName ),
182 sValue( sValue )
183{
184}
185
186Bu::TafProperty::~TafProperty()
187{
188}
189
190const Bu::FString &Bu::TafProperty::getName() const
191{
192 return sName;
193}
194
195const Bu::FString &Bu::TafProperty::getValue() const
196{
197 return sValue;
198}
199
200Bu::TafComment::TafComment( const Bu::FString &sText, bool bEOL ) :
201 TafNode( typeComment ),
202 sText( sText ),
203 bEOL( bEOL )
204{
205}
206
207Bu::TafComment::~TafComment()
208{
209}
210
211const Bu::FString &Bu::TafComment::getText() const
212{
213 return sText;
214}
215
216bool Bu::TafComment::isEOLStyle() const
217{
218 return bEOL;
219}
220