mirror of https://github.com/djcb/mu.git
* mu-msg-doc: cosmetics, documentation
This commit is contained in:
parent
8000b85f89
commit
b08bf4a1ed
|
@ -29,21 +29,22 @@
|
|||
#include "mu-str.h"
|
||||
|
||||
struct _MuMsgDoc {
|
||||
_MuMsgDoc (const Xapian::Document& doc) : _doc (doc) {}
|
||||
const Xapian::Document doc() const { return _doc; }
|
||||
_MuMsgDoc (Xapian::Document *doc) : _doc (doc) {}
|
||||
~_MuMsgDoc () { delete _doc; }
|
||||
const Xapian::Document doc() const { return *_doc; }
|
||||
private:
|
||||
const Xapian::Document& _doc;
|
||||
Xapian::Document *_doc;
|
||||
|
||||
};
|
||||
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
|
@ -61,7 +62,8 @@ mu_msg_doc_destroy (MuMsgDoc *self)
|
|||
|
||||
|
||||
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 (mu_msg_field_id_is_valid(mfid), NULL);
|
||||
|
@ -72,7 +74,7 @@ mu_msg_doc_get_str_field (MuMsgDoc *self, MuMsgFieldId mfid, gboolean *do_free)
|
|||
try {
|
||||
const std::string s (self->doc().get_value(mfid));
|
||||
return s.empty() ? NULL : g_strdup (s.c_str());
|
||||
|
||||
|
||||
} MU_XAPIAN_CATCH_BLOCK_RETURN(NULL);
|
||||
}
|
||||
|
||||
|
@ -96,8 +98,6 @@ mu_msg_doc_get_str_list_field (MuMsgDoc *self, MuMsgFieldId mfid,
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
gint64
|
||||
mu_msg_doc_get_num_field (MuMsgDoc *self, MuMsgFieldId mfid)
|
||||
{
|
||||
|
|
|
@ -33,13 +33,14 @@ typedef struct _MuMsgDoc MuMsgDoc;
|
|||
*
|
||||
* @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.
|
||||
* allowed in this header file. MuMsgDoc takes _ownership_ of this pointer;
|
||||
* don't touch it afterwards
|
||||
* @param err receives error info, or NULL
|
||||
*
|
||||
* @return a new MuMsgDoc instance (free with mu_msg_doc_destroy), or
|
||||
* 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;
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue