MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenImageIO / parse

Method parse

src/include/pugixml.cpp:2385–2614  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2383 }
2384
2385 char_t* parse(char_t* s, xml_node_struct* xmldoc, unsigned int optmsk, char_t endch)
2386 {
2387 strconv_attribute_t strconv_attribute = get_strconv_attribute(optmsk);
2388 strconv_pcdata_t strconv_pcdata = get_strconv_pcdata(optmsk);
2389
2390 char_t ch = 0;
2391 xml_node_struct* cursor = xmldoc;
2392 char_t* mark = s;
2393
2394 while (*s != 0)
2395 {
2396 if (*s == '<')
2397 {
2398 ++s;
2399
2400 LOC_TAG:
2401 if (PUGI__IS_CHARTYPE(*s, ct_start_symbol)) // '<#...'
2402 {
2403 PUGI__PUSHNODE(node_element); // Append a new node to the tree.
2404
2405 cursor->name = s;
2406
2407 PUGI__SCANWHILE(PUGI__IS_CHARTYPE(*s, ct_symbol)); // Scan for a terminator.
2408 PUGI__ENDSEG(); // Save char in 'ch', terminate & step over.
2409
2410 if (ch == '>')
2411 {
2412 // end of tag
2413 }
2414 else if (PUGI__IS_CHARTYPE(ch, ct_space))
2415 {
2416 LOC_ATTRIBUTES:
2417 while (true)
2418 {
2419 PUGI__SKIPWS(); // Eat any whitespace.
2420
2421 if (PUGI__IS_CHARTYPE(*s, ct_start_symbol)) // <... #...
2422 {
2423 xml_attribute_struct* a = append_attribute_ll(cursor, alloc); // Make space for this attribute.
2424 if (!a) PUGI__THROW_ERROR(status_out_of_memory, s);
2425
2426 a->name = s; // Save the offset.
2427
2428 PUGI__SCANWHILE(PUGI__IS_CHARTYPE(*s, ct_symbol)); // Scan for a terminator.
2429 PUGI__CHECK_ERROR(status_bad_attribute, s); //$ redundant, left for performance
2430
2431 PUGI__ENDSEG(); // Save char in 'ch', terminate & step over.
2432 PUGI__CHECK_ERROR(status_bad_attribute, s); //$ redundant, left for performance
2433
2434 if (PUGI__IS_CHARTYPE(ch, ct_space))
2435 {
2436 PUGI__SKIPWS(); // Eat any whitespace.
2437 PUGI__CHECK_ERROR(status_bad_attribute, s); //$ redundant, left for performance
2438
2439 ch = *s;
2440 ++s;
2441 }
2442

Callers 6

getargsFunction · 0.45
getargsFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
getargsFunction · 0.45
parseMethod · 0.45

Calls 1

make_parse_resultFunction · 0.85

Tested by

no test coverage detected