mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
add a book-foreach-collection routine
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@9552 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
92aff7f9d0
commit
aee3597d53
@ -236,6 +236,35 @@ qof_book_get_collection (QofBook *book, QofIdType entity_type)
|
||||
return col;
|
||||
}
|
||||
|
||||
struct _iterate {
|
||||
QofCollectionForeachCB fn;
|
||||
gpointer data;
|
||||
};
|
||||
|
||||
static void
|
||||
foreach_cb (gpointer key, gpointer item, gpointer arg)
|
||||
{
|
||||
struct _iterate *iter = arg;
|
||||
QofCollection *col = item;
|
||||
|
||||
iter->fn (col, iter->data);
|
||||
}
|
||||
|
||||
void
|
||||
qof_book_foreach_collection (QofBook *book,
|
||||
QofCollectionForeachCB cb, gpointer user_data)
|
||||
{
|
||||
struct _iterate iter;
|
||||
|
||||
g_return_if_fail (book);
|
||||
g_return_if_fail (cb);
|
||||
|
||||
iter.fn = cb;
|
||||
iter.data = user_data;
|
||||
|
||||
g_hash_table_foreach (book->hash_of_collections, foreach_cb, &iter);
|
||||
}
|
||||
|
||||
/* ====================================================================== */
|
||||
|
||||
gint64
|
||||
|
@ -59,9 +59,13 @@ QofBook * qof_book_new (void);
|
||||
associated with it. */
|
||||
void qof_book_destroy (QofBook *book);
|
||||
|
||||
/** \return The Entity table for the book. */
|
||||
/** \return The table of entities of the given type. */
|
||||
QofCollection * qof_book_get_collection (QofBook *, QofIdType);
|
||||
|
||||
/** Invoke the indicated callback on each collection in the book. */
|
||||
typedef void (*QofCollectionForeachCB) (QofCollection *, gpointer user_data);
|
||||
void qof_book_foreach_collection (QofBook *, QofCollectionForeachCB, gpointer);
|
||||
|
||||
/** \return The kvp data for the book */
|
||||
KvpFrame * qof_book_get_slots (QofBook *book);
|
||||
|
||||
@ -77,6 +81,7 @@ gpointer qof_book_get_data (QofBook *book, const char *key);
|
||||
|
||||
/** DOCUMENT ME! */
|
||||
QofBackend *qof_book_get_backend (QofBook *book);
|
||||
|
||||
void qof_book_set_backend (QofBook *book, QofBackend *);
|
||||
|
||||
/** qof_book_not_saved() will return TRUE if any
|
||||
|
@ -95,9 +95,10 @@ QofIdType qof_collection_get_type (QofCollection *);
|
||||
/** Find the entity going only from its guid */
|
||||
QofEntity * qof_collection_lookup_entity (QofCollection *, const GUID *);
|
||||
|
||||
/* Callback type for qof_entity_foreach */
|
||||
/** Callback type for qof_entity_foreach */
|
||||
typedef void (*QofEntityForeachCB) (QofEntity *, gpointer user_data);
|
||||
|
||||
/** Call the callback for each entity in the collection. */
|
||||
void qof_collection_foreach (QofCollection *,
|
||||
QofEntityForeachCB, gpointer user_data);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user