MCPcopy Create free account
hub / github.com/RenderKit/embree / parseXML

Function parseXML

tutorials/common/scenegraph/xml_parser.cpp:52–96  ·  view source on GitHub ↗

! parse XML tag */

Source from the content-addressed store, hash-verified

50
51 /*! parse XML tag */
52 Ref<XML> parseXML(Ref<Stream<Token> >& cin, size_t depth)
53 {
54 if (depth > 1024)
55 THROW_RUNTIME_ERROR(cin->peek().Location().str()+": maximal nesting depth reached");
56
57 Ref<XML> xml = new XML;
58 xml->loc = cin->peek().Location();
59
60 /* parse tag opening */
61 if (cin->get() != Token::Sym("<")) THROW_RUNTIME_ERROR(cin->unget().Location().str()+": tag expected");
62
63 xml->name = cin->get().Identifier();
64 parseComments(cin);
65 while (cin->peek() != Token::Sym("/>") && cin->peek() != Token::Sym(">")) {
66 parseParm(cin,xml->parms);
67 parseComments(cin);
68 }
69 if (cin->peek() == Token::Sym("/>")) {
70 cin->drop();
71 return xml;
72 }
73 cin->drop();
74
75 /* parse body token list */
76 parseComments(cin);
77 while (cin->peek() != Token::Sym("<") && cin->peek() != Token::Sym("</")) {
78 xml->body.push_back(cin->get());
79 parseComments(cin);
80 }
81
82 /* the body also contains children */
83 if (cin->peek() == Token::Sym("<")) {
84 while (cin->peek() != Token::Sym("</")) {
85 xml->children.push_back(parseXML(cin,depth+1));
86 parseComments(cin);
87 }
88 }
89
90 /* parse tag closing */
91 if (cin->get() != Token::Sym("</") ) THROW_RUNTIME_ERROR(cin->unget().Location().str()+": symbol \"</\" expected");
92 if (cin->get() != Token::Id(xml->name)) THROW_RUNTIME_ERROR(cin->unget().Location().str()+": closing "+xml->name+" expected");
93 if (cin->get() != Token::Sym(">") ) THROW_RUNTIME_ERROR(cin->unget().Location().str()+": symbol \">\" expected");
94
95 return xml;
96 }
97
98 /* load XML from token stream */
99 Ref<XML> parseXML(Ref<Stream<int> > chars, std::string id, bool hasHeader = true, bool hasTail = false)

Callers 4

loadMaterialLibraryMethod · 0.85
CoronaLoaderMethod · 0.85
XMLLoaderMethod · 0.85
xml_parser.cppFile · 0.85

Calls 8

parseCommentsFunction · 0.85
parseParmFunction · 0.85
parseHeaderFunction · 0.85
IdentifierMethod · 0.80
dropMethod · 0.80
strMethod · 0.45
getMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected