Reduce the number of Makefiles in 'src/'
[babeltrace.git] / src / cpp-common / glib-up.hpp
CommitLineData
de719a10
SM
1/*
2 * Copyright (c) 2022 EfficiOS, inc.
3 *
4 * SPDX-License-Identifier: MIT
5 */
6
7#ifndef BABELTRACE_CPP_COMMON_GLIB_UP_HPP
8#define BABELTRACE_CPP_COMMON_GLIB_UP_HPP
9
10#include <glib.h>
11#include <memory>
12
13namespace bt2_common {
14namespace internal {
15
16struct GCharDeleter final
17{
18 void operator()(gchar * const p) noexcept
19 {
20 g_free(p);
21 }
22};
23
24} /* namespace internal */
25
26using GCharUP = std::unique_ptr<gchar, internal::GCharDeleter>;
27
73f0a623
SM
28namespace internal {
29
30struct GStringDeleter final
31{
32 void operator()(GString * const str)
33 {
34 g_string_free(str, TRUE);
35 }
36};
37
38} /* namespace internal */
39
40using GStringUP = std::unique_ptr<GString, internal::GStringDeleter>;
41
2058f4fb
SM
42namespace internal {
43
44struct GDirDeleter final
45{
46 void operator()(GDir * const dir)
47 {
48 g_dir_close(dir);
49 }
50};
51
52} /* namespace internal */
53
54using GDirUP = std::unique_ptr<GDir, internal::GDirDeleter>;
55
2478aa4b
SM
56namespace internal {
57
58struct GMappedFileDeleter final
59{
60 void operator()(GMappedFile * const f)
61 {
62 g_mapped_file_unref(f);
63 }
64};
65
66} /* namespace internal */
67
68using GMappedFileUP = std::unique_ptr<GMappedFile, internal::GMappedFileDeleter>;
69
de719a10
SM
70} /* namespace bt2_common */
71
72#endif /* BABELTRACE_CPP_COMMON_GLIB_UP_HPP */
This page took 0.025255 seconds and 4 git commands to generate.