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

Method parseLine

MyGUIEngine/src/MyGUI_XmlDocument.cpp:834–888  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

832 }
833
834 bool Document::parseLine(std::string& _line, ElementPtr& _element)
835 {
836 // крутимся пока в строке есть теги
837 while (true)
838 {
839 // сначала ищем по угловым скобкам
840 size_t start = find(_line, '<');
841 if (start == std::string::npos)
842 break;
843 size_t end;
844
845 // пытаемся вырезать многострочный коментарий
846 if ((start + 3 < _line.size()) && (_line[start + 1] == '!') && (_line[start + 2] == '-') &&
847 (_line[start + 3] == '-'))
848 {
849 end = _line.find("-->", start + 4);
850 if (end == std::string::npos)
851 break;
852 end += 2;
853 }
854 else
855 {
856 end = find(_line, '>', start + 1);
857 if (end == std::string::npos)
858 break;
859 }
860 // проверяем на наличее тела
861 size_t body = _line.find_first_not_of(" \t<");
862 if (body < start)
863 {
864 std::string_view body_str = std::string_view{_line}.substr(0, start);
865 // текущий символ
866 mCol = 0;
867
868 if (_element != nullptr)
869 {
870 bool ok = true;
871 _element->setContent(utility::convert_from_xml(body_str, ok));
872 if (!ok)
873 {
874 mLastError = ErrorType::IncorrectContent;
875 return false;
876 }
877 }
878 }
879 // вырезаем наш тэг и парсим
880 if (!parseTag(_element, _line.substr(start + 1, end - start - 1)))
881 {
882 return false;
883 }
884 // и обрезаем текущую строку разбора
885 _line = _line.substr(end + 1);
886 }
887 return true;
888 }
889
890 std::string Document::getLastError() const
891 {

Callers

nothing calls this directly

Calls 6

convert_from_xmlFunction · 0.85
find_first_not_ofMethod · 0.80
substrMethod · 0.80
setContentMethod · 0.80
sizeMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected