| 548 | } |
| 549 | |
| 550 | bool Document::parseTag(ElementPtr& _currentNode, std::string _content) |
| 551 | { |
| 552 | // убераем лишнее |
| 553 | MyGUI::utility::trim(_content); |
| 554 | |
| 555 | if (_content.empty()) |
| 556 | { |
| 557 | // создаем пустой тег |
| 558 | if (_currentNode) |
| 559 | { |
| 560 | _currentNode = _currentNode->createChild(std::string_view{}); |
| 561 | } |
| 562 | else if (!mRoot) |
| 563 | { |
| 564 | mRoot = std::make_unique<Element>(std::string_view{}, nullptr); |
| 565 | _currentNode = mRoot.get(); |
| 566 | } |
| 567 | return true; |
| 568 | } |
| 569 | |
| 570 | char symbol = _content[0]; |
| 571 | bool tagDeclaration = false; |
| 572 | |
| 573 | // проверяем на коментарии |
| 574 | if (symbol == '!') |
| 575 | { |
| 576 | if (_currentNode != nullptr) |
| 577 | { |
| 578 | //_currentNode->createChild(std::string_view{}, _content, ElementType::Comment); |
| 579 | } |
| 580 | return true; |
| 581 | } |
| 582 | // проверяем на информационный тег |
| 583 | if (symbol == '?') |
| 584 | { |
| 585 | tagDeclaration = true; |
| 586 | _content.erase(0, 1); // удаляем первый символ |
| 587 | } |
| 588 | |
| 589 | size_t start = 0; |
| 590 | // проверяем на закрытие тега |
| 591 | if (symbol == '/') |
| 592 | { |
| 593 | if (_currentNode == nullptr) |
| 594 | { |
| 595 | mLastError = ErrorType::CloseNotOpenedElement; |
| 596 | return false; |
| 597 | } |
| 598 | // обрезаем имя тэга |
| 599 | start = _content.find_first_not_of(" \t", 1); |
| 600 | if (start == std::string::npos) |
| 601 | { |
| 602 | // тег пустой |
| 603 | _content.clear(); |
| 604 | } |
| 605 | else |
| 606 | { |
| 607 | size_t end = _content.find_last_not_of(" \t"); |
nothing calls this directly
no test coverage detected