Fix FSF address (Tobias Mueller, #470445)
[platform/upstream/evolution-data-server.git] / libedataserver / e-xml-hash-utils.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /* 
3  * Copyright (C) 2001-2003 Ximian, Inc.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of version 2 of the GNU Lesser General Public
7  * License as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this program; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19
20 #ifndef __E_XML_HASH_UTILS_H__
21 #define __E_XML_HASH_UTILS_H__
22
23 #include <glib.h>
24 #include <libxml/parser.h>
25
26 G_BEGIN_DECLS
27
28 /**
29  * EXmlHashType:
30  * @E_XML_HASH_TYPE_OBJECT_UID: Use the object UID as the hash key.
31  * @E_XML_HASH_TYPE_PROPERTY: Use the property name as the hash key.
32  **/
33 typedef enum {
34         E_XML_HASH_TYPE_OBJECT_UID,
35         E_XML_HASH_TYPE_PROPERTY
36 } EXmlHashType;
37
38 GHashTable *e_xml_to_hash      (xmlDoc       *doc,
39                                 EXmlHashType  type);
40 xmlDoc     *e_xml_from_hash    (GHashTable   *hash,
41                                 EXmlHashType  type,
42                                 const char   *root_node);
43
44 void        e_xml_destroy_hash (GHashTable   *hash);
45
46
47
48 /**
49  * EXmlHashStatus:
50  * @E_XMLHASH_STATUS_SAME: The compared values are the same.
51  * @E_XMLHASH_STATUS_DIFFERENT: The compared values are different.
52  * @E_XMLHASH_STATUS_NOT_FOUND: The key to compare against was not found.
53  **/
54 typedef enum {
55         E_XMLHASH_STATUS_SAME,
56         E_XMLHASH_STATUS_DIFFERENT,
57         E_XMLHASH_STATUS_NOT_FOUND
58 } EXmlHashStatus;
59
60 typedef void (* EXmlHashFunc) (const char *key, const char *value, gpointer user_data);
61 typedef gboolean (* EXmlHashRemoveFunc) (const char *key, const char *value, gpointer user_data);
62
63 typedef struct EXmlHash EXmlHash;
64
65 EXmlHash      *e_xmlhash_new         (const char   *filename);
66
67 void           e_xmlhash_add         (EXmlHash     *hash,
68                                       const char   *key,
69                                       const char   *data);
70 void           e_xmlhash_remove      (EXmlHash     *hash,
71                                       const char   *key);
72
73 EXmlHashStatus e_xmlhash_compare     (EXmlHash     *hash,
74                                       const char   *key,
75                                       const char   *compare_data);
76 void           e_xmlhash_foreach_key (EXmlHash     *hash,
77                                       EXmlHashFunc  func,
78                                       gpointer      user_data);
79 void           e_xmlhash_foreach_key_remove (EXmlHash     *hash,
80                                       EXmlHashRemoveFunc  func,
81                                       gpointer      user_data);
82
83 void           e_xmlhash_write       (EXmlHash     *hash);
84 void           e_xmlhash_destroy     (EXmlHash     *hash);
85
86 G_END_DECLS
87
88 #endif