* mu-msg-doc: cosmetics, documentation

This commit is contained in:
Dirk-Jan C. Binnema
2011-06-18 18:42:24 +03:00
parent 8000b85f89
commit b08bf4a1ed
2 changed files with 14 additions and 12 deletions

View File

@ -29,21 +29,22 @@
#include "mu-str.h" #include "mu-str.h"
struct _MuMsgDoc { struct _MuMsgDoc {
_MuMsgDoc (const Xapian::Document& doc) : _doc (doc) {} _MuMsgDoc (Xapian::Document *doc) : _doc (doc) {}
const Xapian::Document doc() const { return _doc; } ~_MuMsgDoc () { delete _doc; }
const Xapian::Document doc() const { return *_doc; }
private: private:
const Xapian::Document& _doc; Xapian::Document *_doc;
}; };
MuMsgDoc* MuMsgDoc*
mu_msg_doc_new (const XapianDocument *doc, GError **err) mu_msg_doc_new (XapianDocument *doc, GError **err)
{ {
g_return_val_if_fail (doc, NULL); g_return_val_if_fail (doc, NULL);
try { try {
return new MuMsgDoc ((const Xapian::Document&)*doc); return new MuMsgDoc ((Xapian::Document*)doc);
} MU_XAPIAN_CATCH_BLOCK_G_ERROR_RETURN(err, MU_ERROR_XAPIAN, NULL); } MU_XAPIAN_CATCH_BLOCK_G_ERROR_RETURN(err, MU_ERROR_XAPIAN, NULL);
@ -61,7 +62,8 @@ mu_msg_doc_destroy (MuMsgDoc *self)
gchar* gchar*
mu_msg_doc_get_str_field (MuMsgDoc *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);
@ -96,8 +98,6 @@ mu_msg_doc_get_str_list_field (MuMsgDoc *self, MuMsgFieldId mfid,
} }
gint64 gint64
mu_msg_doc_get_num_field (MuMsgDoc *self, MuMsgFieldId mfid) mu_msg_doc_get_num_field (MuMsgDoc *self, MuMsgFieldId mfid)
{ {

View File

@ -33,13 +33,14 @@ typedef struct _MuMsgDoc MuMsgDoc;
* *
* @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. MuMsgDoc takes _ownership_ of this pointer;
* don't touch it afterwards
* @param err receives error info, or NULL * @param err receives error info, or NULL
* *
* @return a new MuMsgDoc instance (free with mu_msg_doc_destroy), or * @return a new MuMsgDoc instance (free with mu_msg_doc_destroy), or
* NULL in case of error. * NULL in case of error.
*/ */
MuMsgDoc* mu_msg_doc_new (const XapianDocument *doc, GError **err) MuMsgDoc* mu_msg_doc_new (XapianDocument *doc, GError **err)
G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
/** /**
@ -65,7 +66,8 @@ void mu_msg_doc_destroy (MuMsgDoc *self);
* *
* @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_doc_get_str_field (MuMsgDoc *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; G_GNUC_WARN_UNUSED_RESULT;
/** /**