Aurum  0.1.1
 All Classes Functions Variables Pages
AccessibleUtils.h
1 #ifndef ACCESSIBLE_UTILS_H
2 #define ACCESSIBLE_UTILS_H
3 
4 #include <atspi/atspi.h>
5 #include <gio/gio.h>
6 #include <string.h>
7 
8 #include <memory>
9 
10 #include "config.h"
11 
16 struct GobjDeletor {
17  void operator()(gpointer ptr) const
18  {
19  if (ptr) g_object_unref(ptr);
20  }
21 };
22 
27 struct GarrayDeletor {
28  void operator()(GArray *ptr) const
29  {
30  if (ptr) g_array_free(ptr, 1);
31  }
32 };
33 
38 template <class T>
39 using unique_ptr_gobj = std::unique_ptr<T, GobjDeletor>;
40 
45 template <class T>
46 using unique_ptr_garray = std::unique_ptr<T, GarrayDeletor>;
47 
52 template <class T>
53 unique_ptr_gobj<T> make_gobj_unique(T *ptr)
54 {
55  return unique_ptr_gobj<T>(ptr);
56 }
57 
62 template <class T>
63 unique_ptr_garray<T> make_garray_unique(T *ptr)
64 {
65  return unique_ptr_garray<T>(ptr);
66 }
67 
72 template <class T>
73 unique_ptr_gobj<T> make_gobj_ref_unique(T *ptr)
74 {
75  g_object_ref(ptr);
76  return unique_ptr_gobj<T>(ptr);
77 }
78 
83 char *state_to_char(AtspiStateType state);
84 
85 #endif