diff options
Diffstat (limited to '')
-rw-r--r-- | src/old/xmlnode.cpp (renamed from src/xmlnode.cpp) | 106 |
1 files changed, 32 insertions, 74 deletions
diff --git a/src/xmlnode.cpp b/src/old/xmlnode.cpp index b1ed9a9..96d5850 100644 --- a/src/xmlnode.cpp +++ b/src/old/xmlnode.cpp | |||
@@ -1,53 +1,15 @@ | |||
1 | #include "xmlnode.h" | 1 | #include "xmlnode.h" |
2 | #include "hashfunctionstring.h" | ||
3 | 2 | ||
4 | XmlNode::XmlNode( const char *sName, XmlNode *pParent, const char *sContent ) : | 3 | XmlNode::XmlNode( const Bu::FString &sName, XmlNode *pParent ) : |
5 | hProperties( new HashFunctionString(), 53, false ), | 4 | sName( sName ), |
6 | hChildren( new HashFunctionString(), 53, true ) | 5 | pParent( pParent ) |
7 | { | 6 | { |
8 | this->pParent = pParent; | ||
9 | if( sName != NULL ) | ||
10 | { | ||
11 | setName( sName ); | ||
12 | } | ||
13 | if( sContent != NULL ) | ||
14 | { | ||
15 | this->sPreContent = new std::string( sContent ); | ||
16 | } | ||
17 | else | ||
18 | { | ||
19 | this->sPreContent = NULL; | ||
20 | } | ||
21 | nCurContent = 0; | ||
22 | } | 7 | } |
23 | 8 | ||
24 | XmlNode::~XmlNode() | 9 | XmlNode::~XmlNode() |
25 | { | 10 | { |
26 | for( int j = 0; j < lChildren.getSize(); j++ ) | ||
27 | { | ||
28 | delete (XmlNode *)lChildren[j]; | ||
29 | } | ||
30 | for( int j = 0; j < lPropNames.getSize(); j++ ) | ||
31 | { | ||
32 | delete (std::string *)lPropNames[j]; | ||
33 | } | ||
34 | for( int j = 0; j < lPropValues.getSize(); j++ ) | ||
35 | { | ||
36 | delete (std::string *)lPropValues[j]; | ||
37 | } | ||
38 | for( int j = 0; j < lPostContent.getSize(); j++ ) | ||
39 | { | ||
40 | if( lPostContent[j] != NULL ) | ||
41 | { | ||
42 | delete (std::string *)lPostContent[j]; | ||
43 | } | ||
44 | } | ||
45 | if( sPreContent ) | ||
46 | { | ||
47 | delete sPreContent; | ||
48 | } | ||
49 | } | 11 | } |
50 | 12 | /* | |
51 | void XmlNode::setName( const char *sName ) | 13 | void XmlNode::setName( const char *sName ) |
52 | { | 14 | { |
53 | if( pParent ) | 15 | if( pParent ) |
@@ -120,18 +82,18 @@ const char *XmlNode::getContent( int nIndex ) | |||
120 | } | 82 | } |
121 | 83 | ||
122 | return NULL; | 84 | return NULL; |
123 | } | 85 | }*/ |
124 | 86 | ||
125 | XmlNode *XmlNode::addChild( const char *sName, const char *sContent ) | 87 | XmlNode *XmlNode::addChild( const Bu::FString &sName ) |
126 | { | 88 | { |
127 | return addChild( new XmlNode( sName, this, sContent ) ); | 89 | return addChild( new XmlNode( sName, this ) ); |
128 | } | 90 | } |
129 | 91 | ||
130 | XmlNode *XmlNode::addChild( XmlNode *pNode ) | 92 | XmlNode *XmlNode::addChild( XmlNode *pNode ) |
131 | { | 93 | { |
132 | lChildren.append( pNode ); | 94 | Child c = { typeNode }; |
133 | lPostContent.append( NULL ); | 95 | c.pNode = pNode; |
134 | nCurContent++; | 96 | lChildren.append( c ); |
135 | pNode->pParent = this; | 97 | pNode->pParent = this; |
136 | 98 | ||
137 | return pNode; | 99 | return pNode; |
@@ -142,21 +104,16 @@ XmlNode *XmlNode::getParent() | |||
142 | return pParent; | 104 | return pParent; |
143 | } | 105 | } |
144 | 106 | ||
145 | void XmlNode::addProperty( const char *sName, const char *sValue ) | 107 | void XmlNode::addProperty( const Bu::FString &sName, const Bu::FString &sValue ) |
146 | { | 108 | { |
147 | std::string *pName = new std::string( sName ); | 109 | hProperties.insert( sName, sValue ); |
148 | std::string *pValue = new std::string( sValue ); | ||
149 | |||
150 | hProperties.insert( pName->c_str(), pValue->c_str() ); | ||
151 | lPropNames.append( pName ); | ||
152 | lPropValues.append( pValue ); | ||
153 | } | 110 | } |
154 | 111 | ||
155 | int XmlNode::getNumProperties() | 112 | int XmlNode::getNumProperties() |
156 | { | 113 | { |
157 | return lPropNames.getSize(); | 114 | return hProperties.size(); |
158 | } | 115 | } |
159 | 116 | /* | |
160 | const char *XmlNode::getPropertyName( int nIndex ) | 117 | const char *XmlNode::getPropertyName( int nIndex ) |
161 | { | 118 | { |
162 | std::string *tmp = ((std::string *)lPropNames[nIndex]); | 119 | std::string *tmp = ((std::string *)lPropNames[nIndex]); |
@@ -172,15 +129,12 @@ const char *XmlNode::getProperty( int nIndex ) | |||
172 | return NULL; | 129 | return NULL; |
173 | return tmp->c_str(); | 130 | return tmp->c_str(); |
174 | } | 131 | } |
175 | 132 | */ | |
176 | const char *XmlNode::getProperty( const char *sName ) | 133 | Bu::FString XmlNode::getProperty( const Bu::FString &sName ) |
177 | { | 134 | { |
178 | const char *tmp = (const char *)hProperties[sName]; | 135 | return hProperties[sName]; |
179 | if( tmp == NULL ) | ||
180 | return NULL; | ||
181 | return tmp; | ||
182 | } | 136 | } |
183 | 137 | /* | |
184 | void XmlNode::deleteProperty( int nIndex ) | 138 | void XmlNode::deleteProperty( int nIndex ) |
185 | { | 139 | { |
186 | hProperties.del( ((std::string *)lPropNames[nIndex])->c_str() ); | 140 | hProperties.del( ((std::string *)lPropNames[nIndex])->c_str() ); |
@@ -194,29 +148,33 @@ void XmlNode::deleteProperty( int nIndex ) | |||
194 | 148 | ||
195 | bool XmlNode::hasChildren() | 149 | bool XmlNode::hasChildren() |
196 | { | 150 | { |
197 | return lChildren.getSize()>0; | 151 | return hChildren.getSize()>0; |
198 | } | 152 | }*/ |
199 | 153 | ||
200 | int XmlNode::getNumChildren() | 154 | int XmlNode::getNumChildren() |
201 | { | 155 | { |
202 | return lChildren.getSize(); | 156 | return lChildren.getSize(); |
203 | } | 157 | } |
204 | 158 | /* | |
205 | XmlNode *XmlNode::getChild( int nIndex ) | 159 | XmlNode *XmlNode::getChild( int nIndex ) |
206 | { | 160 | { |
207 | return (XmlNode *)lChildren[nIndex]; | 161 | return (XmlNode *)lChildren[nIndex]; |
208 | } | 162 | } |
209 | 163 | */ | |
210 | XmlNode *XmlNode::getChild( const char *sName, int nSkip ) | 164 | XmlNode *XmlNode::getChild( const Bu::FString &sName, int nSkip ) |
211 | { | 165 | { |
212 | return (XmlNode *)hChildren.get( sName, nSkip ); | 166 | if( !hChildren.has( sName ) ) |
167 | return NULL; | ||
168 | |||
169 | Bu::List<XmlNode *>::iterator i = hChildren[sName]->begin(); | ||
170 | return *i; | ||
213 | } | 171 | } |
214 | 172 | ||
215 | const char *XmlNode::getName() | 173 | Bu::FString XmlNode::getName() |
216 | { | 174 | { |
217 | return sName.c_str(); | 175 | return sName; |
218 | } | 176 | } |
219 | 177 | /* | |
220 | void XmlNode::deleteNode( int nIndex, const char *sReplacementText ) | 178 | void XmlNode::deleteNode( int nIndex, const char *sReplacementText ) |
221 | { | 179 | { |
222 | XmlNode *xRet = detatchNode( nIndex, sReplacementText ); | 180 | XmlNode *xRet = detatchNode( nIndex, sReplacementText ); |
@@ -442,4 +400,4 @@ void XmlNode::deleteNodeKeepChildren( int nIndex ) | |||
442 | void XmlNode::replaceNodeWithChildren( int nIndex, XmlNode *pNewNode ) | 400 | void XmlNode::replaceNodeWithChildren( int nIndex, XmlNode *pNewNode ) |
443 | { | 401 | { |
444 | } | 402 | } |
445 | 403 | */ | |