xapian-core  1.4.26
Public Member Functions | List of all members
Xapian::NumberValueRangeProcessor Class Reference

Handle a number range. More...

#include <queryparser.h>

+ Inheritance diagram for Xapian::NumberValueRangeProcessor:

Public Member Functions

 NumberValueRangeProcessor (Xapian::valueno slot_)
 Constructor.
 
 NumberValueRangeProcessor (Xapian::valueno slot_, const std::string &str_, bool prefix_=true)
 Constructor.
 
Xapian::valueno operator() (std::string &begin, std::string &end)
 Check for a valid numeric range.
 
- Public Member Functions inherited from Xapian::StringValueRangeProcessor
 StringValueRangeProcessor (Xapian::valueno slot_)
 Constructor.
 
 StringValueRangeProcessor (Xapian::valueno slot_, const std::string &str_, bool prefix_=true)
 Constructor.
 
Xapian::valueno operator() (std::string &begin, std::string &end)
 Check for a valid string range.
 
- Public Member Functions inherited from Xapian::ValueRangeProcessor
 ValueRangeProcessor ()
 Default constructor.
 
virtual ~ValueRangeProcessor ()
 Destructor.
 
ValueRangeProcessorrelease ()
 Start reference counting this object.
 
const ValueRangeProcessorrelease () const
 Start reference counting this object.
 

Additional Inherited Members

- Protected Attributes inherited from Xapian::StringValueRangeProcessor
Xapian::valueno valno
 The value slot to process.
 
bool prefix
 Whether to look for str as a prefix or suffix.
 
std::string str
 The prefix (or suffix if prefix==false) string to look for.
 

Detailed Description

Handle a number range.

This class must be used on values which have been encoded using Xapian::sortable_serialise() which turns numbers into strings which will sort in the same order as the numbers (the same values can be used to implement a numeric sort).

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

Constructor & Destructor Documentation

◆ NumberValueRangeProcessor() [1/2]

Xapian::NumberValueRangeProcessor::NumberValueRangeProcessor ( Xapian::valueno  slot_)
inlineexplicit

Constructor.

Parameters
slot_The value number to return from operator().

◆ NumberValueRangeProcessor() [2/2]

Xapian::NumberValueRangeProcessor::NumberValueRangeProcessor ( Xapian::valueno  slot_,
const std::string &  str_,
bool  prefix_ = true 
)
inline

Constructor.

Parameters
slot_The value number to return from operator().
str_A string to look for to recognise values as belonging to this numeric 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).

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 floating point numbers. (FIXME: define format recognised).

For example, if str_ is "$" and prefix_ is true, and the range processor has been added to the queryparser, the queryparser will accept "$10..50" or "$10..$50", but not "10..50" or "10..$50" as valid ranges. If str_ is "kg" and prefix_ is false, the queryparser will accept "10..50kg" or "10kg..50kg", but not "10..50" or "10kg..50" as valid ranges.

Member Function Documentation

◆ operator()()

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

Check for a valid numeric 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 valid numeric range with the specified prefix/suffix (if one was specified), this method modifies them by removing the prefix/suffix, converting to a number, and encoding with Xapian::sortable_serialise(), and returns the value of slot_ passed at construction time. Otherwise it returns Xapian::BAD_VALUENO.

Implements Xapian::ValueRangeProcessor.


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