summaryrefslogtreecommitdiff
path: root/lib/mu-msg-doc.h
blob: 03044f486ce4388c7fc801ad2d97c7306ab5a948 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
** Copyright (C) 2012-2013 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** This program is free software; you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by the
** Free Software Foundation; either version 3, or (at your option) any
** later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software Foundation,
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
*/

#ifndef __MU_MSG_DOC_H__
#define __MU_MSG_DOC_H__

#include <glib.h>
#include <mu-util.h> /* for XapianDocument */

G_BEGIN_DECLS

struct _MuMsgDoc;
typedef struct _MuMsgDoc MuMsgDoc;

/**
 * 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. 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 (XapianDocument *doc, GError **err)
	G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;

/**
 * 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 MuMsgDoc instance
 */
void mu_msg_doc_destroy (MuMsgDoc *self);


/**
 * get a string parameter from the msgdoc
 *
 * @param self a MuMsgDoc instance
 * @param mfid a MuMsgFieldId for a string field
 *
 * @return a string for the given field (see do_free), or NULL in case of error.
 * free with g_free
 */
gchar* mu_msg_doc_get_str_field (MuMsgDoc *self, MuMsgFieldId mfid)
          G_GNUC_WARN_UNUSED_RESULT;

/**
 * get a string-list parameter from the msgdoc
 *
 * @param self a MuMsgDoc instance
 * @param mfid a MuMsgFieldId for a string-list field
 *
 * @return a list for the given field (see do_free), or NULL in case
 * of error. free with mu_str_free_list
 */
GSList* mu_msg_doc_get_str_list_field (MuMsgDoc *self, MuMsgFieldId mfid)
    G_GNUC_WARN_UNUSED_RESULT;


/**
 *
 * get a numeric parameter from the msgdoc
 *
 * @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_doc_get_num_field (MuMsgDoc *self, MuMsgFieldId mfid);


G_END_DECLS

#endif /*__MU_MSG_DOC_H__*/