TIVI-1924: Initial commit of IVI settings daemon.
[profile/ivi/settings-daemon.git] / include / settingsd / json_glib_traits.hpp
1 /**
2  * @file json_glib_traits.hpp
3  *
4  * @brief @c JSON-GLib traits.
5  *
6  * @author Ossama Othman @<ossama.othman@@intel.com@>
7  *
8  * @copyright @par
9  * Copyright 2013 Intel Corporation All Rights Reserved.
10  * @par
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation;
14  * version 2.1 of the License.
15  * @par
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Lesser General Public License for more details.
20  * @par
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with this library; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
24  * Boston, MA  02110-1301  USA
25  */
26
27 #ifndef IVI_SETTINGS_JSON_GLIB_TRAITS_HPP
28 #define IVI_SETTINGS_JSON_GLIB_TRAITS_HPP
29
30 #include <glib.h>
31 #include <json-glib/json-glib.h>
32
33
34 namespace ivi
35 {
36   namespace settings
37   {
38     template<typename T> struct traits;
39
40     template<>
41     struct traits<JsonNode>
42     {
43       static void release(JsonNode * p) { json_node_free(p); }
44     };
45
46     template<>
47     struct traits<JsonParser>
48     {
49       static void
50       release(JsonParser * p)
51       {
52         if (p != nullptr)
53           g_object_unref(p);
54       }
55     };
56
57     template<>
58     struct traits<JsonReader>
59     {
60       static void
61       release(JsonReader * p)
62       {
63         if (p != nullptr)
64           g_object_unref(p);
65       }
66     };
67
68     template<>
69     struct traits<JsonBuilder>
70     {
71       static void
72       release(JsonBuilder * p)
73       {
74         if (p != nullptr)
75           g_object_unref(p);
76       }
77     };
78
79     template<>
80     struct traits<JsonGenerator>
81     {
82       static void
83       release(JsonGenerator * p)
84       {
85         if (p != nullptr)
86           g_object_unref(p);
87       }
88     };
89
90   }
91 }
92
93
94 #endif /* IVI_SETTINGS_JSON_GLIB_TRAITS_HPP */
95
96
97 // Local Variables:
98 // mode:c++
99 // c-basic-offset:2
100 // indent-tabs-mode: nil
101 // End: