GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
qofid.h
Go to the documentation of this file.
1 /********************************************************************\
2  * qofid.h -- QOF entity type identification system *
3  * *
4  * This program is free software; you can redistribute it and/or *
5  * modify it under the terms of the GNU General Public License as *
6  * published by the Free Software Foundation; either version 2 of *
7  * the License, or (at your option) any later version. *
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 *
12  * GNU General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU General Public License*
15  * along with this program; if not, contact: *
16  * *
17  * Free Software Foundation Voice: +1-617-542-5942 *
18  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
19  * Boston, MA 02110-1301, USA [email protected] *
20  * *
21 \********************************************************************/
22 
23 #ifndef QOF_ID_H
24 #define QOF_ID_H
25 
26 #ifdef __cplusplus
27 extern "C"
28 {
29 #endif
30 
81 #include <string.h>
82 #include "guid.h"
83 
85 typedef const gchar * QofIdType;
87 typedef const gchar * QofIdTypeConst;
89 typedef const gchar* QofLogModule;
90 
91 typedef struct QofCollection_s QofCollection;
92 
93 #include "qofinstance.h"
94 
95 #define QOF_ID_NONE NULL
96 #define QOF_ID_NULL "null"
97 
98 #define QOF_ID_BOOK "Book"
99 #define QOF_ID_SESSION "Session"
100 
102 #ifndef _MSC_VER
103 # define QSTRCMP(da,db) ({ \
104  gint val = 0; \
105  if ((da) && (db)) { \
106  if ((da) != (db)) { \
107  val = strcmp ((da), (db)); \
108  } \
109  } else \
110  if ((!(da)) && (db)) { \
111  val = -1; \
112  } else \
113  if ((da) && (!(db))) { \
114  val = 1; \
115  } \
116  val; /* block assumes value of last statement */ \
117 })
118 #else
119 /* MSVC: Simply use g_strcmp */
120 # define QSTRCMP g_strcmp0
121 #endif
122 
124 #define QOF_CHECK_TYPE(obj,type) (((obj) != NULL) && \
125  (0 == QSTRCMP((type),(((QofInstance *)(obj))->e_type))))
126 
129 #define QOF_CHECK_CAST(obj,e_type,c_type) ( \
130  QOF_CHECK_TYPE((obj),(e_type)) ? \
131  (c_type *) (obj) : \
132  (c_type *) ({ \
133  g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \
134  "Error: Bad QofInstance at %s:%d", __FILE__, __LINE__); \
135  (obj); \
136  }))
137 
138 
156 gboolean qof_get_alt_dirty_mode (void);
157 
164 void qof_set_alt_dirty_mode (gboolean enabled);
165 
170 QofCollection * qof_collection_new (QofIdType type);
171 
173 guint qof_collection_count (const QofCollection *col);
174 
176 void qof_collection_destroy (QofCollection *col);
177 
179 QofIdType qof_collection_get_type (const QofCollection *);
180 
182 /*@ dependent @*/
183 QofInstance * qof_collection_lookup_entity (const QofCollection *, const GncGUID *);
184 
186 typedef void (*QofInstanceForeachCB) (QofInstance *, gpointer user_data);
187 
189 void qof_collection_foreach (const QofCollection *, QofInstanceForeachCB,
190  gpointer user_data);
191 
198 gpointer qof_collection_get_data (const QofCollection *col);
199 void qof_collection_set_data (QofCollection *col, gpointer user_data);
200 
202 gboolean qof_collection_is_dirty (const QofCollection *col);
203 
224 gboolean
225 qof_collection_add_entity (QofCollection *coll, QofInstance *ent);
226 
227 void qof_collection_remove_entity (QofInstance *ent);
228 
240 gint
241 qof_collection_compare (QofCollection *target, QofCollection *merge);
242 
253 QofCollection*
254 qof_collection_from_glist (QofIdType type, const GList *glist);
255 
259 #ifdef __cplusplus
260 }
261 #endif
262 
263 #endif /* QOF_ID_H */
264 
gboolean qof_collection_is_dirty(const QofCollection *col)
QofInstance * qof_collection_lookup_entity(const QofCollection *, const GncGUID *)
const gchar * QofIdTypeConst
Definition: qofid.h:87
void qof_set_alt_dirty_mode(gboolean enabled)
globally unique ID User API
Object instance holds common fields that most gnucash objects use.
void qof_collection_foreach(const QofCollection *, QofInstanceForeachCB, gpointer user_data)
Definition: guid.h:65
gint qof_collection_compare(QofCollection *target, QofCollection *merge)
Compare two secondary collections.
const gchar * QofIdType
Definition: qofid.h:85
QofCollection * qof_collection_from_glist(QofIdType type, const GList *glist)
Create a secondary collection from a GList.
void(* QofInstanceForeachCB)(QofInstance *, gpointer user_data)
Definition: qofid.h:186
void qof_collection_destroy(QofCollection *col)
QofIdType qof_collection_get_type(const QofCollection *)
gboolean qof_collection_add_entity(QofCollection *coll, QofInstance *ent)
Add an entity to a QOF_TYPE_COLLECT.
guint qof_collection_count(const QofCollection *col)
gpointer qof_collection_get_data(const QofCollection *col)
gboolean qof_get_alt_dirty_mode(void)
const gchar * QofLogModule
Definition: qofid.h:89
QofCollection * qof_collection_new(QofIdType type)