From: Carl Worth Date: Thu, 28 Oct 2010 17:30:26 +0000 (-0700) Subject: lib: Add two functions: notmuch_query_get_query_string and _get_sort X-Git-Tag: 0.4~39 X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=e83b40138ef3dd116001a4c53150d0a3274b41c0;p=obsolete%2Fnotmuch-old lib: Add two functions: notmuch_query_get_query_string and _get_sort It can be handy to be able to query these settings from an existing query object. --- diff --git a/lib/notmuch.h b/lib/notmuch.h index 9a196999..bd0880f3 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -361,10 +361,18 @@ typedef enum { NOTMUCH_SORT_UNSORTED } notmuch_sort_t; +/* Return the query_string of this query. See notmuch_query_create. */ +const char * +notmuch_query_get_query_string (notmuch_query_t *query); + /* Specify the sorting desired for this query. */ void notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort); +/* Return the sort specified for this query. See notmuch_query_set_sort. */ +notmuch_sort_t +notmuch_query_get_sort (notmuch_query_t *query); + /* Execute a query for threads, returning a notmuch_threads_t object * which can be used to iterate over the results. The returned threads * object is owned by the query and as such, will only be valid until diff --git a/lib/query.cc b/lib/query.cc index 59f4011b..9acf2b03 100644 --- a/lib/query.cc +++ b/lib/query.cc @@ -70,12 +70,24 @@ notmuch_query_create (notmuch_database_t *notmuch, return query; } +const char * +notmuch_query_get_query_string (notmuch_query_t *query) +{ + return query->query_string; +} + void notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort) { query->sort = sort; } +notmuch_sort_t +notmuch_query_get_sort (notmuch_query_t *query) +{ + return query->sort; +} + /* We end up having to call the destructors explicitly because we had * to use "placement new" in order to initialize C++ objects within a * block that we allocated with talloc. So C++ is making talloc