1 /* Lasem
2  *
3  * Copyright © 2010 Emmanuel Pacaud
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General
16  * Public License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18  * Boston, MA 02111-1307, USA.
19  *
20  * Author:
21  * 	Emmanuel Pacaud <emmanuel@gnome.org>
22  */
23 
24 #include <lsmdomnamednodemap.h>
25 #include <lsmdomnode.h>
26 
27 /**
28  * SECTION:lsmdomnamednodemap
29  * @short_description: Base class for DOM named node maps
30  */
31 
32 /* LsmDomNamedNodeMap implementation */
33 
34 /**
35  * lsm_dom_named_node_map_get_named_item:
36  * @map: a #LsmDomNamedNodeMap
37  * @name: name of the requested item
38  *
39  * Returns: (transfer none): The corresponding node, NULL if not found.
40  */
41 
42 LsmDomNode *
lsm_dom_named_node_map_get_named_item(LsmDomNamedNodeMap * map,const char * name)43 lsm_dom_named_node_map_get_named_item (LsmDomNamedNodeMap *map, const char *name)
44 {
45 	g_return_val_if_fail (LSM_IS_DOM_NAMED_NODE_MAP (map), NULL);
46 
47 	return LSM_DOM_NAMED_NODE_MAP_GET_CLASS (map)->get (map, name);
48 }
49 
50 /**
51  * lsm_dom_named_node_map_set_named_item:
52  * @map: a #LsmDomNamedNodeMap
53  * @node: a #LsmDomNode
54  *
55  * Returns: (transfer none): same as @node, NULL on error.
56  */
57 
58 LsmDomNode *
lsm_dom_named_node_map_set_named_item(LsmDomNamedNodeMap * map,LsmDomNode * node)59 lsm_dom_named_node_map_set_named_item (LsmDomNamedNodeMap *map, LsmDomNode *node)
60 {
61 	g_return_val_if_fail (LSM_IS_DOM_NAMED_NODE_MAP (map), NULL);
62 
63 	return LSM_DOM_NAMED_NODE_MAP_GET_CLASS (map)->set (map, node);
64 }
65 
66 /**
67  * lsm_dom_named_node_map_remove_named_item:
68  * @map: a #LsmDomNamedNodeMap
69  * @name: name of the item to remove
70  *
71  * Returns: (transfer full): removed node, NULL on error.
72  */
73 
74 LsmDomNode *
lsm_dom_named_node_map_remove_named_item(LsmDomNamedNodeMap * map,const char * name)75 lsm_dom_named_node_map_remove_named_item (LsmDomNamedNodeMap *map, const char *name)
76 {
77 	g_return_val_if_fail (LSM_IS_DOM_NAMED_NODE_MAP (map), NULL);
78 
79 	return LSM_DOM_NAMED_NODE_MAP_GET_CLASS (map)->remove (map, name);
80 }
81 
82 /**
83  * lsm_dom_named_node_map_get_item:
84  * @map: a #LsmDomNamedNodeMap
85  * @index: item index
86  *
87  * Returns: (transfer none): The node corresponding to @index, NULL on error.
88  */
89 
90 LsmDomNode *
lsm_dom_named_node_map_get_item(LsmDomNamedNodeMap * map,unsigned int index)91 lsm_dom_named_node_map_get_item (LsmDomNamedNodeMap *map, unsigned int index)
92 {
93 	g_return_val_if_fail (LSM_IS_DOM_NAMED_NODE_MAP (map), NULL);
94 
95 	return LSM_DOM_NAMED_NODE_MAP_GET_CLASS (map)->get_item (map, index);
96 }
97 
98 unsigned int
lsm_dom_named_node_map_get_length(LsmDomNamedNodeMap * map)99 lsm_dom_named_node_map_get_length (LsmDomNamedNodeMap *map)
100 {
101 	g_return_val_if_fail (LSM_IS_DOM_NAMED_NODE_MAP (map), 0);
102 
103 	return LSM_DOM_NAMED_NODE_MAP_GET_CLASS (map)->get_length (map);
104 }
105 
106 static void
lsm_dom_named_node_map_init(LsmDomNamedNodeMap * map)107 lsm_dom_named_node_map_init (LsmDomNamedNodeMap *map)
108 {
109 }
110 
111 /* LsmDomNamedNodeMap class */
112 
113 static void
lsm_dom_named_node_map_class_init(LsmDomNamedNodeMapClass * klass)114 lsm_dom_named_node_map_class_init (LsmDomNamedNodeMapClass *klass)
115 {
116 }
117 
118 G_DEFINE_ABSTRACT_TYPE (LsmDomNamedNodeMap, lsm_dom_named_node_map, G_TYPE_OBJECT)
119