Clean-up: modernize pretty_xml.cpp
[lttng-tools.git] / tests / utils / xml-utils / common.hpp
CommitLineData
051356a8
SM
1/*
2 * Copyright (C) 2024 EfficiOS Inc.
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 *
6 */
7
8#ifndef TESTS_UTILS_XML_UTILS_COMMON_HPP
9#define TESTS_UTILS_XML_UTILS_COMMON_HPP
10
11#include "common/make-unique-wrapper.hpp"
12
13#include <libxml/parser.h>
14#include <memory>
15
f59edc7c
JG
16namespace lttng {
17namespace libxml {
18
19using parser_ctx_uptr = std::unique_ptr<
051356a8
SM
20 xmlParserCtxt,
21 lttng::memory::create_deleter_class<xmlParserCtxt, xmlFreeParserCtxt>::deleter>;
f59edc7c
JG
22using doc_uptr =
23 std::unique_ptr<xmlDoc, lttng::memory::create_deleter_class<xmlDoc, xmlFreeDoc>::deleter>;
24
25/*
26 * Manage the global parser context of libxml2.
27 * There should only be one instance of this class per process.
28 */
29class global_parser_context {
30public:
31 global_parser_context()
32 {
33 xmlInitParser();
34 }
35
36 ~global_parser_context()
37 {
38 xmlCleanupParser();
39 }
051356a8 40
f59edc7c
JG
41 /* Deactivate copy and assignment. */
42 global_parser_context(const global_parser_context&) = delete;
43 global_parser_context(global_parser_context&&) = delete;
44 global_parser_context& operator=(const global_parser_context&) = delete;
45 global_parser_context& operator=(global_parser_context&&) = delete;
46};
47} /* namespace libxml */
48} /* namespace lttng */
051356a8 49#endif /* TESTS_UTILS_XML_UTILS_COMMON_HPP */
This page took 0.024564 seconds and 4 git commands to generate.