* mu-msg-db => mu-msg-doc

This commit is contained in:
Dirk-Jan C. Binnema 2011-05-17 23:17:11 +03:00
parent d7a1c7699b
commit bf4314533b
2 changed files with 32 additions and 33 deletions

View File

@ -25,10 +25,10 @@
#include "mu-util.h" #include "mu-util.h"
#include "mu-msg-fields.h" #include "mu-msg-fields.h"
#include "mu-msg-db.h" #include "mu-msg-doc.h"
struct _MuMsgDb { struct _MuMsgDoc {
_MuMsgDb (const Xapian::Document& doc) : _doc (doc) {} _MuMsgDoc (const Xapian::Document& doc) : _doc (doc) {}
const Xapian::Document doc() const { return _doc; } const Xapian::Document doc() const { return _doc; }
private: private:
const Xapian::Document& _doc; const Xapian::Document& _doc;
@ -36,14 +36,13 @@ private:
}; };
MuMsgDb* MuMsgDoc*
mu_msg_db_new (const XapianDocument *doc, GError **err) mu_msg_doc_new (const XapianDocument *doc, GError **err)
{ {
g_return_val_if_fail (doc, NULL); g_return_val_if_fail (doc, NULL);
try { try {
MuMsgDb *db = new MuMsgDb ((const Xapian::Document&)*doc); return new MuMsgDoc ((const Xapian::Document&)*doc);
return db;
} MU_XAPIAN_CATCH_BLOCK_G_ERROR_RETURN(err, MU_ERROR_XAPIAN, NULL); } 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 void
mu_msg_db_destroy (MuMsgDb *self) mu_msg_doc_destroy (MuMsgDoc *self)
{ {
try { try {
delete self; delete self;
@ -61,7 +60,7 @@ mu_msg_db_destroy (MuMsgDb *self)
gchar* 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 (self, NULL);
g_return_val_if_fail (mu_msg_field_id_is_valid(mfid), 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 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 (self, -1);
g_return_val_if_fail (mu_msg_field_id_is_valid(mfid), -1); g_return_val_if_fail (mu_msg_field_id_is_valid(mfid), -1);

View File

@ -17,70 +17,70 @@
** **
*/ */
#ifndef __MU_MSG_DB_H__ #ifndef __MU_MSG_DOC_H__
#define __MU_MSG_DB_H__ #define __MU_MSG_DOC_H__
#include <glib.h> #include <glib.h>
#include <mu-util.h> /* for XapianDocument */ #include <mu-util.h> /* for XapianDocument */
G_BEGIN_DECLS G_BEGIN_DECLS
struct _MuMsgDb; struct _MuMsgDoc;
typedef struct _MuMsgDb MuMsgDb; 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 * @param doc a Xapian::Document* (you'll need to cast the
* Xapian::Document* to XapianDocument*, because only C (not C++) is * Xapian::Document* to XapianDocument*, because only C (not C++) is
* allowed in this header file. * allowed in this header file.
* @param err receives error info, or NULL * @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. * 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 * destroy a MuMsgDoc instance -- free all the resources. Note, after
* destroying, any strings returned from mu_msg_db_get_str_field with * destroying, any strings returned from mu_msg_doc_get_str_field with
* do_free==FALSE are no longer valid * 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 mfid a MuMsgFieldId for a string field
* @param do_free receives either TRUE or FALSE, where TRUE means that * @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 * 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 * with it; FALSE means that the MuMsgDoc owns the string, and it is
* only valid as long as the MuMsgDb is valid (ie., before * only valid as long as the MuMsgDoc is valid (ie., before
* mu_msg_db_destroy). * mu_msg_doc_destroy).
* *
* @return a string for the given field (see do_free), or NULL in case of error * @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 * @param mfid a MuMsgFieldId for a numeric field
* *
* @return the numerical value, or -1 in case of error. You'll need to * @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) * 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 G_END_DECLS
#endif /*__MU_MSG_DB_H__*/ #endif /*__MU_MSG_DOC_H__*/