File: common.hpp

package info (click to toggle)
ltt-control 2.14.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 22,400 kB
  • sloc: cpp: 192,720; sh: 29,271; ansic: 10,960; python: 7,419; makefile: 3,534; java: 109; xml: 46
file content (49 lines) | stat: -rw-r--r-- 1,225 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
 * SPDX-FileCopyrightText: 2024 EfficiOS Inc.
 *
 * SPDX-License-Identifier: LGPL-2.1-only
 *
 */

#ifndef TESTS_UTILS_XML_UTILS_COMMON_HPP
#define TESTS_UTILS_XML_UTILS_COMMON_HPP

#include "common/make-unique-wrapper.hpp"

#include <libxml/parser.h>
#include <memory>

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 */