MCPcopy Create free account
hub / github.com/MyGUI/mygui / parseTag

Method parseTag

MyGUIEngine/src/MyGUI_XmlDocument.cpp:550–742  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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");

Callers

nothing calls this directly

Calls 13

trimFunction · 0.85
createChildMethod · 0.80
find_first_not_ofMethod · 0.80
find_last_not_ofMethod · 0.80
substrMethod · 0.80
find_first_ofMethod · 0.80
addAttributeMethod · 0.80
emptyMethod · 0.45
getMethod · 0.45
eraseMethod · 0.45
clearMethod · 0.45
getParentMethod · 0.45

Tested by

no test coverage detected