2011-05-15 09:39:27 +02:00
|
|
|
/*
|
2022-03-03 23:04:30 +01:00
|
|
|
** Copyright (C) 2012-2022 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
2011-05-15 09:39:27 +02:00
|
|
|
**
|
|
|
|
** 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.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
2020-11-28 09:15:49 +01:00
|
|
|
#ifndef MU_MSG_DOC_HH__
|
|
|
|
#define MU_MSG_DOC_HH__
|
2011-05-15 09:39:27 +02:00
|
|
|
|
|
|
|
#include <glib.h>
|
2019-12-16 20:44:35 +01:00
|
|
|
#include <utils/mu-util.h>
|
2022-03-26 16:16:46 +01:00
|
|
|
#include <message/mu-message.hh>
|
2011-05-15 09:39:27 +02:00
|
|
|
|
2020-11-28 09:15:49 +01:00
|
|
|
namespace Mu {
|
|
|
|
|
|
|
|
struct MuMsgDoc;
|
2011-05-15 09:39:27 +02:00
|
|
|
|
|
|
|
/**
|
2012-08-08 18:13:59 +02:00
|
|
|
* create a new MuMsgDoc instance
|
|
|
|
*
|
2011-05-15 09:39:27 +02:00
|
|
|
* @param doc a Xapian::Document* (you'll need to cast the
|
|
|
|
* Xapian::Document* to XapianDocument*, because only C (not C++) is
|
2011-06-18 17:42:24 +02:00
|
|
|
* allowed in this header file. MuMsgDoc takes _ownership_ of this pointer;
|
|
|
|
* don't touch it afterwards
|
2011-05-15 09:39:27 +02:00
|
|
|
* @param err receives error info, or NULL
|
2012-08-08 18:13:59 +02:00
|
|
|
*
|
2011-05-17 22:17:11 +02:00
|
|
|
* @return a new MuMsgDoc instance (free with mu_msg_doc_destroy), or
|
2011-05-15 09:39:27 +02:00
|
|
|
* NULL in case of error.
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
MuMsgDoc* mu_msg_doc_new(XapianDocument* doc, GError** err) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
|
2011-05-15 09:39:27 +02:00
|
|
|
|
|
|
|
/**
|
2011-05-17 22:17:11 +02:00
|
|
|
* destroy a MuMsgDoc instance -- free all the resources. Note, after
|
|
|
|
* destroying, any strings returned from mu_msg_doc_get_str_field with
|
2011-05-15 09:39:27 +02:00
|
|
|
* do_free==FALSE are no longer valid
|
2012-08-08 18:13:59 +02:00
|
|
|
*
|
2011-05-17 22:17:11 +02:00
|
|
|
* @param self a MuMsgDoc instance
|
2011-05-15 09:39:27 +02:00
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
void mu_msg_doc_destroy(MuMsgDoc* self);
|
2011-05-15 09:39:27 +02:00
|
|
|
|
|
|
|
/**
|
2011-05-17 22:17:11 +02:00
|
|
|
* get a string parameter from the msgdoc
|
2012-08-08 18:13:59 +02:00
|
|
|
*
|
2011-05-17 22:17:11 +02:00
|
|
|
* @param self a MuMsgDoc instance
|
2022-03-20 13:12:41 +01:00
|
|
|
* @param mfid a Field::Id for a string field
|
2012-08-08 18:13:59 +02:00
|
|
|
*
|
|
|
|
* @return a string for the given field (see do_free), or NULL in case of error.
|
|
|
|
* free with g_free
|
2011-05-15 09:39:27 +02:00
|
|
|
*/
|
2022-03-20 13:12:41 +01:00
|
|
|
gchar* mu_msg_doc_get_str_field(MuMsgDoc* self, Field::Id mfid) G_GNUC_WARN_UNUSED_RESULT;
|
2011-05-15 09:39:27 +02:00
|
|
|
|
2011-06-15 22:50:17 +02:00
|
|
|
/**
|
|
|
|
* get a string-list parameter from the msgdoc
|
2012-08-08 18:13:59 +02:00
|
|
|
*
|
2011-06-15 22:50:17 +02:00
|
|
|
* @param self a MuMsgDoc instance
|
2022-03-20 13:12:41 +01:00
|
|
|
* @param mfid a Field::Id for a string-list field
|
2012-08-08 18:13:59 +02:00
|
|
|
*
|
|
|
|
* @return a list for the given field (see do_free), or NULL in case
|
|
|
|
* of error. free with mu_str_free_list
|
2011-06-15 22:50:17 +02:00
|
|
|
*/
|
2022-03-20 13:12:41 +01:00
|
|
|
GSList* mu_msg_doc_get_str_list_field(MuMsgDoc* self, Field::Id mfid) G_GNUC_WARN_UNUSED_RESULT;
|
2011-06-15 22:50:17 +02:00
|
|
|
|
2011-05-15 09:39:27 +02:00
|
|
|
/**
|
2012-08-08 18:13:59 +02:00
|
|
|
*
|
2011-05-17 22:17:11 +02:00
|
|
|
* get a numeric parameter from the msgdoc
|
2012-08-08 18:13:59 +02:00
|
|
|
*
|
2011-05-17 22:17:11 +02:00
|
|
|
* @param self a MuMsgDoc instance
|
2022-03-20 13:12:41 +01:00
|
|
|
* @param mfid a Field::Id for a numeric field
|
2012-08-08 18:13:59 +02:00
|
|
|
*
|
2011-05-15 09:39:27 +02:00
|
|
|
* @return the numerical value, or -1 in case of error. You'll need to
|
2022-03-03 23:04:30 +01:00
|
|
|
* cast this value to the actual type (e.g. time_t for Field::Id::Date)
|
2011-05-15 09:39:27 +02:00
|
|
|
*/
|
2022-03-20 13:12:41 +01:00
|
|
|
gint64 mu_msg_doc_get_num_field(MuMsgDoc* self, Field::Id mfid);
|
2011-05-15 09:39:27 +02:00
|
|
|
|
2020-11-28 09:15:49 +01:00
|
|
|
} // namespace Mu
|
2011-05-15 09:39:27 +02:00
|
|
|
|
2020-11-28 09:15:49 +01:00
|
|
|
#endif /*MU_MSG_DOC_HH__*/
|