xml_parsing.h
Go to the documentation of this file.
1 #ifndef XML_PARSING_BT_H
2 #define XML_PARSING_BT_H
3 
5 
6 #include <filesystem>
7 #include <unordered_map>
8 
9 namespace BT
10 {
16 class XMLParser : public Parser
17 {
18 public:
19  XMLParser(const BehaviorTreeFactory& factory);
20 
21  ~XMLParser() override;
22 
23  XMLParser(const XMLParser& other) = delete;
24  XMLParser& operator=(const XMLParser& other) = delete;
25 
26  XMLParser(XMLParser&& other) noexcept;
27  XMLParser& operator=(XMLParser&& other) noexcept;
28 
29  void loadFromFile(const std::filesystem::path& filename,
30  bool add_includes = true) override;
31 
32  void loadFromText(const std::string& xml_text, bool add_includes = true) override;
33 
34  [[nodiscard]] std::vector<std::string> registeredBehaviorTrees() const override;
35 
36  [[nodiscard]] Tree instantiateTree(const Blackboard::Ptr& root_blackboard,
37  std::string main_tree_to_execute = {}) override;
38 
39  void clearInternalState() override;
40 
41 private:
42  struct PImpl;
43  std::unique_ptr<PImpl> _p;
44 };
45 
46 void VerifyXML(const std::string& xml_text,
47  const std::unordered_map<std::string, NodeType>& registered_nodes);
48 
58 [[nodiscard]] std::string writeTreeNodesModelXML(const BehaviorTreeFactory& factory,
59  bool include_builtin = false);
60 
68 [[nodiscard]] std::string writeTreeXSD(const BehaviorTreeFactory& factory);
69 
81 [[nodiscard]] std::string WriteTreeToXML(const Tree& tree, bool add_metadata,
82  bool add_builtin_models);
83 
84 } // namespace BT
85 
86 #endif // XML_PARSING_BT_H
BT
Definition: ex01_wrap_legacy.cpp:29
BT::XMLParser::clearInternalState
void clearInternalState() override
Definition: xml_parsing.cpp:623
BT::XMLParser::loadFromText
void loadFromText(const std::string &xml_text, bool add_includes=true) override
Definition: xml_parsing.cpp:170
BT::XMLParser::registeredBehaviorTrees
std::vector< std::string > registeredBehaviorTrees() const override
Definition: xml_parsing.cpp:180
BT::Tree
Struct used to store a tree. If this object goes out of scope, the tree is destroyed.
Definition: bt_factory.h:91
BT::XMLParser::operator=
XMLParser & operator=(const XMLParser &other)=delete
BT::WriteTreeToXML
std::string WriteTreeToXML(const Tree &tree, bool add_metadata, bool add_builtin_models)
WriteTreeToXML create a string that contains the XML that corresponds to a given tree....
Definition: xml_parsing.cpp:1533
BT::XMLParser::_p
std::unique_ptr< PImpl > _p
Definition: xml_parsing.h:42
BT::Blackboard::Ptr
std::shared_ptr< Blackboard > Ptr
Definition: blackboard.h:35
BT::XMLParser::instantiateTree
Tree instantiateTree(const Blackboard::Ptr &root_blackboard, std::string main_tree_to_execute={}) override
Definition: xml_parsing.cpp:584
BT::XMLParser::XMLParser
XMLParser(const BehaviorTreeFactory &factory)
Definition: xml_parsing.cpp:141
bt_parser.h
BT::BehaviorTreeFactory
The BehaviorTreeFactory is used to create instances of a TreeNode at run-time.
Definition: bt_factory.h:209
BT::XMLParser::loadFromFile
void loadFromFile(const std::filesystem::path &filename, bool add_includes=true) override
Definition: xml_parsing.cpp:158
BT::VerifyXML
void VerifyXML(const std::string &xml_text, const std::unordered_map< std::string, NodeType > &registered_nodes)
BT::XMLParser
The XMLParser is a class used to read the model of a BehaviorTree from file or text and instantiate t...
Definition: xml_parsing.h:16
BT::XMLParser::PImpl
Definition: xml_parsing.cpp:94
xml_text
static const char * xml_text
Definition: ex01_wrap_legacy.cpp:52
BT::writeTreeXSD
std::string writeTreeXSD(const BehaviorTreeFactory &factory)
writeTreeXSD generates an XSD for the nodes defined in the factory
Definition: xml_parsing.cpp:1246
BT::XMLParser::~XMLParser
~XMLParser() override
Definition: xml_parsing.cpp:155
BT::writeTreeNodesModelXML
std::string writeTreeNodesModelXML(const BehaviorTreeFactory &factory, bool include_builtin=false)
writeTreeNodesModelXML generates an XMl that contains the manifests in the <TreeNodesModel>
Definition: xml_parsing.cpp:1214
BT::Parser
The BehaviorTreeParser is a class used to read the model of a BehaviorTree from file or text and inst...
Definition: bt_parser.h:26


behaviortree_cpp_v4
Author(s): Davide Faconti
autogenerated on Fri Dec 13 2024 03:19:17