GnuCash  5.6-150-g038405b370+
guid.h
Go to the documentation of this file.
1 /********************************************************************\
2  * guid.h -- globally unique ID User API *
3  * Copyright (C) 2000 Dave Peticolas <peticola@cs.ucdavis.edu> *
4  * 2014 Aaron Laws <dartmetrash@gmail.com> *
5  * *
6  * This program is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU General Public License as *
8  * published by the Free Software Foundation; either version 2 of *
9  * the License, or (at your option) any later version. *
10  * *
11  * This program is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License*
17  * along with this program; if not, contact: *
18  * *
19  * Free Software Foundation Voice: +1-617-542-5942 *
20  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
21  * Boston, MA 02110-1301, USA gnu@gnu.org *
22  * *
23 \********************************************************************/
24 
25 #ifndef GUID_H
26 #define GUID_H
27 
28 #include <glib-object.h>
29 #include <stddef.h>
30 
31 #ifdef __cplusplus
32 extern "C"
33 {
34 #endif
35 
59 #define GUID_DATA_SIZE 16
60 
61 #define GNC_TYPE_GUID (gnc_guid_get_type())
62 #define GNC_VALUE_HOLDS_GUID(value) G_VALUE_HOLDS(value, GNC_TYPE_GUID)
63 
64 /* We use two definitions for gncguid: one when compiling for C (so that
65  * the object can be persisted), and a different one when compiling for C++
66  * found in guid.hpp
67  */
68 #ifdef __cplusplus
69 namespace gnc {
70 struct GUID;
71 }
72 #endif
73 
75 typedef struct _gncGuid {
76  unsigned char reserved[GUID_DATA_SIZE];
77 } GncGUID;
78 
79 GType gnc_guid_get_type (void);
80 const GncGUID* gnc_value_get_guid (const GValue *value);
81 
84 #define GUID_ENCODING_LENGTH 32
85 
91 void guid_replace (GncGUID *guid);
92 
98 
102 const GncGUID * guid_null (void);
103 
109 GncGUID * guid_malloc (void);
110 
115 GncGUID * guid_new (void);
116 
117 /*Free the guid pointed to. Do not use this guid any more.*/
118 void guid_free (GncGUID *guid);
119 
124 GncGUID *guid_copy (const GncGUID *guid);
125 
138 gchar * guid_to_string (const GncGUID * guid);
139 
154 gchar * guid_to_string_buff (const GncGUID * guid, /*@ out @*/ gchar *buff);
155 
156 
166 gboolean string_to_guid(const gchar * string, /*@ out @*/ GncGUID * guid);
167 
168 
171 gboolean guid_equal(const GncGUID *guid_1, const GncGUID *guid_2);
172 gint guid_compare(const GncGUID *g1, const GncGUID *g2);
173 
175 guint guid_hash_to_guint(gconstpointer ptr);
176 
178 gint guid_g_hash_table_equal (gconstpointer guid_a, gconstpointer guid_b);
179 
182 GHashTable *guid_hash_table_new(void);
183 
184 /* @} */
185 /* @} */
186 #ifdef __cplusplus
187 }
188 #endif
189 
190 #endif
void guid_replace(GncGUID *guid)
Generate a new guid.
Definition: guid.cpp:143
GncGUID guid_new_return(void)
Generate a new id.
Definition: guid.cpp:158
GncGUID * guid_copy(const GncGUID *guid)
Returns a newly allocated GncGUID that matches the passed-in GUID.
Definition: guid.cpp:120
gboolean string_to_guid(const gchar *string, GncGUID *guid)
Given a string, replace the given guid with the parsed one unless the given value is null...
GncGUID * guid_new(void)
Allocate and construct a new GUID.
Definition: guid.cpp:151
GHashTable * guid_hash_table_new(void)
Returns a GHashTable with <GUID*> as key and a <gpointer> as value and no destructor functions for ke...
Definition: guid.cpp:254
gchar * guid_to_string_buff(const GncGUID *guid, gchar *buff)
The guid_to_string_buff() routine puts a null-terminated string encoding of the id into the memory po...
Definition: guid.cpp:173
guint guid_hash_to_guint(gconstpointer ptr)
Hash function for a GUID.
Definition: guid.cpp:228
const GncGUID * gnc_value_get_guid(const GValue *value)
gnc_value_get_guid
Definition: guid.cpp:72
GncGUID * guid_malloc(void)
Allocate memory for a GUID.
Definition: guid.cpp:104
gboolean guid_equal(const GncGUID *guid_1, const GncGUID *guid_2)
Given two GUIDs, return TRUE if they are non-NULL and equal.
Definition: guid.cpp:204
gchar * guid_to_string(const GncGUID *guid)
The guid_to_string() routine returns a null-terminated string encoding of the id. ...
Definition: guid.cpp:164
const GncGUID * guid_null(void)
Returns a GncGUID which is guaranteed to never reference any entity.
Definition: guid.cpp:130
The type used to store guids in C.
Definition: guid.h:75
gint guid_g_hash_table_equal(gconstpointer guid_a, gconstpointer guid_b)
Equality function for two GUIDs in a GHashTable.
Definition: guid.cpp:247