X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=tests%2Futils%2Fxml-utils%2Fcommon.hpp;h=01a9b5207b7bdaf2463b7e478de37ae9b4ae5956;hb=refs%2Fheads%2Fmaster;hp=5acb1b1beafd48a70395d859a7ac64dd0df6b80d;hpb=0e9cf259c6e7f66b48c07365dca15903cd352164;p=lttng-tools.git diff --git a/tests/utils/xml-utils/common.hpp b/tests/utils/xml-utils/common.hpp index 5acb1b1be..01a9b5207 100644 --- a/tests/utils/xml-utils/common.hpp +++ b/tests/utils/xml-utils/common.hpp @@ -13,8 +13,37 @@ #include #include -using xml_parser_ctx_uptr = std::unique_ptr< +namespace lttng { +namespace libxml { + +using parser_ctx_uptr = std::unique_ptr< xmlParserCtxt, lttng::memory::create_deleter_class::deleter>; +using doc_uptr = + std::unique_ptr::deleter>; + +/* + * Manage the global parser context of libxml2. + * There should only be one instance of this class per process. + */ +class global_parser_context { +public: + global_parser_context() + { + xmlInitParser(); + } + + ~global_parser_context() + { + xmlCleanupParser(); + } + /* Deactivate copy and assignment. */ + global_parser_context(const global_parser_context&) = delete; + global_parser_context(global_parser_context&&) = delete; + global_parser_context& operator=(const global_parser_context&) = delete; + global_parser_context& operator=(global_parser_context&&) = delete; +}; +} /* namespace libxml */ +} /* namespace lttng */ #endif /* TESTS_UTILS_XML_UTILS_COMMON_HPP */