61 LOG_INFO(
"LibXMLParser",
"libxml2 threading support enabled");
84 std::ifstream file(filepath);
92 file.seekg(0, std::ios::end);
93 std::streampos fileSize = file.tellg();
94 file.seekg(0, std::ios::beg);
97 if (fileSize < 1024) {
98 sizeStr = std::to_string(fileSize) +
" bytes";
99 }
else if (fileSize < 1024 * 1024) {
100 sizeStr = std::to_string(
static_cast<double>(fileSize) / 1024.0) +
" KB";
102 sizeStr = std::to_string(
static_cast<double>(fileSize) / (1024.0 * 1024.0)) +
" MB";
112 xmlDocPtr doc = xmlParseFile(filepath.c_str());
133 ReportProgress(
"ERROR: Failed to parse document structure", 2, 5);
154 auto validation_result = validator.
Validate(main_tree.get());
157 if (validation_result.HasErrors()) {
159 "Tree validation failed with " + std::to_string(validation_result.ErrorCount()) +
" error(s):");
161 for (
const auto &issue : validation_result.issues) {
164 LOG_ERROR(
"LibXMLParser",
" [" + issue.node_path +
"] " + issue.message);
173 if (validation_result.HasWarnings()) {
175 "Tree has " + std::to_string(validation_result.WarningCount()) +
" warning(s):");
177 for (
const auto &issue : validation_result.issues) {
179 LOG_WARNING(
"LibXMLParser",
" [" + issue.node_path +
"] " + issue.message);
194 auto validation_result = validator.
Validate(first_tree.get());
196 if (validation_result.HasErrors()) {
197 for (
const auto &issue : validation_result.issues) {
219 xmlDocPtr doc = xmlParseMemory(xml_content.c_str(), xml_content.length());
239 auto validation_result = validator.
Validate(main_tree.get());
241 if (validation_result.HasErrors()) {
242 for (
const auto &issue : validation_result.issues) {
259 auto validation_result = validator.
Validate(first_tree.get());
261 if (validation_result.HasErrors()) {
262 for (
const auto &issue : validation_result.issues) {
277std::vector<LibXMLBehaviorTreeParser::ParseResult>
280 std::vector<ParseResult> results;
281 results.reserve(filepaths.size());
283 for (
const auto &filepath : filepaths) {
294 }
catch (
const std::exception &e) {
300 results.push_back(result);
313 if (pair.second.is_implemented) {
332 std::vector<EmberCore::String> filepaths;
362 int total_files =
static_cast<int>(filepaths.size());
363 int current_file = 0;
365 ReportProgress(
"Starting project parsing...", 0, total_files + 2);
368 for (
const auto &filepath : filepaths) {
372 ReportProgress(
"Parsing file " + std::to_string(current_file) +
"/" + std::to_string(total_files) +
": " +
374 current_file, total_files + 2);
377 std::ifstream file(filepath);
383 failedInfo.
errors.push_back(
"File not found: " + filepath);
394 xmlDocPtr doc = xmlParseFile(filepath.c_str());
400 failedInfo.
errors.push_back(
"Failed to parse XML file - syntax error");
411 xmlNodePtr root = xmlDocGetRootElement(doc);
417 failedInfo.
errors.push_back(
"XML document has no root element");
428 const auto &doc_config =
config_.GetDocumentConfig();
429 const auto &tree_config =
config_.GetTreeConfig();
433 bool root_valid =
false;
434 if (doc_config.case_sensitive) {
435 root_valid = (root_name == doc_config.root_element);
437 auto to_lower = [](
String str) {
438 std::transform(str.begin(), str.end(), str.begin(), ::tolower);
441 root_valid = (to_lower(root_name) == to_lower(doc_config.root_element));
449 failedInfo.
errors.push_back(
"Expected '" + doc_config.root_element +
"' element, found '" + root_name +
456 "' element, found '" + root_name +
"'",
465 if (!main_tree.empty()) {
475 std::set<String> file_tree_ids;
476 std::set<String> file_bb_ids;
477 std::set<String> subtree_refs_set;
478 std::set<String> bb_includes_set;
481 for (xmlNodePtr child = root->children; child; child = child->next) {
482 if (child->type == XML_ELEMENT_NODE) {
485 if (name == tree_config.behavior_tree_element) {
491 if (tree_id.empty()) {
492 fileInfo.
errors.push_back(
"BehaviorTree element missing required 'ID' attribute");
494 fileInfo.
tree_ids.push_back(tree_id);
497 if (file_tree_ids.count(tree_id) > 0) {
498 fileInfo.
warnings.push_back(
"Duplicate tree ID within file: " + tree_id);
500 file_tree_ids.insert(tree_id);
508 status.
is_implemented = tree->HasRootNode() && tree->GetNodeCount() > 0;
514 if (tree->HasRootNode()) {
518 LOG_INFO(
"LibXMLParser",
"Parsed tree '" + tree_id +
"' from " + filepath);
521 }
else if (name ==
"Blackboard") {
528 fileInfo.
errors.push_back(
"Blackboard element missing required 'ID' attribute");
533 if (file_bb_ids.count(bb_id) > 0) {
534 fileInfo.
warnings.push_back(
"Duplicate blackboard ID within file: " + bb_id);
536 file_bb_ids.insert(bb_id);
540 if (!includes.empty()) {
542 if (includes.front() !=
'{' || includes.back() !=
'}') {
544 "Blackboard '" + bb_id +
545 "' has malformed includes syntax (should be {ID1 ID2 ...})");
548 String includes_content = includes.substr(1, includes.size() - 2);
549 std::istringstream iss(includes_content);
551 while (iss >> token) {
552 if (!token.empty()) {
553 bb_includes_set.insert(token);
561 std::set<String> seen_keys;
562 for (xmlNodePtr entryNode = child->children; entryNode; entryNode = entryNode->next) {
563 if (entryNode->type != XML_ELEMENT_NODE)
572 fileInfo.
errors.push_back(
"Blackboard '" + bb_id +
573 "' has Entry missing required 'key' attribute");
577 fileInfo.
errors.push_back(
"Blackboard '" + bb_id +
"' entry '" + key +
578 "' missing required 'type' attribute");
583 if (seen_keys.count(key) > 0) {
584 fileInfo.
warnings.push_back(
"Blackboard '" + bb_id +
585 "' has duplicate entry key: " + key);
587 seen_keys.insert(key);
590 static const std::set<String> validTypes = {
"bool",
608 "vec(vec(uint32_t))",
613 "map(string, string)",
614 "map(string,string)",
625 bool isValidType = validTypes.count(type) > 0;
626 bool isCustomType = !type.empty() && std::isupper(type[0]) &&
627 type.find(
'(') == String::npos && type.find(
')') == String::npos;
629 if (!isValidType && !isCustomType) {
630 fileInfo.
warnings.push_back(
"Blackboard '" + bb_id +
"' entry '" + key +
631 "' has unsupported type: " + type);
639 LOG_INFO(
"LibXMLParser",
"Parsed blackboard '" + bb_id +
"' from " + filepath);
647 fileInfo.
subtree_refs.assign(subtree_refs_set.begin(), subtree_refs_set.end());
651 fileInfo.
warnings.push_back(
"No BehaviorTree or Blackboard elements found in file");
667 for (
const auto &err :
errors_) {
668 result.
errors.push_back(err);
673 ReportProgress(
"Collecting SubTree references...", total_files + 1, total_files + 2);
675 std::set<EmberCore::String> all_references;
677 if (tree_pair.second && tree_pair.second->HasRootNode()) {
683 std::set<String> implemented_tree_ids;
685 implemented_tree_ids.insert(tree_pair.first);
689 for (
const auto &ref : all_references) {
698 result.
warnings.push_back(
"Tree '" + ref +
"' is referenced but not implemented");
699 LOG_WARNING(
"LibXMLParser",
"Tree '" + ref +
"' is referenced but not implemented");
703 for (
const auto &subtree_ref : fileInfo.subtree_refs) {
704 if (subtree_ref == ref) {
705 fileInfo.warnings.push_back(
"References unimplemented tree: " + ref);
714 ReportProgress(
"Expanding SubTree references...", total_files + 2, total_files + 2);
718 ReportProgress(
"Validating cross-file references...", total_files + 2, total_files + 2);
721 std::map<String, std::vector<String>> tree_id_to_files;
722 for (
const auto &fileInfo : result.
file_infos) {
723 for (
const auto &tree_id : fileInfo.tree_ids) {
724 tree_id_to_files[tree_id].push_back(fileInfo.filepath);
727 for (
const auto &pair : tree_id_to_files) {
728 if (pair.second.size() > 1) {
730 result.
warnings.push_back(
"Duplicate tree ID found across files: " + pair.first);
735 std::map<String, std::vector<String>> bb_id_to_files;
736 std::set<String> all_blackboard_ids;
737 for (
const auto &fileInfo : result.
file_infos) {
738 for (
const auto &bb_id : fileInfo.blackboard_ids) {
739 bb_id_to_files[bb_id].push_back(fileInfo.filepath);
740 all_blackboard_ids.insert(bb_id);
743 for (
const auto &pair : bb_id_to_files) {
744 if (pair.second.size() > 1) {
746 result.
warnings.push_back(
"Duplicate blackboard ID found across files: " + pair.first);
751 std::set<String> unresolved_includes;
752 for (
const auto &fileInfo : result.
file_infos) {
753 for (
const auto &include : fileInfo.blackboard_includes) {
754 if (all_blackboard_ids.count(include) == 0) {
755 unresolved_includes.insert(include);
760 for (
const auto &include : unresolved_includes) {
761 result.
warnings.push_back(
"Unresolved blackboard include: " + include);
774 result.
parsed_blackboards[pair.first] = std::shared_ptr<Blackboard>(std::move(pair.second));
783 for (
const auto &err :
errors_) {
784 result.
errors.push_back(err);
793 total_files + 2, total_files + 2);
804 if (!subtree_ref.empty()) {
805 references.insert(subtree_ref);
810 if (std::find(status.referenced_in_files.begin(), status.referenced_in_files.end(),
current_file_path_) ==
811 status.referenced_in_files.end()) {
830 auto &tree = tree_pair.second;
831 if (tree && tree->HasRootNode()) {
844 bool expanded_any =
false;
848 if (!subtree_ref.empty()) {
853 if (referenced_tree && referenced_tree->HasRootNode()) {
854 Node *referenced_root = referenced_tree->GetRootNode();
862 String cycle_msg =
"Circular reference: ";
867 cycle_msg += tree_in_stack;
870 cycle_msg +=
" -> " + subtree_ref;
874 LOG_ERROR(
"LibXMLParser",
"Circular SubTree reference detected: " + cycle_msg);
878 if (!already_expanded) {
894 for (
size_t i = 0; i < referenced_root->
GetChildCount(); ++i) {
906 node->
SetName(
"SubTree: " + subtree_ref +
" [EMPTY]");
907 LOG_WARNING(
"LibXMLParser",
"SubTree '" + subtree_ref +
"' is empty (no root node)");
914 node->
SetName(
"SubTree: " + subtree_ref +
" [NOT IMPLEMENTED]");
915 LOG_WARNING(
"LibXMLParser",
"SubTree '" + subtree_ref +
"' not found (unimplemented reference)");
932 return it->second.is_implemented;
938 std::vector<EmberCore::String> result;
940 result.push_back(ref);
950 xmlNodePtr root = xmlDocGetRootElement(doc);
957 const auto &doc_config =
config_.GetDocumentConfig();
960 if (doc_config.case_sensitive) {
961 if (root_name != doc_config.root_element) {
963 "' element, found '" + root_name +
"'");
968 auto to_lower = [](
String str) {
969 std::transform(str.begin(), str.end(), str.begin(), ::tolower);
972 if (to_lower(root_name) != to_lower(doc_config.root_element)) {
974 "' element, found '" + root_name +
"'");
989 const auto &tree_config =
config_.GetTreeConfig();
990 const auto &blackboard_config =
config_.GetBlackboardConfig();
993 int totalElements = 0;
994 for (xmlNodePtr child = root->children; child; child = child->next) {
995 if (child->type == XML_ELEMENT_NODE) {
997 if (name == tree_config.behavior_tree_element || name == blackboard_config.blackboard_element) {
1002 ReportProgress(
"Found " + std::to_string(totalElements) +
" element(s) to parse", 2, 5);
1006 int blackboardCount = 0;
1007 for (xmlNodePtr child = root->children; child; child = child->next) {
1008 if (child->type == XML_ELEMENT_NODE) {
1010 if (name == tree_config.behavior_tree_element) {
1014 if (!tree_id.empty()) {
1018 EmberCore::String progressMsg =
"Parsed tree " + std::to_string(treeCount) +
"/" +
1019 std::to_string(totalElements) +
": " + tree_id;
1023 if (tree->HasRootNode()) {
1024 size_t nodeCount = tree->GetNodeCount();
1025 ReportProgress(
" " + std::to_string(nodeCount) +
" node(s) in tree", 2, 5);
1029 tree_config.behavior_tree_element +
" missing " + tree_config.tree_id_attribute +
1035 }
else if (name == blackboard_config.blackboard_element) {
1043 }
else if (!doc_config.allow_unknown_elements) {
1044 LOG_WARNING(
"LibXMLParser",
"Unknown element '" + name +
"' in root (ignored)");
1052 ReportProgress(
"Parsed " + std::to_string(treeCount) +
" tree(s) and " + std::to_string(blackboardCount) +
1065 const auto &blackboard = blackboard_pair.second;
1067 tree_pair.second->AddBlackboard(blackboard->Clone());
1073 LOG_ERROR(
"LibXMLParser",
"Parsing failed with " + std::to_string(
errors_.size()) +
" error(s):");
1074 for (
size_t i = 0; i <
errors_.size(); ++i) {
1075 LOG_ERROR(
"LibXMLParser",
" " + std::to_string(i + 1) +
": " +
errors_[i].message);
1080 LOG_INFO(
"LibXMLParser",
"Parsing completed successfully");
1086 if (!node || !node->name)
1088 return std::string(
reinterpret_cast<const char *
>(node->name));
1095 xmlChar *value = xmlGetProp(node,
reinterpret_cast<const xmlChar *
>(attr_name.c_str()));
1131 if (!context.empty()) {
1133 error.
message +=
" (Context: " + context +
")";
1137 LOG_ERROR(
"LibXMLParser",
"Parse error: " + message +
"");
1145 xmlNodePtr current = node;
1147 while (current && current->parent) {
1153 node_name +=
"[ID=" +
id +
"]";
1154 }
else if (!name.empty()) {
1155 node_name +=
"[name=" + name +
"]";
1161 path = node_name +
"/" + path;
1164 current = current->parent;
1179 const auto &tree_config =
config_.GetTreeConfig();
1186 auto behavior_tree = std::make_shared<BehaviorTree>();
1189 behavior_tree->SetName(tree_id);
1195 xmlNodePtr child = tree_node->children;
1196 std::unique_ptr<Node> root_node =
nullptr;
1199 if (child->type == XML_ELEMENT_NODE) {
1203 root_node = std::move(node);
1206 tree_config.behavior_tree_element +
" can only have one root node", child);
1211 child = child->next;
1214 if (!root_node && tree_config.require_root_node) {
1216 EmberCore::String(tree_config.behavior_tree_element) +
" '" + tree_id +
"' has no root node");
1225 xmlAttrPtr attr = tree_node->properties;
1229 wrapper_node->SetAttribute(attr_name, attr_value);
1234 wrapper_node->AddChild(std::move(root_node));
1237 behavior_tree->SetRootNode(std::move(wrapper_node));
1239 return behavior_tree;
1243 if (!xml_node || xml_node->type != XML_ELEMENT_NODE) {
1247 const auto &node_config =
config_.GetNodeConfig();
1248 const auto &tree_config =
config_.GetTreeConfig();
1251 std::unique_ptr<Node> node =
nullptr;
1255 if (element_name == node_config.control_element) {
1257 }
else if (element_name == node_config.action_element) {
1259 }
else if (element_name == node_config.condition_element) {
1261 }
else if (element_name == node_config.decorator_element) {
1263 }
else if (element_name == tree_config.subtree_element) {
1265 }
else if (element_name == node_config.generic_node_element) {
1270 const auto &classification_config =
config_.GetClassificationConfig();
1271 switch (classification_config.unknown_behavior) {
1276 LOG_WARNING(
"LibXMLParser",
"Unknown node element: " + element_name +
" (skipped)");
1279 LOG_WARNING(
"LibXMLParser",
"Unknown node element: " + element_name +
" (creating generic action node)");
1288 if (element_name != tree_config.subtree_element) {
1298 const auto &node_config =
config_.GetNodeConfig();
1307 if (!
config_.IsControlType(control_type)) {
1308 const auto &classification_config =
config_.GetClassificationConfig();
1313 LOG_WARNING(
"LibXMLParser",
"Unknown control type '" + control_type +
"', creating generic control node");
1317 LOG_TRACE(
"LibXMLParser",
"Created control node: " + control_type);
1323 const auto &node_config =
config_.GetNodeConfig();
1332 if (!
config_.IsActionType(action_type)) {
1333 const auto &classification_config =
config_.GetClassificationConfig();
1334 if (!classification_config.action_types.empty() &&
1339 LOG_TRACE(
"LibXMLParser",
"Unknown action type '" + action_type +
"', creating generic Action node");
1343 LOG_TRACE(
"LibXMLParser",
"Created action node: " + action_type);
1349 const auto &node_config =
config_.GetNodeConfig();
1358 if (!
config_.IsConditionType(condition_type)) {
1359 const auto &classification_config =
config_.GetClassificationConfig();
1360 if (!classification_config.condition_types.empty() &&
1365 LOG_TRACE(
"LibXMLParser",
"Unknown condition type '" + condition_type +
"', creating generic Condition node");
1369 LOG_TRACE(
"LibXMLParser",
"Created condition node: " + condition_type);
1375 const auto &node_config =
config_.GetNodeConfig();
1384 if (!
config_.IsDecoratorType(decorator_type)) {
1385 const auto &classification_config =
config_.GetClassificationConfig();
1390 LOG_WARNING(
"LibXMLParser",
"Unknown decorator type '" + decorator_type +
"', creating generic decorator node");
1394 LOG_TRACE(
"LibXMLParser",
"Created decorator node: " + decorator_type);
1400 const auto &tree_config =
config_.GetTreeConfig();
1412 placeholder->SetAttribute(
"__subtree_ref__", subtree_id);
1413 placeholder->SetAttribute(
"__is_placeholder__",
"true");
1416 "Created SubTree placeholder for '" + subtree_id +
"' (will expand after all trees parsed)");
1425 const auto &blackboard_config =
config_.GetBlackboardConfig();
1432 auto blackboard = std::make_unique<Blackboard>(blackboard_id);
1436 if (!parent_id.empty()) {
1437 blackboard->SetParentId(parent_id);
1438 LOG_TRACE(
"LibXMLParser",
"Blackboard '" + blackboard_id +
"' inherits from '" + parent_id +
"'");
1442 xmlNodePtr child = blackboard_node->children;
1444 if (child->type == XML_ELEMENT_NODE &&
GetNodeName(child) == blackboard_config.entry_element) {
1447 blackboard->AddEntry(std::move(entry));
1450 child = child->next;
1453 LOG_TRACE(
"LibXMLParser",
"Parsed blackboard '" + blackboard_id +
"' with " +
1454 std::to_string(blackboard->GetEntryCount()) +
" entries");
1460 const auto &blackboard_config =
config_.GetBlackboardConfig();
1473 if (!blackboard_config.allow_undefined_keys) {
1477 LOG_WARNING(
"LibXMLParser",
"Unknown blackboard type '" + type_str +
"', using AUTO");
1481 auto entry = std::make_unique<BlackboardEntry>(key, data_type, value);
1483 if (!entry->IsValidValue()) {
1486 LOG_WARNING(
"LibXMLParser",
"Empty or invalid value '" + value +
"' for type '" + type_str +
"' (key: " + key +
1487 ") - will use default");
1492 "Parsed blackboard entry: " + key +
" (" + type_str +
") = " + (value.empty() ?
"<empty>" : value));
1498 const auto &node_config =
config_.GetNodeConfig();
1502 if (!name.empty()) {
1507 if (!
id.empty() && name.empty()) {
1517 if (node_config.allow_custom_attributes) {
1518 xmlAttrPtr attr = xml_node->properties;
1520 EmberCore::String attr_name = std::string(
reinterpret_cast<const char *
>(attr->name));
1521 EmberCore::String attr_value = std::string(
reinterpret_cast<const char *
>(attr->children->content));
1525 if (attr_name != node_config.node_name_attribute) {
1527 LOG_TRACE(
"LibXMLParser",
"Stored node attribute: " + attr_name +
" = " + attr_value);
1536 xmlNodePtr child = xml_parent->children;
1537 size_t children_added = 0;
1540 if (child->type == XML_ELEMENT_NODE) {
1544 parent->
AddChild(std::move(child_node));
1551 child = child->next;
1555 if (children_added == 0 && xml_parent->children) {
1557 "Node '" + parent->
GetName() +
1558 "' ended up with no children after parsing (likely due to skipped SubTree nodes)");
1568 auto &tree = tree_pair.second;
1569 if (tree && tree->HasRootNode()) {
1579 bool expanded_any =
false;
1583 if (!subtree_ref.empty()) {
1588 if (referenced_tree && referenced_tree->HasRootNode()) {
1589 Node *referenced_root = referenced_tree->GetRootNode();
1599 LOG_ERROR(
"LibXMLParser",
"Circular SubTree reference detected: " + subtree_ref);
1603 if (!already_expanded) {
1628 for (
size_t i = 0; i < referenced_root->
GetChildCount(); ++i) {
1638 expanded_any =
true;
1643 node->
SetName(
"SubTree: " + subtree_ref +
" [EMPTY]");
1644 LOG_WARNING(
"LibXMLParser",
"SubTree '" + subtree_ref +
"' is empty (no root node)");
1651 node->
SetName(
"SubTree: " + subtree_ref +
" [NOT IMPLEMENTED]");
1652 LOG_WARNING(
"LibXMLParser",
"SubTree '" + subtree_ref +
"' not found (unimplemented reference)");
1658 expanded_any =
true;
1663 return expanded_any;
1673 if (value.empty()) {
1682 if (!parent || !tree) {
1689 for (xmlNodePtr child = parent->children; child; child = child->next) {
1690 if (child->type == XML_COMMENT_NODE) {
1692 xmlChar *content = xmlNodeGetContent(child);
1698 bool before_node =
true;
1699 xmlNodePtr next_element = child->next;
1700 while (next_element && next_element->type != XML_ELEMENT_NODE) {
1701 next_element = next_element->next;
1704 if (!next_element) {
1705 before_node =
false;
1711 comment.
text = comment_text;
1713 xml_metadata.node_comments[node->
GetId()].push_back(comment);
1717 xml_metadata.header_comments.push_back(comment_text);
1719 xml_metadata.footer_comments.push_back(comment_text);
#define LOG_ERROR(category, message)
#define LOG_TRACE(category, message)
#define LOG_WARNING(category, message)
#define LOG_INFO(category, message)
Represents a BehaviorTree project containing multiple XML resources.
void SetTreeImplementationStatus(const std::map< String, TreeImplementationStatus > &statuses)
const std::vector< String > & GetResources() const
String ResolveResourcePath(const String &resource_path) const
Unified validation system for behavior trees.
ValidationResult Validate(const BehaviorTree *tree) const
Validate a behavior tree against the parser profile.
Represents a complete behavior tree data structure.
XMLMetadata & GetXMLMetadata()
static DataType ParseDataType(const EmberCore::String &typeStr)
DataType
Supported data types for blackboard entries.
std::unique_ptr< Node > ParseNode(xmlNodePtr xml_node)
std::shared_ptr< BehaviorTree > ParseFromString(const EmberCore::String &xml_content)
std::vector< EmberCore::String > GetUnimplementedReferences() const
bool ExpandSubTreePlaceholder(Node *node)
ProjectParseResult ParseFilesWithSharedRegistry(const std::vector< EmberCore::String > &filepaths)
std::set< EmberCore::String > unimplemented_references_
~LibXMLBehaviorTreeParser()
std::set< EmberCore::String > circular_references_
std::unique_ptr< Node > ParseSubTreeNode(xmlNodePtr xml_node)
std::map< EmberCore::String, TreeImplementationStatus > tree_implementation_statuses_
std::unique_ptr< Node > ParseActionNode(xmlNodePtr xml_node)
bool ExpandSubTreePlaceholderForProject(Node *node)
bool project_parsing_mode_
void ParseChildNodes(Node *parent, xmlNodePtr xml_parent)
IParseProgressCallback * progress_callback_
static std::mutex destruction_mutex_
void ExpandAllSubTreePlaceholdersForProject()
bool ParseXMLDocument(xmlDocPtr doc, const EmberCore::String &source_path="")
void AddError(ParseError::Type type, const EmberCore::String &message, xmlNodePtr node=nullptr, const EmberCore::String &context="")
void ExpandAllSubTreePlaceholders()
EmberCore::String current_file_path_
std::unique_ptr< BlackboardEntry > ParseBlackboardEntry(xmlNodePtr entry_node)
static bool global_libxml2_initialized_
std::unique_ptr< Node > ParseConditionNode(xmlNodePtr xml_node)
void CaptureComments(xmlNodePtr parent, BehaviorTree *tree, Node *node=nullptr)
std::set< EmberCore::String > expansion_stack_
void CollectSubTreeReferences(Node *node, std::set< EmberCore::String > &references)
EmberCore::String main_tree_name_
std::unique_ptr< Node > ParseControlNode(xmlNodePtr xml_node)
LibXMLBehaviorTreeParser()
std::map< EmberCore::String, std::shared_ptr< BehaviorTree > > parsed_trees_
const std::vector< ParseError > & GetErrors() const
EmberCore::String GetNodeAttribute(xmlNodePtr node, const EmberCore::String &attr_name)
EmberCore::String GetNodePath(xmlNodePtr node)
std::unique_ptr< Blackboard > ParseBlackboard(xmlNodePtr blackboard_node)
EmberCore::String GetNodeName(xmlNodePtr node)
ProjectParseResult ParseProject(BehaviorTreeProject *project)
void SetNodeAttributes(Node *node, xmlNodePtr xml_node)
std::vector< ParseError > errors_
std::shared_ptr< BehaviorTree > ParseFromFile(const EmberCore::String &filepath)
bool IsTreeImplemented(const EmberCore::String &tree_id) const
std::set< EmberCore::String > expanded_subtree_cache_
std::shared_ptr< BehaviorTree > ParseBehaviorTree(xmlNodePtr tree_node)
std::map< EmberCore::String, std::unique_ptr< Blackboard > > parsed_blackboards_
std::unique_ptr< Node > ParseDecoratorNode(xmlNodePtr xml_node)
bool libxml2_initialized_
std::vector< ParseResult > ParseMultipleFiles(const std::vector< EmberCore::String > &filepaths)
bool ReportProgress(const EmberCore::String &message, int current=0, int total=0)
bool ValidateRequiredAttribute(xmlNodePtr node, const EmberCore::String &attr_name)
static std::once_flag libxml2_init_flag_
Represents a node in a behavior tree structure.
void SetName(const String &name)
const std::map< String, String > & GetAllAttributes() const
String GetAttribute(const String &name, const String &default_value="") const
Node * GetChild(size_t index) const
const String & GetName() const
void SetAttribute(const String &name, const String &value)
void RemoveAttribute(const String &name)
void AddChild(std::unique_ptr< Node > child)
size_t GetChildCount() const
std::unique_ptr< Node > DeepCopy() const
Configuration for XML parser behavior and element/attribute mappings.
Main types header for EmberCore.
static void SuppressLibXMLErrors(void *ctx, const char *msg,...)
std::string String
Framework-agnostic string type.
Per-file parsing information for project validation.
std::vector< String > blackboard_includes
std::vector< String > blackboard_ids
std::vector< String > errors
std::vector< String > subtree_refs
std::vector< String > tree_ids
std::vector< String > warnings
Error information for parsing failures (enhanced with libxml2 details)
EmberCore::String context
EmberCore::String node_path
EmberCore::String message
Result of parallel parsing operation.
std::shared_ptr< BehaviorTree > tree
EmberCore::String file_path
std::vector< ParseError > errors
Result of project parsing operation.
std::vector< FileParseInfo > file_infos
std::vector< EmberCore::String > warnings
std::map< EmberCore::String, TreeImplementationStatus > tree_statuses
std::vector< EmberCore::String > duplicate_blackboard_ids
std::map< EmberCore::String, std::shared_ptr< BehaviorTree > > parsed_trees
int GetImplementedTreeCount() const
std::vector< EmberCore::String > unimplemented_references
std::vector< EmberCore::String > circular_references
std::vector< ParseError > errors
int GetTotalTreeCount() const
std::map< EmberCore::String, std::shared_ptr< Blackboard > > parsed_blackboards
EmberCore::String main_tree_name
std::vector< EmberCore::String > duplicate_tree_ids
std::vector< EmberCore::String > unresolved_blackboard_includes
Status of a tree's implementation in the project.
String defined_in_file
Which file defines this tree (empty if not defined)
bool has_root_node
Whether tree has a root node.
bool is_implemented
Has actual implementation (not just empty/placeholder)