xapian-core  1.4.27
Public Member Functions | Private Attributes | List of all members
Xapian::DateValueRangeProcessor Class Reference

Handle a date range. More...

#include <queryparser.h>

+ Inheritance diagram for Xapian::DateValueRangeProcessor:
+ Collaboration diagram for Xapian::DateValueRangeProcessor:

Public Member Functions

 DateValueRangeProcessor (Xapian::valueno slot_, bool prefer_mdy_=false, int epoch_year_=1970)
 Constructor. More...
 
 DateValueRangeProcessor (Xapian::valueno slot_, const std::string &str_, bool prefix_=true, bool prefer_mdy_=false, int epoch_year_=1970)
 Constructor. More...
 
 DateValueRangeProcessor (Xapian::valueno slot_, const char *str_, bool prefix_=true, bool prefer_mdy_=false, int epoch_year_=1970)
 Constructor. More...
 
Xapian::valueno operator() (std::string &begin, std::string &end)
 Check for a valid date range. More...
 
- Public Member Functions inherited from Xapian::StringValueRangeProcessor
 StringValueRangeProcessor (Xapian::valueno slot_)
 Constructor. More...
 
 StringValueRangeProcessor (Xapian::valueno slot_, const std::string &str_, bool prefix_=true)
 Constructor. More...
 
- Public Member Functions inherited from Xapian::ValueRangeProcessor
 ValueRangeProcessor ()
 Default constructor. More...
 
virtual ~ValueRangeProcessor ()
 Destructor. More...
 
ValueRangeProcessorrelease ()
 Start reference counting this object. More...
 
const ValueRangeProcessorrelease () 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_baseoperator= (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

bool prefer_mdy
 
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::StringValueRangeProcessor
Xapian::valueno valno
 The value slot to process. More...
 
bool prefix
 Whether to look for str as a prefix or suffix. More...
 
std::string str
 The prefix (or suffix if prefix==false) string to look for. More...
 

Detailed Description

Handle a date range.

Begin and end must be dates in a recognised format.

Deprecated:
Use Xapian::DateRangeProcessor instead (added in 1.3.6).

Definition at line 520 of file queryparser.h.

Constructor & Destructor Documentation

◆ DateValueRangeProcessor() [1/3]

Xapian::DateValueRangeProcessor::DateValueRangeProcessor ( Xapian::valueno  slot_,
bool  prefer_mdy_ = false,
int  epoch_year_ = 1970 
)
inline

Constructor.

Parameters
slot_The value number to return from operator().
prefer_mdy_Should ambiguous dates be interpreted as month/day/year rather than day/month/year? (default: false)
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 535 of file queryparser.h.

◆ DateValueRangeProcessor() [2/3]

Xapian::DateValueRangeProcessor::DateValueRangeProcessor ( Xapian::valueno  slot_,
const std::string &  str_,
bool  prefix_ = true,
bool  prefer_mdy_ = false,
int  epoch_year_ = 1970 
)
inline

Constructor.

Parameters
slot_The value number to return from operator().
str_A string to look for to recognise values as belonging to this date range.
prefix_Whether to look for the string at the start or end of the values. If true, the string is a prefix; if false, the string is a suffix (default: true).
prefer_mdy_Should ambiguous dates be interpreted as month/day/year rather than day/month/year? (default: false)
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, the setting of prefix_ is irrelevant, and no special strings are required at the start or end of the strings defining the range.

The remainder of both strings defining the endpoints must be valid dates.

For example, if str_ is "created:" and prefix_ is true, and the range processor has been added to the queryparser, the queryparser will accept "created:1/1/2000..31/12/2001".

Definition at line 577 of file queryparser.h.

◆ DateValueRangeProcessor() [3/3]

Xapian::DateValueRangeProcessor::DateValueRangeProcessor ( Xapian::valueno  slot_,
const char *  str_,
bool  prefix_ = true,
bool  prefer_mdy_ = false,
int  epoch_year_ = 1970 
)
inline

Constructor.

This is like the previous version, but with const char * instead of std::string - we need this overload as otherwise DateValueRangeProcessor(1, "date:") quietly interprets the second argument as a boolean in preference to std::string. If you want to be compatible with 1.2.12 and earlier, then explicitly convert to std::string, i.e.: DateValueRangeProcessor(1, std::string("date:"))

Parameters
slot_The value number to return from operator().
str_A string to look for to recognise values as belonging to this date range.
prefix_Whether to look for the string at the start or end of the values. If true, the string is a prefix; if false, the string is a suffix (default: true).
prefer_mdy_Should ambiguous dates be interpreted as month/day/year rather than day/month/year? (default: false)
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, the setting of prefix_ is irrelevant, and no special strings are required at the start or end of the strings defining the range.

The remainder of both strings defining the endpoints must be valid dates.

For example, if str_ is "created:" and prefix_ is true, and the range processor has been added to the queryparser, the queryparser will accept "created:1/1/2000..31/12/2001".

Definition at line 628 of file queryparser.h.

Member Function Documentation

◆ operator()()

Xapian::valueno Xapian::DateValueRangeProcessor::operator() ( std::string &  begin,
std::string &  end 
)
virtual

Check for a valid date range.

Parameters
[in,out]beginThe start of the range as specified in the query string by the user. This parameter is a non-const reference so the ValueRangeProcessor can modify it to return the value to start the range with.
[in,out]endThe end of the range. This is also a non-const reference so it can be modified.
Returns
If BEGIN..END is a sensible date range, this method modifies them into the format YYYYMMDD and returns the value of slot_ passed at construction time. Otherwise it returns Xapian::BAD_VALUENO.

Reimplemented from Xapian::StringValueRangeProcessor.

Definition at line 144 of file valuerangeproc.cc.

References Xapian::BAD_VALUENO, Xapian::decode_xxy(), Xapian::format_yyyymmdd(), Xapian::is_yyyy_mm_dd(), and Xapian::vet_dm().

Member Data Documentation

◆ epoch_year

int Xapian::DateValueRangeProcessor::epoch_year
private

Definition at line 522 of file queryparser.h.

◆ prefer_mdy

bool Xapian::DateValueRangeProcessor::prefer_mdy
private

Definition at line 521 of file queryparser.h.


The documentation for this class was generated from the following files: