libaurum: extract methods into Utils class
[platform/core/uifw/aurum.git] / libaurum / inc / AccessibleUtils.h
1 #ifndef ACCESSIBLE_UTILS_H
2 #define ACCESSIBLE_UTILS_H
3
4 #include <atspi/atspi.h>
5 #include <gio/gio.h>
6
7 #include <memory>
8 #include "config.h"
9
10 struct GobjDeletor {
11     void operator() (gpointer ptr) const { if (ptr) g_object_unref(ptr); }
12 };
13
14 struct GarrayDeletor {
15     void operator() (GArray *ptr) const { if (ptr) g_array_free(ptr, 1); }
16 };
17
18 template<class T> using unique_ptr_gobj = std::unique_ptr<T, GobjDeletor>;
19 template<class T> using unique_ptr_garray = std::unique_ptr<T, GarrayDeletor>;
20
21 template<class T>
22 unique_ptr_gobj<T> make_gobj_unique(T *ptr)
23 {
24     return unique_ptr_gobj<T>(ptr);
25 }
26
27 template<class T>
28 unique_ptr_garray<T> make_garray_unique(T *ptr)
29 {
30     return unique_ptr_garray<T>(ptr);
31 }
32
33 template<class T>
34 unique_ptr_gobj<T> make_gobj_ref_unique(T *ptr)
35 {
36     g_object_ref(ptr);
37     return unique_ptr_gobj<T>(ptr);
38 }
39
40 char *state_to_char(AtspiStateType state);
41
42 #endif