| 611 | } |
| 612 | |
| 613 | bool Generators::DeepCopy(const GeneratorInfo &info, TemplateEngine &templateEngine) { |
| 614 | // Get the types |
| 615 | tinyxml2::XMLElement *types = info.registry->FirstChildElement("types"); |
| 616 | if (!types) { |
| 617 | std::cerr << "Failed to find commands in registry" << std::endl; |
| 618 | return false; |
| 619 | } |
| 620 | |
| 621 | // Metadata |
| 622 | ObjectTreeMetadata md; |
| 623 | |
| 624 | // Populate lookup |
| 625 | for (tinyxml2::XMLElement *typeNode = types->FirstChildElement("type"); typeNode; typeNode = typeNode->NextSiblingElement("type")) { |
| 626 | // Try to get the category, if not, not interested |
| 627 | const char *category = typeNode->Attribute("category", nullptr); |
| 628 | if (!category) { |
| 629 | continue; |
| 630 | } |
| 631 | |
| 632 | // Skip non-compound types |
| 633 | if (std::strcmp(category, "struct") != 0) { |
| 634 | continue; |
| 635 | } |
| 636 | |
| 637 | // Attempt to get the name |
| 638 | const char *name = typeNode->Attribute("name", nullptr); |
| 639 | if (!name) { |
| 640 | std::cerr << "Malformed type in line: " << typeNode->GetLineNum() << ", name not found" << std::endl; |
| 641 | return false; |
| 642 | } |
| 643 | |
| 644 | // Add lookup |
| 645 | md.lookup[name] = typeNode; |
| 646 | } |
| 647 | |
| 648 | // Final stream |
| 649 | std::stringstream deepCopy; |
| 650 | |
| 651 | // Create deep copies |
| 652 | for (tinyxml2::XMLElement *typeNode = types->FirstChildElement("type"); typeNode; typeNode = typeNode->NextSiblingElement("type")) { |
| 653 | // Try to get the category, if not, not interested |
| 654 | const char *category = typeNode->Attribute("category", nullptr); |
| 655 | if (!category) { |
| 656 | continue; |
| 657 | } |
| 658 | |
| 659 | // Skip non-compound types |
| 660 | if (std::strcmp(category, "struct") != 0) { |
| 661 | continue; |
| 662 | } |
| 663 | |
| 664 | // Attempt to get the name |
| 665 | const char *name = typeNode->Attribute("name", nullptr); |
| 666 | if (!name) { |
| 667 | std::cerr << "Malformed type in line: " << typeNode->GetLineNum() << ", name not found" << std::endl; |
| 668 | return false; |
| 669 | } |
| 670 |
no test coverage detected