mirror of https://github.com/djcb/mu.git
* mu-msg-db => mu-msg-doc
This commit is contained in:
parent
d7a1c7699b
commit
bf4314533b
|
@ -25,10 +25,10 @@
|
|||
|
||||
#include "mu-util.h"
|
||||
#include "mu-msg-fields.h"
|
||||
#include "mu-msg-db.h"
|
||||
#include "mu-msg-doc.h"
|
||||
|
||||
struct _MuMsgDb {
|
||||
_MuMsgDb (const Xapian::Document& doc) : _doc (doc) {}
|
||||
struct _MuMsgDoc {
|
||||
_MuMsgDoc (const Xapian::Document& doc) : _doc (doc) {}
|
||||
const Xapian::Document doc() const { return _doc; }
|
||||
private:
|
||||
const Xapian::Document& _doc;
|
||||
|
@ -36,14 +36,13 @@ private:
|
|||
};
|
||||
|
||||
|
||||
MuMsgDb*
|
||||
mu_msg_db_new (const XapianDocument *doc, GError **err)
|
||||
MuMsgDoc*
|
||||
mu_msg_doc_new (const XapianDocument *doc, GError **err)
|
||||
{
|
||||
g_return_val_if_fail (doc, NULL);
|
||||
|
||||
try {
|
||||
MuMsgDb *db = new MuMsgDb ((const Xapian::Document&)*doc);
|
||||
return db;
|
||||
return new MuMsgDoc ((const Xapian::Document&)*doc);
|
||||
|
||||
} MU_XAPIAN_CATCH_BLOCK_G_ERROR_RETURN(err, MU_ERROR_XAPIAN, NULL);
|
||||
|
||||
|
@ -51,7 +50,7 @@ mu_msg_db_new (const XapianDocument *doc, GError **err)
|
|||
}
|
||||
|
||||
void
|
||||
mu_msg_db_destroy (MuMsgDb *self)
|
||||
mu_msg_doc_destroy (MuMsgDoc *self)
|
||||
{
|
||||
try {
|
||||
delete self;
|
||||
|
@ -61,7 +60,7 @@ mu_msg_db_destroy (MuMsgDb *self)
|
|||
|
||||
|
||||
gchar*
|
||||
mu_msg_db_get_str_field (MuMsgDb *self, MuMsgFieldId mfid, gboolean *do_free)
|
||||
mu_msg_doc_get_str_field (MuMsgDoc *self, MuMsgFieldId mfid, gboolean *do_free)
|
||||
{
|
||||
g_return_val_if_fail (self, NULL);
|
||||
g_return_val_if_fail (mu_msg_field_id_is_valid(mfid), NULL);
|
||||
|
@ -78,7 +77,7 @@ mu_msg_db_get_str_field (MuMsgDb *self, MuMsgFieldId mfid, gboolean *do_free)
|
|||
|
||||
|
||||
gint64
|
||||
mu_msg_db_get_num_field (MuMsgDb *self, MuMsgFieldId mfid)
|
||||
mu_msg_doc_get_num_field (MuMsgDoc *self, MuMsgFieldId mfid)
|
||||
{
|
||||
g_return_val_if_fail (self, -1);
|
||||
g_return_val_if_fail (mu_msg_field_id_is_valid(mfid), -1);
|
|
@ -17,70 +17,70 @@
|
|||
**
|
||||
*/
|
||||
|
||||
#ifndef __MU_MSG_DB_H__
|
||||
#define __MU_MSG_DB_H__
|
||||
#ifndef __MU_MSG_DOC_H__
|
||||
#define __MU_MSG_DOC_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include <mu-util.h> /* for XapianDocument */
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
struct _MuMsgDb;
|
||||
typedef struct _MuMsgDb MuMsgDb;
|
||||
struct _MuMsgDoc;
|
||||
typedef struct _MuMsgDoc MuMsgDoc;
|
||||
|
||||
/**
|
||||
* create a new MuMsgDb instance
|
||||
* create a new MuMsgDoc instance
|
||||
*
|
||||
* @param doc a Xapian::Document* (you'll need to cast the
|
||||
* Xapian::Document* to XapianDocument*, because only C (not C++) is
|
||||
* allowed in this header file.
|
||||
* @param err receives error info, or NULL
|
||||
*
|
||||
* @return a new MuMsgDb instance (free with mu_msg_db_destroy), or
|
||||
* @return a new MuMsgDoc instance (free with mu_msg_doc_destroy), or
|
||||
* NULL in case of error.
|
||||
*/
|
||||
MuMsgDb* mu_msg_db_new (const XapianDocument *doc, GError **err);
|
||||
|
||||
MuMsgDoc* mu_msg_doc_new (const XapianDocument *doc, GError **err)
|
||||
G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
|
||||
|
||||
/**
|
||||
* destroy a MuMsgDb instance -- free all the resources. Note, after
|
||||
* destroying, any strings returned from mu_msg_db_get_str_field with
|
||||
* destroy a MuMsgDoc instance -- free all the resources. Note, after
|
||||
* destroying, any strings returned from mu_msg_doc_get_str_field with
|
||||
* do_free==FALSE are no longer valid
|
||||
*
|
||||
* @param self a MuMsgDb instance
|
||||
* @param self a MuMsgDoc instance
|
||||
*/
|
||||
void mu_msg_db_destroy (MuMsgDb *self);
|
||||
void mu_msg_doc_destroy (MuMsgDoc *self);
|
||||
|
||||
|
||||
/**
|
||||
* get a string parameter from the msgdb
|
||||
* get a string parameter from the msgdoc
|
||||
*
|
||||
* @param self a MuMsgDb instance
|
||||
* @param self a MuMsgDoc instance
|
||||
* @param mfid a MuMsgFieldId for a string field
|
||||
* @param do_free receives either TRUE or FALSE, where TRUE means that
|
||||
* the caller owns the string, and has to free it (g_free) when done
|
||||
* with it; FALSE means that the MuMsgDb owns the string, and it is
|
||||
* only valid as long as the MuMsgDb is valid (ie., before
|
||||
* mu_msg_db_destroy).
|
||||
* with it; FALSE means that the MuMsgDoc owns the string, and it is
|
||||
* only valid as long as the MuMsgDoc is valid (ie., before
|
||||
* mu_msg_doc_destroy).
|
||||
*
|
||||
* @return a string for the given field (see do_free), or NULL in case of error
|
||||
*/
|
||||
gchar* mu_msg_db_get_str_field (MuMsgDb *self, MuMsgFieldId mfid, gboolean *do_free);
|
||||
gchar* mu_msg_doc_get_str_field (MuMsgDoc *self, MuMsgFieldId mfid, gboolean *do_free)
|
||||
G_GNUC_WARN_UNUSED_RESULT;
|
||||
|
||||
/**
|
||||
*
|
||||
* get a numeric parameter from the msgdb
|
||||
* get a numeric parameter from the msgdoc
|
||||
*
|
||||
* @param self a MuMsgDb instance
|
||||
* @param self a MuMsgDoc instance
|
||||
* @param mfid a MuMsgFieldId for a numeric field
|
||||
*
|
||||
* @return the numerical value, or -1 in case of error. You'll need to
|
||||
* cast this value to the actual type (e.g. time_t for MU_MSG_FIELD_ID_DATE)
|
||||
*/
|
||||
gint64 mu_msg_db_get_num_field (MuMsgDb *self, MuMsgFieldId mfid);
|
||||
|
||||
gint64 mu_msg_doc_get_num_field (MuMsgDoc *self, MuMsgFieldId mfid);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /*__MU_MSG_DB_H__*/
|
||||
#endif /*__MU_MSG_DOC_H__*/
|
Loading…
Reference in New Issue