| 275 | |
| 276 | |
| 277 | int |
| 278 | XmlFileStream::tag(const char *tagName) |
| 279 | { |
| 280 | if (fileOpen == 0) |
| 281 | this->open(); |
| 282 | |
| 283 | // |
| 284 | // copy tagName to end of list of tags |
| 285 | // |
| 286 | |
| 287 | // if tags array not large enough, expand |
| 288 | if (numTag == sizeTags) { |
| 289 | int nextSize = 2*sizeTags; |
| 290 | |
| 291 | if (nextSize == 0) nextSize = 32; |
| 292 | char **nextTags = new char *[nextSize]; |
| 293 | if (nextTags != 0) { |
| 294 | for (int i=0; i<sizeTags; i++) |
| 295 | nextTags[i] = tags[i]; |
| 296 | for (int j=sizeTags+1; j<nextSize; j++) |
| 297 | nextTags[j] = 0; |
| 298 | sizeTags = nextSize; |
| 299 | } else { |
| 300 | sizeTags = 0; |
| 301 | delete [] tags; |
| 302 | tags = 0; |
| 303 | return -1; |
| 304 | } |
| 305 | |
| 306 | if (tags != 0) |
| 307 | delete [] tags; |
| 308 | |
| 309 | tags = nextTags; |
| 310 | } |
| 311 | |
| 312 | |
| 313 | // copy string and assign to end of array |
| 314 | char *newTag = new char[strlen(tagName) +1]; |
| 315 | strcpy(newTag, tagName); |
| 316 | |
| 317 | if (sendSelfCount != 0 && numTag != 0) { |
| 318 | if (attributeMode == true) |
| 319 | (*xmlColumns)(numXMLTags) += 2; |
| 320 | else |
| 321 | (*xmlColumns)(numXMLTags) += 1; |
| 322 | } |
| 323 | |
| 324 | tags[numTag++] = newTag; |
| 325 | |
| 326 | // if (sendSelfCount == 0 || (strstr(tagName,"Data") != 0)) { |
| 327 | if (attributeMode == true) { |
| 328 | theFile << ">\n"; |
| 329 | } |
| 330 | |
| 331 | // output the xml for it to the file |
| 332 | |
| 333 | numIndent++; |
| 334 | this->indent(); |