From 8be9efb931773da4afc90ddaa1776387a9cea630 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 3 Mar 2012 21:42:30 +0000 Subject: Add sord_iter_get_node(). git-svn-id: http://svn.drobilla.net/sord/trunk@201 3d64ff67-21c5-427c-a301-fe4f08042e5a --- ChangeLog | 1 + sord/sord.h | 7 +++++++ src/sord.c | 6 ++++++ src/sord_test.c | 10 ++++++---- wscript | 2 +- 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 69dd838..68fb5f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,7 @@ sord (UNRELEASED) unstable; urgency=low * Fix comparison of typed literals * Take advantage of interning in sord_node_equals() * Support compilation as C++ under MSVC++. + * Add sord_iter_get_node() -- David Robillard (UNRELEASED) diff --git a/sord/sord.h b/sord/sord.h index e6f5bd8..7d3412e 100644 --- a/sord/sord.h +++ b/sord/sord.h @@ -392,6 +392,13 @@ SORD_API void sord_iter_get(const SordIter* iter, SordQuad quad); +/** + Return a field of the quad pointed to by @c iter. +*/ +SORD_API +const SordNode* +sord_iter_get_node(const SordIter* iter, SordQuadIndex index); + /** Return the store pointed to by @c iter. */ diff --git a/src/sord.c b/src/sord.c index 249fb0d..eac5087 100644 --- a/src/sord.c +++ b/src/sord.c @@ -421,6 +421,12 @@ sord_iter_get(const SordIter* iter, SordQuad id) } } +const SordNode* +sord_iter_get_node(const SordIter* iter, SordQuadIndex index) +{ + return ((SordNode**)zix_tree_get(iter->cur))[index]; +} + bool sord_iter_next(SordIter* iter) { diff --git a/src/sord_test.c b/src/sord_test.c index 279c147..15d4ad6 100644 --- a/src/sord_test.c +++ b/src/sord_test.c @@ -25,7 +25,6 @@ static const int DIGITS = 3; static const int MAX_NUM = 999; static const int n_objects_per = 2; - typedef struct { SordQuad query; int expected_num_results; @@ -299,9 +298,12 @@ test_read(SordWorld* world, SordModel* sord, SordNode* g, if (id[0] == last_subject) continue; - SordQuad subpat = { id[0], 0, 0 }; - SordIter* subiter = sord_find(sord, subpat); - int num_sub_results = 0; + SordQuad subpat = { id[0], 0, 0 }; + SordIter* subiter = sord_find(sord, subpat); + int num_sub_results = 0; + if (sord_iter_get_node(subiter, SORD_SUBJECT) != id[0]) { + return test_fail("Fail: Incorrect initial submatch\n"); + } for (; !sord_iter_end(subiter); sord_iter_next(subiter)) { SordQuad subid; sord_iter_get(subiter, subid); diff --git a/wscript b/wscript index 8e6e624..7ee89ba 100644 --- a/wscript +++ b/wscript @@ -8,7 +8,7 @@ from waflib.extras import autowaf as autowaf import waflib.Logs as Logs, waflib.Options as Options # Version of this package (even if built as a child) -SORD_VERSION = '0.5.0' +SORD_VERSION = '0.6.0' SORD_MAJOR_VERSION = '0' # Library version (UNIX style major, minor, micro) -- cgit v1.2.1