|
xapian-core
1.4.31
|
Handle a date range. More...
#include <queryparser.h>
Inheritance diagram for Xapian::DateRangeProcessor:
Collaboration diagram for Xapian::DateRangeProcessor:Public Member Functions | |
| DateRangeProcessor (Xapian::valueno slot_, unsigned flags_=0, int epoch_year_=1970) | |
| Constructor. More... | |
| DateRangeProcessor (Xapian::valueno slot_, const std::string &str_, unsigned flags_=0, int epoch_year_=1970) | |
| Constructor. More... | |
| Xapian::Query | operator() (const std::string &begin, const std::string &end) |
| Check for a valid date range. More... | |
Public Member Functions inherited from Xapian::RangeProcessor | |
| RangeProcessor () | |
| Default constructor. More... | |
| RangeProcessor (Xapian::valueno slot_, const std::string &str_=std::string(), unsigned flags_=0) | |
| Constructor. More... | |
| virtual | ~RangeProcessor () |
| Destructor. More... | |
| Xapian::Query | check_range (const std::string &b, const std::string &e) |
| Check prefix/suffix on range. More... | |
| RangeProcessor * | release () |
| Start reference counting this object. More... | |
| const RangeProcessor * | release () const |
| Start reference counting this object. More... | |
Public Member Functions inherited from Xapian::Internal::opt_intrusive_base | |
| opt_intrusive_base (const opt_intrusive_base &) | |
| opt_intrusive_base & | operator= (const opt_intrusive_base &) |
| opt_intrusive_base () | |
| Construct object which is initially not reference counted. More... | |
| virtual | ~opt_intrusive_base () |
| void | ref () const |
| void | unref () const |
Private Attributes | |
| int | epoch_year |
Additional Inherited Members | |
Public Attributes inherited from Xapian::Internal::opt_intrusive_base | |
| unsigned | _refs |
| Reference count. More... | |
Protected Member Functions inherited from Xapian::Internal::opt_intrusive_base | |
| void | release () const |
| Start reference counting. More... | |
Protected Attributes inherited from Xapian::RangeProcessor | |
| Xapian::valueno | slot |
| The value slot to process. More... | |
| std::string | str |
| The prefix (or suffix with RP_SUFFIX) string to look for. More... | |
| unsigned | flags |
| Flags. More... | |
Handle a date range.
Begin and end must be dates in a recognised format.
Definition at line 255 of file queryparser.h.
|
inlineexplicit |
Constructor.
| slot_ | The value number to return from operator(). |
| flags_ | Zero or more of the following flags, combined with bitwise-or:
|
| epoch_year_ | Year to use as the epoch for dates with 2 digit years (default: 1970, so 1/1/69 is 2069 while 1/1/70 is 1970). |
Definition at line 272 of file queryparser.h.
|
inline |
Constructor.
| slot_ | The value slot number to query. |
| str_ | A prefix or suffix string to look for to recognise values as belonging to this date range (flags_ determines whether this is a prefix or suffix). |
| flags_ | Zero or more of the following flags, combined with bitwise-or:
|
| epoch_year_ | Year to use as the epoch for dates with 2 digit years (default: 1970, so 1/1/69 is 2069 while 1/1/70 is 1970). |
The string supplied in str_ is used by operator() to decide whether the pair of strings supplied to it constitute a valid range. If prefix_ is true, the first value in a range must begin with str_ (and the second value may optionally begin with str_); if prefix_ is false, the second value in a range must end with str_ (and the first value may optionally end with str_).
If str_ is empty then no prefix or suffix is checked for (and Xapian::RP_SUFFIX and Xapian::RP_REPEATED are irrelevant) - anything which looks like a date range will be processed.
Definition at line 313 of file queryparser.h.
|
virtual |
Check for a valid date range.
| begin | The start of the range as specified in the query string by the user. |
| end | The end of the range as specified in the query string by the user. |
If a prefix or suffix was specified at construction time, that must be present on begin and/or end (taking Xapian::RP_SUFFIX and Xapian::RP_REPEATED into account).
Then if the range looks like a date range, the dates are converted to the format YYYYMMDD and combined into a value range query.
Most numeric date formats are recognised:
20251225..202602142025-12-25..2026-02-1412/25/2025..2/14/202625/12/2025..14/2/2026The delimiter can be -, / or . for any of the delimited formats, but must be the same within a single date.
Some dates are unfortunately ambiguous and could be in either of the last two formats - for example 2/3/2025 could be March 2nd or February 3rd. The range start is assumed to be before the range end which can resolve some ambiguous cases, but otherwise day/month/year is assumed unless flag Xapian::RP_DATE_PREFER_MDY was specified.
Two digit years can be used with the last two formats - constructor parameter epoch_year_ determines how these are interpreted.
Reimplemented from Xapian::RangeProcessor.
Definition at line 335 of file valuerangeproc.cc.
References Xapian::decode_xxy(), Xapian::format_yyyymmdd(), Xapian::is_yyyy_mm_dd(), Xapian::Query::OP_INVALID, Xapian::RP_DATE_PREFER_MDY, and Xapian::vet_dm().
|
private |
Definition at line 256 of file queryparser.h.