xmlnode.h
Go to the documentation of this file.
1 
6 /* purple
7  *
8  * Purple is the legal property of its developers, whose names are too numerous
9  * to list here. Please refer to the COPYRIGHT file distributed with this
10  * source distribution.
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
25  */
26 #ifndef _PURPLE_XMLNODE_H_
27 #define _PURPLE_XMLNODE_H_
28 
29 #include <glib.h>
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
38 typedef enum _XMLNodeType
39 {
43 } XMLNodeType;
44 
48 typedef struct _xmlnode xmlnode;
49 struct _xmlnode
50 {
51  char *name;
52  char *xmlns;
54  char *data;
55  size_t data_sz;
60  char *prefix;
61  GHashTable *namespace_map;
62 };
63 
71 xmlnode *xmlnode_new(const char *name);
72 
81 xmlnode *xmlnode_new_child(xmlnode *parent, const char *name);
82 
89 void xmlnode_insert_child(xmlnode *parent, xmlnode *child);
90 
99 xmlnode *xmlnode_get_child(const xmlnode *parent, const char *name);
100 
110 xmlnode *xmlnode_get_child_with_namespace(const xmlnode *parent, const char *name, const char *xmlns);
111 
120 
129 void xmlnode_insert_data(xmlnode *node, const char *data, gssize size);
130 
139 char *xmlnode_get_data(const xmlnode *node);
140 
149 char *xmlnode_get_data_unescaped(const xmlnode *node);
150 
158 void xmlnode_set_attrib(xmlnode *node, const char *attr, const char *value);
159 
160 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_XMLNODE_C_)
161 
171 void xmlnode_set_attrib_with_prefix(xmlnode *node, const char *attr, const char *prefix, const char *value);
172 
183 void xmlnode_set_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns, const char *value);
184 #endif /* PURPLE_DISABLE_DEPRECATED */
185 
197 void xmlnode_set_attrib_full(xmlnode *node, const char *attr, const char *xmlns,
198  const char *prefix, const char *value);
199 
208 const char *xmlnode_get_attrib(const xmlnode *node, const char *attr);
209 
219 const char *xmlnode_get_attrib_with_namespace(const xmlnode *node, const char *attr, const char *xmlns);
220 
227 void xmlnode_remove_attrib(xmlnode *node, const char *attr);
228 
236 void xmlnode_remove_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns);
237 
244 void xmlnode_set_namespace(xmlnode *node, const char *xmlns);
245 
252 const char *xmlnode_get_namespace(xmlnode *node);
253 
260 void xmlnode_set_prefix(xmlnode *node, const char *prefix);
261 
268 const char *xmlnode_get_prefix(const xmlnode *node);
269 
279 xmlnode *xmlnode_get_parent(const xmlnode *child);
280 
290 char *xmlnode_to_str(const xmlnode *node, int *len);
291 
302 char *xmlnode_to_formatted_str(const xmlnode *node, int *len);
303 
315 xmlnode *xmlnode_from_str(const char *str, gssize size);
316 
324 xmlnode *xmlnode_copy(const xmlnode *src);
325 
331 void xmlnode_free(xmlnode *node);
332 
349 xmlnode *xmlnode_from_file(const char *dir, const char *filename,
350  const char *description, const char *process);
351 
352 #ifdef __cplusplus
353 }
354 #endif
355 
356 #endif /* _PURPLE_XMLNODE_H_ */
char * xmlnode_get_data_unescaped(const xmlnode *node)
Gets unescaped data from a node.
const char * xmlnode_get_prefix(const xmlnode *node)
Returns the prefix of a node.
void xmlnode_set_attrib(xmlnode *node, const char *attr, const char *value)
Sets an attribute for a node.
xmlnode * xmlnode_get_child_with_namespace(const xmlnode *parent, const char *name, const char *xmlns)
Gets a child node named name in a namespace.
xmlnode * xmlnode_get_child(const xmlnode *parent, const char *name)
Gets a child node named name.
void xmlnode_remove_attrib(xmlnode *node, const char *attr)
Removes an attribute from a node.
char * prefix
The namespace prefix if any.
Definition: xmlnode.h:60
xmlnode * parent
The parent node or NULL.
Definition: xmlnode.h:56
const char * xmlnode_get_attrib_with_namespace(const xmlnode *node, const char *attr, const char *xmlns)
Gets a namespaced attribute from a node.
xmlnode * xmlnode_new_child(xmlnode *parent, const char *name)
Creates a new xmlnode child.
xmlnode * xmlnode_from_file(const char *dir, const char *filename, const char *description, const char *process)
Creates a node from a XML File.
char * data
The data for the node.
Definition: xmlnode.h:54
char * xmlnode_get_data(const xmlnode *node)
Gets (escaped) data from a node.
char * name
The name of the node.
Definition: xmlnode.h:51
void xmlnode_set_namespace(xmlnode *node, const char *xmlns)
Sets the namespace of a node.
void xmlnode_set_attrib_full(xmlnode *node, const char *attr, const char *xmlns, const char *prefix, const char *value)
Sets a namespaced attribute for a node.
xmlnode * child
The child node or NULL.
Definition: xmlnode.h:57
void xmlnode_set_attrib_with_prefix(xmlnode *node, const char *attr, const char *prefix, const char *value)
Sets a prefixed attribute for a node.
Has attributes.
Definition: xmlnode.h:41
Just a tag.
Definition: xmlnode.h:40
const char * xmlnode_get_namespace(xmlnode *node)
Returns the namespace of a node.
GHashTable * namespace_map
The namespace map.
Definition: xmlnode.h:61
_XMLNodeType
The valid types for an xmlnode.
Definition: xmlnode.h:38
const char * xmlnode_get_attrib(const xmlnode *node, const char *attr)
Gets an attribute from a node.
size_t data_sz
The size of the data.
Definition: xmlnode.h:55
Has data.
Definition: xmlnode.h:42
void xmlnode_insert_child(xmlnode *parent, xmlnode *child)
Inserts a node into a node as a child.
void xmlnode_remove_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns)
Removes a namespaced attribute from a node.
xmlnode * xmlnode_from_str(const char *str, gssize size)
Creates a node from a string of XML.
void xmlnode_free(xmlnode *node)
Frees a node and all of its children.
void xmlnode_insert_data(xmlnode *node, const char *data, gssize size)
Inserts data into a node.
char * xmlns
The namespace of the node.
Definition: xmlnode.h:52
xmlnode * lastchild
The last child node or NULL.
Definition: xmlnode.h:58
void xmlnode_set_prefix(xmlnode *node, const char *prefix)
Sets the prefix of a node.
XMLNodeType type
The type of the node.
Definition: xmlnode.h:53
char * xmlnode_to_formatted_str(const xmlnode *node, int *len)
Returns the node in a string of human readable xml.
xmlnode * next
The next node or NULL.
Definition: xmlnode.h:59
xmlnode * xmlnode_copy(const xmlnode *src)
Creates a new node from the source node.
xmlnode * xmlnode_get_parent(const xmlnode *child)
Gets the parent node.
xmlnode * xmlnode_new(const char *name)
Creates a new xmlnode.
void xmlnode_set_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns, const char *value)
Sets a namespaced attribute for a node.
xmlnode * xmlnode_get_next_twin(xmlnode *node)
Gets the next node with the same name as node.
enum _XMLNodeType XMLNodeType
The valid types for an xmlnode.
char * xmlnode_to_str(const xmlnode *node, int *len)
Returns the node in a string of xml.