From 57498fb1a205a6c674f4479e83c351a2bd41a1ae Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Wed, 18 May 2011 23:51:52 +0300 Subject: [PATCH] * mu-msg-iter-priv.cc: get rid of this with some void** casting tricks... --- src/Makefile.am | 1 - src/mu-msg-iter-priv.hh | 38 -------------------------------------- src/mu-msg-iter.cc | 8 ++++---- src/mu-msg-iter.h | 14 ++++++++++++++ src/mu-query.cc | 3 +-- src/mu-util.h | 11 +++++++++-- 6 files changed, 28 insertions(+), 47 deletions(-) delete mode 100644 src/mu-msg-iter-priv.hh diff --git a/src/Makefile.am b/src/Makefile.am index 7187a5c1..9168a9a4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -74,7 +74,6 @@ libmu_la_SOURCES= \ mu-msg-file.h \ mu-msg-flags.c \ mu-msg-flags.h \ - mu-msg-iter-priv.hh \ mu-msg-iter.cc \ mu-msg-iter.h \ mu-msg-part.c \ diff --git a/src/mu-msg-iter-priv.hh b/src/mu-msg-iter-priv.hh deleted file mode 100644 index 4a3307ee..00000000 --- a/src/mu-msg-iter-priv.hh +++ /dev/null @@ -1,38 +0,0 @@ -/* -** Copyright (C) 2008-2010 Dirk-Jan C. Binnema -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software Foundation, -** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -** -*/ - -#ifndef __MU_MSG_PRIV_HH__ -#define __MU_MSG_PRIV_HH__ - -#include - -/** - * create a new MuMsgIter -- basically, an iterator over the search - * results - * - * @param enq a Xapian::Enquiry providing access to search results - * @param batchsize how many results to retrieve at once - * - * @return a new MuMsgIter, or NULL in case of error - */ -MuMsgIter *mu_msg_iter_new (const Xapian::Enquire& enq, - size_t batchsize) G_GNUC_WARN_UNUSED_RESULT; - - -#endif /*__MU_MSG_PRIV_HH__*/ diff --git a/src/mu-msg-iter.cc b/src/mu-msg-iter.cc index ac37af62..fd9e86ce 100644 --- a/src/mu-msg-iter.cc +++ b/src/mu-msg-iter.cc @@ -26,8 +26,6 @@ #include "mu-util.h" #include "mu-msg.h" #include "mu-msg-iter.h" -#include "mu-msg-iter-priv.hh" - static gboolean update_msg (MuMsgIter *iter); @@ -62,10 +60,12 @@ struct _MuMsgIter { MuMsgIter* -mu_msg_iter_new (const Xapian::Enquire& enq, size_t batchsize) +mu_msg_iter_new (XapianEnquire *enq, size_t batchsize) { + g_return_val_if_fail (enq, NULL); + try { - return new MuMsgIter (enq, batchsize); + return new MuMsgIter ((const Xapian::Enquire&)*enq, batchsize); } MU_XAPIAN_CATCH_BLOCK_RETURN(NULL); } diff --git a/src/mu-msg-iter.h b/src/mu-msg-iter.h index cc97ff5e..b2c479e0 100644 --- a/src/mu-msg-iter.h +++ b/src/mu-msg-iter.h @@ -36,6 +36,20 @@ G_BEGIN_DECLS struct _MuMsgIter; typedef struct _MuMsgIter MuMsgIter; + +/** + * create a new MuMsgIter -- basically, an iterator over the search + * results + * + * @param enq a Xapian::Enquire* cast to XapianEnquire* (because this + * is C, not C++),providing access to search results + * @param batchsize how many results to retrieve at once + * + * @return a new MuMsgIter, or NULL in case of error + */ +MuMsgIter *mu_msg_iter_new (XapianEnquire *enq, + size_t batchsize) G_GNUC_WARN_UNUSED_RESULT; + /** * get the next message (which you got from * e.g. mu_query_run) diff --git a/src/mu-query.cc b/src/mu-query.cc index 55d7da04..199ef99f 100644 --- a/src/mu-query.cc +++ b/src/mu-query.cc @@ -30,7 +30,6 @@ #include "mu-msg-fields.h" #include "mu-msg-iter.h" -#include "mu-msg-iter-priv.hh" #include "mu-util.h" #include "mu-str.h" @@ -349,7 +348,7 @@ mu_query_run (MuQuery *self, const char* searchexpr, enq.set_query(query); enq.set_cutoff(0,0); - return mu_msg_iter_new (enq, batchsize); + return mu_msg_iter_new ((XapianEnquire*)&enq, batchsize); } MU_XAPIAN_CATCH_BLOCK_RETURN(NULL); } diff --git a/src/mu-util.h b/src/mu-util.h index d2669a1e..e587f860 100644 --- a/src/mu-util.h +++ b/src/mu-util.h @@ -95,7 +95,7 @@ gboolean mu_util_check_dir (const gchar* path, gboolean readable, G_GNUC_WARN_UNUSED_RESULT; -/** +/** * get our the cache directory, typically, /tmp/mu-/ * * @return the cache directory; don't free @@ -244,11 +244,18 @@ enum { unsigned char mu_util_get_dtype_with_lstat (const char *path); -/* +/** * we need this when using Xapian::Document* from C + * */ typedef gpointer XapianDocument; +/** + * we need this when using Xapian::Enquire* from C + * + */ +typedef gpointer XapianEnquire; + /** * * don't repeat these catch blocks everywhere...