aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/database-private.h
diff options
context:
space:
mode:
authorGravatar Jan Janak <jan@ryngle.com>2009-11-23 01:10:54 +0100
committerGravatar Carl Worth <cworth@cworth.org>2009-11-26 07:01:52 -0800
commitc3c52e464b8b0e024a01feacfeb34cc4ce1f3d62 (patch)
tree18903b3db44adf186a95fa2b63f645e2c40c9488 /lib/database-private.h
parent34c840a23e1db4c6cf4a836b441d027fc17e9706 (diff)
notmuch: New function to retrieve all tags from the database.
This patch adds a new function called notmuch_database_get_all_tags which can be used to obtain a list of all tags from the database (in other words, the list contains all tags from all messages). The function produces an alphabetically sorted list. To add support for the new function, we rip the guts off of notmuch_message_get_tags and put them in a new generic function called _notmuch_convert_tags. The generic function takes a Xapian::TermIterator as argument and uses the iterator to find tags. This makes the function usable with different Xapian objects. Function notmuch_message_get_tags is then reimplemented to call the generic function with message->doc.termlist_begin() as argument. Similarly, we implement notmuch_message_database_get_all_tags, the function calls the generic function with db->xapian_db->allterms_begin() as argument. Finally, notmuch_database_get_all_tags is exported through lib/notmuch.h Signed-off-by: Jan Janak <jan@ryngle.com>
Diffstat (limited to 'lib/database-private.h')
-rw-r--r--lib/database-private.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/database-private.h b/lib/database-private.h
index 431966fb..643b0507 100644
--- a/lib/database-private.h
+++ b/lib/database-private.h
@@ -35,4 +35,17 @@ struct _notmuch_database {
Xapian::ValueRangeProcessor *value_range_processor;
};
+/* Convert tags from Xapian internal format to notmuch format.
+ *
+ * The function gets a TermIterator as argument and uses that iterator to find
+ * all tag terms in the object. The tags are then converted to a
+ * notmuch_tags_t list and returned. The function needs to allocate memory for
+ * the resulting list and it uses the argument ctx as talloc context.
+ *
+ * The function returns NULL on failure.
+ */
+notmuch_tags_t *
+_notmuch_convert_tags (void *ctx, Xapian::TermIterator &i,
+ Xapian::TermIterator &end);
+
#endif