.gitignore: ignore local vscode workspace settings file
[lttng-tools.git] / tests / utils / xml-utils / common.hpp
index 5acb1b1beafd48a70395d859a7ac64dd0df6b80d..01a9b5207b7bdaf2463b7e478de37ae9b4ae5956 100644 (file)
 #include <libxml/parser.h>
 #include <memory>
 
-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<xmlParserCtxt, xmlFreeParserCtxt>::deleter>;
+using doc_uptr =
+       std::unique_ptr<xmlDoc, lttng::memory::create_deleter_class<xmlDoc, xmlFreeDoc>::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 */
This page took 0.022934 seconds and 4 git commands to generate.