diff options
author | Charlie Brej <cbrej@cs.man.ac.uk> | 2010-08-08 23:11:37 +0100 |
---|---|---|
committer | Charlie Brej <cbrej@cs.man.ac.uk> | 2010-08-08 23:11:37 +0100 |
commit | f60875b05c6f871520e85ab1c901018b86377bab (patch) | |
tree | bf3ddd1ed413926bfadbb2c789fac2c990d698fa | |
parent | 24cc214334eade647ffd7f8c55d9f5f708550f2d (diff) |
Add a record query which directly constructs a record group
-rw-r--r-- | src/libtidbit/tidbit-database.c | 15 | ||||
-rw-r--r-- | src/libtidbit/tidbit-database.h | 1 |
2 files changed, 16 insertions, 0 deletions
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); */ |