xmlnode.h

Go to the documentation of this file.
00001 
00006 /* purple
00007  *
00008  * Purple is the legal property of its developers, whose names are too numerous
00009  * to list here.  Please refer to the COPYRIGHT file distributed with this
00010  * source distribution.
00011  *
00012  * This program is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU General Public License as published by
00014  * the Free Software Foundation; either version 2 of the License, or
00015  * (at your option) any later version.
00016  *
00017  * This program is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  * GNU General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU General Public License
00023  * along with this program; if not, write to the Free Software
00024  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
00025  */
00026 #ifndef _PURPLE_XMLNODE_H_
00027 #define _PURPLE_XMLNODE_H_
00028 
00029 #include <glib.h>
00030 
00031 #ifdef __cplusplus
00032 extern "C" {
00033 #endif
00034 
00038 typedef enum _XMLNodeType
00039 {
00040     XMLNODE_TYPE_TAG,       
00041     XMLNODE_TYPE_ATTRIB,        
00042     XMLNODE_TYPE_DATA       
00043 } XMLNodeType;
00044 
00048 typedef struct _xmlnode xmlnode;
00049 struct _xmlnode
00050 {
00051     char *name;         
00052     char *xmlns;        
00053     XMLNodeType type;       
00054     char *data;         
00055     size_t data_sz;         
00056     xmlnode *parent;            
00057     xmlnode *child;             
00058     xmlnode *lastchild;         
00059     xmlnode *next;              
00060     char *prefix;               
00061     GHashTable *namespace_map;  
00062 };
00063 
00071 xmlnode *xmlnode_new(const char *name);
00072 
00081 xmlnode *xmlnode_new_child(xmlnode *parent, const char *name);
00082 
00089 void xmlnode_insert_child(xmlnode *parent, xmlnode *child);
00090 
00099 xmlnode *xmlnode_get_child(const xmlnode *parent, const char *name);
00100 
00110 xmlnode *xmlnode_get_child_with_namespace(const xmlnode *parent, const char *name, const char *xmlns);
00111 
00119 xmlnode *xmlnode_get_next_twin(xmlnode *node);
00120 
00129 void xmlnode_insert_data(xmlnode *node, const char *data, gssize size);
00130 
00139 char *xmlnode_get_data(const xmlnode *node);
00140 
00149 char *xmlnode_get_data_unescaped(const xmlnode *node);
00150 
00158 void xmlnode_set_attrib(xmlnode *node, const char *attr, const char *value);
00159 
00160 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_XMLNODE_C_)
00161 
00171 void xmlnode_set_attrib_with_prefix(xmlnode *node, const char *attr, const char *prefix, const char *value);
00172 
00183 void xmlnode_set_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns, const char *value);
00184 #endif /* PURPLE_DISABLE_DEPRECATED */
00185 
00197 void xmlnode_set_attrib_full(xmlnode *node, const char *attr, const char *xmlns,
00198     const char *prefix, const char *value);
00199 
00208 const char *xmlnode_get_attrib(xmlnode *node, const char *attr);
00209 
00219 const char *xmlnode_get_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns);
00220 
00227 void xmlnode_remove_attrib(xmlnode *node, const char *attr);
00228 
00236 void xmlnode_remove_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns);
00237 
00244 void xmlnode_set_namespace(xmlnode *node, const char *xmlns);
00245 
00252 const char *xmlnode_get_namespace(xmlnode *node);
00253 
00260 void xmlnode_set_prefix(xmlnode *node, const char *prefix);
00261 
00268 const char *xmlnode_get_prefix(const xmlnode *node);
00269 
00279 xmlnode *xmlnode_get_parent(const xmlnode *child);
00280 
00290 char *xmlnode_to_str(const xmlnode *node, int *len);
00291 
00302 char *xmlnode_to_formatted_str(const xmlnode *node, int *len);
00303 
00315 xmlnode *xmlnode_from_str(const char *str, gssize size);
00316 
00324 xmlnode *xmlnode_copy(const xmlnode *src);
00325 
00331 void xmlnode_free(xmlnode *node);
00332 
00349 xmlnode *xmlnode_from_file(const char *dir, const char *filename,
00350                const char *description, const char *process);
00351 
00352 #ifdef __cplusplus
00353 }
00354 #endif
00355 
00356 #endif /* _PURPLE_XMLNODE_H_ */