From f60875b05c6f871520e85ab1c901018b86377bab Mon Sep 17 00:00:00 2001 From: Charlie Brej Date: Sun, 8 Aug 2010 23:11:37 +0100 Subject: Add a record query which directly constructs a record group --- src/libtidbit/tidbit-database.c | 15 +++++++++++++++ src/libtidbit/tidbit-database.h | 1 + 2 files changed, 16 insertions(+) diff --git a/src/libtidbit/tidbit-database.c b/src/libtidbit/tidbit-database.c index 6e46f54..78ec9dc 100644 --- a/src/libtidbit/tidbit-database.c +++ b/src/libtidbit/tidbit-database.c @@ -75,3 +75,18 @@ PtrTidbitGuidGroup tidbit_database_query (PtrTidbitDatabase database, PtrTidbitQ g_assert(database->functions->query); return database->functions->query(database, query); } + +PtrTidbitRecordGroup tidbit_database_record_query (PtrTidbitDatabase database, PtrTidbitQuery query) +{ + g_assert(database); + g_assert(query); + PtrTidbitGuidGroup guid_group = tidbit_database_query (database, query); + PtrTidbitRecordGroup record_group = tidbit_record_group_new (); + for (int i = 0; i < guid_group->data->len; i++){ + PtrTidbitRecord record = tidbit_database_fetch (database, g_ptr_array_index(guid_group->data, i)); + tidbit_record_group_add_record (record_group, record); + tidbit_record_unref (record); + } + tidbit_guid_group_unref (guid_group); + return record_group; +} diff --git a/src/libtidbit/tidbit-database.h b/src/libtidbit/tidbit-database.h index 19bdcf1..d6d6d7e 100644 --- a/src/libtidbit/tidbit-database.h +++ b/src/libtidbit/tidbit-database.h @@ -45,6 +45,7 @@ void tidbit_database_unref (PtrTidbitDatabase database); unsigned int tidbit_database_insert (PtrTidbitDatabase database, PtrTidbitRecord record); PtrTidbitRecord tidbit_database_fetch (PtrTidbitDatabase database, PtrTidbitGuid guid); PtrTidbitGuidGroup tidbit_database_query (PtrTidbitDatabase database, PtrTidbitQuery query); +PtrTidbitRecordGroup tidbit_database_record_query (PtrTidbitDatabase database, PtrTidbitQuery query); */ -- cgit v1.2.3