diff options
author | Arun Isaac | 2024-05-04 00:07:31 +0100 |
---|---|---|
committer | Arun Isaac | 2024-05-04 01:39:14 +0100 |
commit | 9a82c0ceb9824960ec8f9c560af8dad67afb0517 (patch) | |
tree | a9b5323b52953082896932a4173b5e4fcb539e6d /xapian.i.in | |
parent | 5763f0c9a713c8627a8e9b801a3cfd24b68ab171 (diff) | |
download | guile-xapian-9a82c0ceb9824960ec8f9c560af8dad67afb0517.tar.gz |
xapian: Wrap RangeProcessor.
* xapian.i.in (GuileXapianRangeProcessorWrapper): New class.
* xapian/xapian.scm (prefixed-range-processor,
suffixed-range-processor): New public functions.
Diffstat (limited to 'xapian.i.in')
-rw-r--r-- | xapian.i.in | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/xapian.i.in b/xapian.i.in index bc9991c..84695e9 100644 --- a/xapian.i.in +++ b/xapian.i.in @@ -142,6 +142,40 @@ } } +// Child class of Xapian::RangeProcessor that calls back to a +// user-specified Scheme procedure to process fields. +%{ + class GuileXapianRangeProcessorWrapper + : public Xapian::RangeProcessor { + private: + SCM proc; + public: + GuileXapianRangeProcessorWrapper(Xapian::valueno slot, const std::string &str, unsigned flags, SCM _proc) + : Xapian::RangeProcessor(slot, str, flags) { + proc = _proc; + } + Xapian::Query operator()(const std::string &begin, const std::string &end) { + void *ptr; + int res = SWIG_ConvertPtr(scm_call_2(proc, + begin.empty() ? SCM_BOOL_F : scm_from_utf8_string(begin.c_str()), + end.empty() ? SCM_BOOL_F : scm_from_utf8_string(end.c_str())), + &ptr, + SWIGTYPE_p_Xapian__Query, + 0); + return *((Xapian::Query*)ptr); + } + }; +%} + +class GuileXapianRangeProcessorWrapper +: public Xapian::RangeProcessor +{ + public: + GuileXapianRangeProcessorWrapper(Xapian::valueno, std::string const&, unsigned, SCM); + ~GuileXapianRangeProcessorWrapper(); + Xapian::Query operator()(std::string const&, std::string const&); +}; + // Child class of Xapian::FieldProcessor that calls back to a // user-specified Scheme procedure to process fields. %{ |