| 365 | #ifdef TIXML_USE_STL |
| 366 | |
| 367 | void TiXmlDocument::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ) |
| 368 | { |
| 369 | // The basic issue with a document is that we don't know what we're |
| 370 | // streaming. Read something presumed to be a tag (and hope), then |
| 371 | // identify it, and call the appropriate stream method on the tag. |
| 372 | // |
| 373 | // This "pre-streaming" will never read the closing ">" so the |
| 374 | // sub-tag can orient itself. |
| 375 | |
| 376 | if ( !StreamTo( in, '<', tag ) ) |
| 377 | { |
| 378 | SetError( TIXML_ERROR_PARSING_EMPTY, 0, 0 ); |
| 379 | return; |
| 380 | } |
| 381 | |
| 382 | while ( in->good() ) |
| 383 | { |
| 384 | int tagIndex = static_cast<int>(tag->length()); |
| 385 | while ( in->good() && in->peek() != '>' ) |
| 386 | { |
| 387 | int c = in->get(); |
| 388 | (*tag) += (TCHAR) c; |
| 389 | } |
| 390 | |
| 391 | if ( in->good() ) |
| 392 | { |
| 393 | // We now have something we presume to be a node of |
| 394 | // some sort. Identify it, and call the node to |
| 395 | // continue streaming. |
| 396 | TiXmlNode* node = Identify( tag->c_str() + tagIndex ); |
| 397 | |
| 398 | if ( node ) |
| 399 | { |
| 400 | node->StreamIn( in, tag ); |
| 401 | bool isElement = node->ToElement() != 0; |
| 402 | delete node; |
| 403 | node = 0; |
| 404 | |
| 405 | // If this is the root element, we're done. Parsing will be |
| 406 | // done by the >> operator. |
| 407 | if ( isElement ) |
| 408 | { |
| 409 | return; |
| 410 | } |
| 411 | } |
| 412 | else |
| 413 | { |
| 414 | SetError( TIXML_ERROR, 0, 0 ); |
| 415 | return; |
| 416 | } |
| 417 | } |
| 418 | } |
| 419 | // We should have returned sooner. |
| 420 | SetError( TIXML_ERROR, 0, 0 ); |
| 421 | } |
| 422 | |
| 423 | #endif |
| 424 |
no test coverage detected