1818#include < sstream>
1919#include < string>
2020#include < typeindex>
21+ #include " behaviortree_cpp/basic_types.h"
2122
2223#if defined(_MSVC_LANG) && !defined(__clang__)
2324#define __bt_cplusplus (_MSC_VER == 1900 ? 201103L : _MSVC_LANG)
@@ -654,13 +655,14 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
654655 }
655656
656657 PortsRemapping port_remap;
658+ OtherAttributes other_attributes;
657659 for (const XMLAttribute* att = element->FirstAttribute (); att; att = att->Next ())
658660 {
659- if (IsAllowedPortName (att->Name ()))
661+ const std::string port_name = att->Name ();
662+ const std::string port_value = att->Value ();
663+ // TODO: modify so that we can parse portnames that start with _
664+ if (IsAllowedPortName (port_name))
660665 {
661- const std::string port_name = att->Name ();
662- const std::string port_value = att->Value ();
663-
664666 if (manifest)
665667 {
666668 auto port_model_it = manifest->ports .find (port_name);
@@ -696,6 +698,10 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
696698
697699 port_remap[port_name] = port_value;
698700 }
701+ else if (!IsNodeNameAttribute (port_name))
702+ {
703+ other_attributes[port_name] = port_value;
704+ }
699705 }
700706
701707 NodeConfig config;
@@ -713,6 +719,7 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
713719 if (auto script = element->Attribute (attr_name))
714720 {
715721 conditions.insert ({ ID, std::string (script) });
722+ other_attributes.erase (attr_name);
716723 }
717724 };
718725
@@ -727,6 +734,7 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
727734 AddCondition (config.post_conditions , toStr (post ).c_str (), post );
728735 }
729736
737+ config.other_attributes = other_attributes;
730738 // ---------------------------------------------
731739 TreeNode::Ptr new_node;
732740
0 commit comments