33e04a9dc108bca651cb631b67ec8901352ab335
[babeltrace.git] / src / cpp-common / glib-up.hpp
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 <memory>
11
12 #include <glib.h>
13
14 namespace bt2_common {
15 namespace internal {
16
17 struct GCharDeleter final
18 {
19 void operator()(gchar * const p) noexcept
20 {
21 g_free(p);
22 }
23 };
24
25 } /* namespace internal */
26
27 using GCharUP = std::unique_ptr<gchar, internal::GCharDeleter>;
28
29 namespace internal {
30
31 struct GStringDeleter final
32 {
33 void operator()(GString * const str)
34 {
35 g_string_free(str, TRUE);
36 }
37 };
38
39 } /* namespace internal */
40
41 using GStringUP = std::unique_ptr<GString, internal::GStringDeleter>;
42
43 namespace internal {
44
45 struct GDirDeleter final
46 {
47 void operator()(GDir * const dir)
48 {
49 g_dir_close(dir);
50 }
51 };
52
53 } /* namespace internal */
54
55 using GDirUP = std::unique_ptr<GDir, internal::GDirDeleter>;
56
57 namespace internal {
58
59 struct GMappedFileDeleter final
60 {
61 void operator()(GMappedFile * const f)
62 {
63 g_mapped_file_unref(f);
64 }
65 };
66
67 } /* namespace internal */
68
69 using GMappedFileUP = std::unique_ptr<GMappedFile, internal::GMappedFileDeleter>;
70
71 } /* namespace bt2_common */
72
73 #endif /* BABELTRACE_CPP_COMMON_GLIB_UP_HPP */
This page took 0.03097 seconds and 3 git commands to generate.