Rev 1311 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1311 | Rev 1314 | ||
|---|---|---|---|
| Line 32... | Line 32... | ||
| 32 | this->parse(filename, xmlData); |
32 | this->parse(filename, xmlData); |
| 33 | } |
33 | } |
| 34 | 34 | ||
| 35 | void Node::load(string filename) |
35 | void Node::load(string filename) |
| 36 | { |
36 | { |
| 37 | this->parse(filename, |
37 | this->parse(filename, file::get_contents(filename)); |
| 38 | } |
38 | } |
| 39 | 39 | ||
| 40 | void Node::parse(string filename, string xmlData) |
40 | void Node::parse(string filename, string xmlData) |
| 41 | { |
41 | { |
| 42 | char c; |
42 | char c; |
| Line 164... | Line 164... | ||
| 164 | { |
164 | { |
| 165 | attributesMatch = true; |
165 | attributesMatch = true; |
| 166 | 166 | ||
| 167 | for (attributeList::iterator iter = attributes.begin(); iter != attributes.end(); iter++) |
167 | for (attributeList::iterator iter = attributes.begin(); iter != attributes.end(); iter++) |
| 168 | { |
168 | { |
| 169 | //LOG.debug("#attributes = " + |
169 | //LOG.debug("#attributes = " + convert::int2string(this->myChildren[n].attributes().size())); |
| 170 | //LOG.debug("iter->first = " + iter->first); |
170 | //LOG.debug("iter->first = " + iter->first); |
| 171 | //LOG.debug("iter->second = " + iter->second); |
171 | //LOG.debug("iter->second = " + iter->second); |
| 172 | //LOG.debug("this->myChildren[n][iter->first] = " + this->myChildren[n][iter->first]); |
172 | //LOG.debug("this->myChildren[n][iter->first] = " + this->myChildren[n][iter->first]); |
| 173 | if (this->myChildren[n][iter->first] != iter->second) |
173 | if (this->myChildren[n][iter->first] != iter->second) |
| 174 | { |
174 | { |
| Line 235... | Line 235... | ||
| 235 | 235 | ||
| 236 | int Node::parseTag(string filename, string xmlData, unsigned int position) |
236 | int Node::parseTag(string filename, string xmlData, unsigned int position) |
| 237 | { |
237 | { |
| 238 | if (xmlData.at(position) != '<') |
238 | if (xmlData.at(position) != '<') |
| 239 | { |
239 | { |
| 240 | throw new Exception("Did not find < as expected. Character " + |
240 | throw new Exception("Did not find < as expected. Character " + convert::int2string(position)); |
| 241 | } |
241 | } |
| 242 | 242 | ||
| 243 | position++; |
243 | position++; |
| 244 | 244 | ||
| 245 | int endPosition = xmlData.find('>', position); |
245 | int endPosition = xmlData.find('>', position); |
| Line 258... | Line 258... | ||
| 258 | tagString = xmlData.substr(position, endPosition - position); |
258 | tagString = xmlData.substr(position, endPosition - position); |
| 259 | } |
259 | } |
| 260 | catch (std::out_of_range & e) |
260 | catch (std::out_of_range & e) |
| 261 | { |
261 | { |
| 262 | LOG.debug("parseTag exception: " + string(e.what())); |
262 | LOG.debug("parseTag exception: " + string(e.what())); |
| 263 | LOG.debug("A xmlData=" + xmlData + " :: position=" + |
263 | LOG.debug("A xmlData=" + xmlData + " :: position=" + convert::int2string(position) + " :: endPosition=" + convert::int2string(endPosition)); |
| 264 | throw e; |
264 | throw e; |
| 265 | } |
265 | } |
| 266 | 266 | ||
| 267 | trim(tagString); |
267 | trim(tagString); |
| 268 | trim_if(tagString, is_any_of("\n")); |
268 | trim_if(tagString, is_any_of("\n")); |
| Line 306... | Line 306... | ||
| 306 | //LOG.debug("Added attribute \"" + buffer + "\" = \"" + this->myAttributes[buffer] + "\""); |
306 | //LOG.debug("Added attribute \"" + buffer + "\" = \"" + this->myAttributes[buffer] + "\""); |
| 307 | } |
307 | } |
| 308 | catch (std::out_of_range & ex) |
308 | catch (std::out_of_range & ex) |
| 309 | { |
309 | { |
| 310 | LOG.debug("parseTag exception: " + string(ex.what())); |
310 | LOG.debug("parseTag exception: " + string(ex.what())); |
| 311 | LOG.debug("A xmlData=" + xmlData + " :: position=" + |
311 | LOG.debug("A xmlData=" + xmlData + " :: position=" + convert::int2string(position) + " :: endPosition=" + convert::int2string(endPosition)); |
| 312 | throw ex; |
312 | throw ex; |
| 313 | } |
313 | } |
| 314 | 314 | ||
| 315 | //cout << "Found attribute: " << buffer << " = " << myAttributes[buffer] << endl; |
315 | //cout << "Found attribute: " << buffer << " = " << myAttributes[buffer] << endl; |
| 316 | pos = e; |
316 | pos = e; |
| Line 354... | Line 354... | ||
| 354 | } |
354 | } |
| 355 | } |
355 | } |
| 356 | catch (std::out_of_range & ex) |
356 | catch (std::out_of_range & ex) |
| 357 | { |
357 | { |
| 358 | LOG.debug("parseTag exception: " + string(ex.what())); |
358 | LOG.debug("parseTag exception: " + string(ex.what())); |
| 359 | LOG.debug("A xmlData=" + xmlData + " :: position=" + |
359 | LOG.debug("A xmlData=" + xmlData + " :: position=" + convert::int2string(position) + " :: endPosition=" + convert::int2string(endPosition)); |
| 360 | throw ex; |
360 | throw ex; |
| 361 | } |
361 | } |
| 362 | 362 | ||
| 363 | } |
363 | } |
| 364 | 364 | ||