aboutsummaryrefslogtreecommitdiff
path: root/xapian
diff options
context:
space:
mode:
authorArun Isaac2024-05-04 00:07:31 +0100
committerArun Isaac2024-05-04 01:39:14 +0100
commit9a82c0ceb9824960ec8f9c560af8dad67afb0517 (patch)
treea9b5323b52953082896932a4173b5e4fcb539e6d /xapian
parent5763f0c9a713c8627a8e9b801a3cfd24b68ab171 (diff)
downloadguile-xapian-9a82c0ceb9824960ec8f9c560af8dad67afb0517.tar.gz
guile-xapian-9a82c0ceb9824960ec8f9c560af8dad67afb0517.tar.lz
guile-xapian-9a82c0ceb9824960ec8f9c560af8dad67afb0517.zip
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')
-rw-r--r--xapian/xapian.scm37
1 files changed, 37 insertions, 0 deletions
diff --git a/xapian/xapian.scm b/xapian/xapian.scm
index 9ca5df6..15690aa 100644
--- a/xapian/xapian.scm
+++ b/xapian/xapian.scm
@@ -54,6 +54,8 @@
query-and
query-or
query-filter
+ prefixed-range-processor
+ suffixed-range-processor
field-processor
enquire
enquire-mset
@@ -240,6 +242,41 @@ In a non-weighted context, @code{query-filter} and @code{query-and}
are equivalent."
(apply query-combine (Query-OP-FILTER) (Query-MatchAll) queries))
+(define* (prefixed-range-processor slot proc #:key (prefix "") repeated?)
+ "Return a @code{RangeProcessor} object that calls @var{proc} to process
+its range over @var{slot}.
+
+@var{proc} is a procedure that, given a begin string and an end
+string, must return a @code{Query} object. For open-ended ranges,
+either the begin string or the end string will be @code{#f}.
+
+@var{prefix} is a prefix to look for to recognize values as belonging
+to this range. When @var{repeated?} is @code{#t}, allow @var{prefix}
+on both ends of the range—@samp{$1..$10}."
+ (new-GuileXapianRangeProcessorWrapper
+ slot
+ prefix
+ (get-flag RP-REPEATED repeated?)
+ proc))
+
+(define* (suffixed-range-processor slot proc #:key suffix repeated?)
+ "Return a @code{RangeProcessor} object that calls @var{proc} to process
+its range over @var{slot}.
+
+@var{proc} is a procedure that, given a begin string and an end
+string, must return a @code{Query} object. For open-ended ranges,
+either the begin string or the end string will be @code{#f}.
+
+@var{suffix} is a suffix to look for to recognize values as belonging
+to this range. When @var{repeated?} is @code{#t}, allow @var{suffix}
+on both ends of the range—@samp{2kg..12kg}."
+ (new-GuileXapianRangeProcessorWrapper
+ slot
+ suffix
+ (bitwise-ior (RP-SUFFIX)
+ (get-flag RP-REPEATED repeated?))
+ proc))
+
(define (field-processor proc)
"Return a @code{FieldProcessor} object that calls
@var{proc} to process its field. @var{proc} is a procedure that, given