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