* add mu_msg_iter_get_index, to get the sequence number of the iterator

This commit is contained in:
Dirk-Jan C. Binnema 2011-03-19 10:11:13 +02:00
parent b98af916b5
commit 4f93f7cc05
3 changed files with 26 additions and 2 deletions

View File

@ -41,6 +41,7 @@ enum _MuMsgFieldId {
MU_MSG_FIELD_ID_TO,
MU_MSG_FIELD_ID_MSGID,
MU_MSG_FIELD_ID_TIMESTAMP,
MU_MSG_FIELD_ID_NUM,
/* fake fields */

View File

@ -31,8 +31,7 @@ struct _MuMsgIter {
Xapian::Enquire *_enq;
Xapian::MSet _matches;
Xapian::MSet::const_iterator _cursor;
size_t _batchsize;
size_t _offset;
size_t _batchsize, _offset;
char* _str[MU_MSG_FIELD_ID_NUM];
bool _is_null;
};
@ -212,6 +211,16 @@ mu_msg_iter_get_field_numeric (MuMsgIter *iter, MuMsgFieldId mfid)
} MU_XAPIAN_CATCH_BLOCK_RETURN(static_cast<gint64>(-1));
}
unsigned int
mu_msg_iter_get_index (MuMsgIter *iter)
{
g_return_val_if_fail (iter, (unsigned int)-1);
return iter->_offset;
}
/* hmmm.... is it impossible to get a 0 docid, or just very improbable? */
unsigned int
mu_msg_iter_get_docid (MuMsgIter *iter)

View File

@ -87,6 +87,20 @@ MuMsg* mu_msg_iter_get_msg (MuMsgIter *iter, GError **err)
unsigned int mu_msg_iter_get_docid (MuMsgIter *iter);
/**
* get the index for this iterator (ie. somewhere between [0..n-1],
* with being the number of matches, and increasing 1 for each
* iter_next)
*
* @param iter a valid MuMsgIter
*
* @return the index or (unsigned int)-1 in case of error
*/
unsigned int mu_msg_iter_get_index (MuMsgIter *iter);
/**
* get the full path of the message file
*