| 624 | // ---------------------------------------------------------------------------------------- |
| 625 | |
| 626 | void xml_parser:: |
| 627 | get_next_token( |
| 628 | std::istream& in, |
| 629 | std::string& token_text, |
| 630 | int& token_kind, |
| 631 | unsigned long& line_number |
| 632 | ) |
| 633 | { |
| 634 | |
| 635 | token_text.erase(); |
| 636 | |
| 637 | std::istream::int_type ch1 = in.get(); |
| 638 | std::istream::int_type ch2; |
| 639 | |
| 640 | |
| 641 | switch (ch1) |
| 642 | { |
| 643 | |
| 644 | // ----------------------------------------- |
| 645 | |
| 646 | // this is the start of some kind of a tag |
| 647 | case '<': |
| 648 | { |
| 649 | ch2 = in.get(); |
| 650 | switch (ch2) |
| 651 | { |
| 652 | |
| 653 | // --------------------------------- |
| 654 | |
| 655 | // this is a dtd, comment, or chars_cdata token |
| 656 | case '!': |
| 657 | { |
| 658 | // if this is a CDATA section ******************************* |
| 659 | if ( in.peek() == '[') |
| 660 | { |
| 661 | token_kind = chars_cdata; |
| 662 | |
| 663 | // throw away the '[' |
| 664 | in.get(); |
| 665 | |
| 666 | // make sure the next chars are CDATA[ |
| 667 | std::istream::int_type ch = in.get(); |
| 668 | if (ch != 'C') |
| 669 | token_kind = error; |
| 670 | ch = in.get(); |
| 671 | if (ch != 'D') |
| 672 | token_kind = error; |
| 673 | ch = in.get(); |
| 674 | if (ch != 'A') |
| 675 | token_kind = error; |
| 676 | ch = in.get(); |
| 677 | if (ch != 'T') |
| 678 | token_kind = error; |
| 679 | ch = in.get(); |
| 680 | if (ch != 'A') |
| 681 | token_kind = error; |
| 682 | ch = in.get(); |
| 683 | if (ch != '[') |