[Gnucash-changes] qof_collection_count

Neil Williams codehelp at cvs.gnucash.org
Sun Jun 19 18:47:23 EDT 2005


Log Message:
-----------
qof_collection_count

Tags:
----
gnucash-gnome2-dev

Modified Files:
--------------
    gnucash:
        ChangeLog
    gnucash/src/engine:
        qofid.c
        qofid.h

Revision Data
-------------
Index: ChangeLog
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/ChangeLog,v
retrieving revision 1.1487.2.233
retrieving revision 1.1487.2.234
diff -LChangeLog -LChangeLog -u -r1.1487.2.233 -r1.1487.2.234
--- ChangeLog
+++ ChangeLog
@@ -1,4 +1,8 @@
 2005-06-19  Neil Williams <linux at codehelp.co.uk>
+	* qofid.c:
+	* qofid.h: qof_collection_count
+
+2005-06-19  Neil Williams <linux at codehelp.co.uk>
 	* src/engine/qof_book_merge.c: Re-organising to
 	use static functions.
 	* src/engine/qof_book_merge.h: Setting public API.
Index: qofid.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofid.h,v
retrieving revision 1.2.6.8
retrieving revision 1.2.6.9
diff -Lsrc/engine/qofid.h -Lsrc/engine/qofid.h -u -r1.2.6.8 -r1.2.6.9
--- src/engine/qofid.h
+++ src/engine/qofid.h
@@ -160,6 +160,9 @@
 /** create a new collection of entities of type */
 QofCollection * qof_collection_new (QofIdType type);
 
+/** return the number of entities in the collection. */
+guint qof_collection_count (QofCollection *col);
+
 /** destroy the collection */
 void qof_collection_destroy (QofCollection *col);
 
@@ -229,6 +232,19 @@
 gint
 qof_collection_compare (QofCollection *target, QofCollection *merge);
 
+/** \brief Create a secondary collection from a GList
+
+ at param type The QofIdType of the QofCollection \b and of 
+	\b all entities in the GList.
+ at param list GList of entities of the same QofIdType.
+
+ at return NULL if any of the entities fail to match the
+	QofCollection type, else a pointer to the collection
+	on success.
+*/
+QofCollection*
+qof_collection_from_glist (QofIdType type, GList *glist);
+
 /** @} */
 
 #endif /* QOF_ID_H */
Index: qofid.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofid.c,v
retrieving revision 1.3.2.7
retrieving revision 1.3.2.8
diff -Lsrc/engine/qofid.c -Lsrc/engine/qofid.c -u -r1.3.2.7 -r1.3.2.8
--- src/engine/qofid.c
+++ src/engine/qofid.c
@@ -296,6 +296,34 @@
   return ent;
 }
 
+QofCollection *
+qof_collection_from_glist (QofIdType type, GList *glist)
+{
+	QofCollection *coll;
+	QofEntity *ent;
+	GList *list;
+
+	coll = qof_collection_new(type);
+	for(list = glist; list != NULL; list = list->next)
+	{
+		ent = (QofEntity*)list->data;
+		if(FALSE == qof_collection_add_entity(coll, ent))
+		{
+			return NULL;
+		}
+	}
+	return coll;
+}
+
+guint
+qof_collection_count (QofCollection *col)
+{
+	guint c;
+
+	c = g_hash_table_size(col->hash_of_entities);
+	return c;
+}
+
 /* =============================================================== */
 
 gboolean 


More information about the gnucash-changes mailing list