Xapian: API Documentation: Xapian::UnitRangeProcessor Class Reference

xapian-core 2.1.0

Public Member Functions | List of all members
Xapian::UnitRangeProcessor Class Reference

Handle a byte unit range. More...

`#include <queryparser.h>`

Inheritance diagram for Xapian::UnitRangeProcessor:
[legend]

## Public Member Functions
| UnitRangeProcessor (Xapian::valueno slot_, std::string_view str_={})
| Constructor.
Xapian::Query | operator() (const std::string &begin, const std::string &end)
| Check for a valid byte value range.
Public Member Functions inherited from Xapian::RangeProcessor
| RangeProcessor ()
| Default constructor.
| RangeProcessor (Xapian::valueno slot_, std::string_view str_={}, unsigned flags_=0)
| Constructor.
virtual | ~RangeProcessor ()
| Destructor.
Xapian::Query | check_range (const std::string &b, const std::string &e)
| Check prefix/suffix on range.
RangeProcessor * | release ()
| Start reference counting this object.
const RangeProcessor * | release () const
| Start reference counting this object.

## Additional Inherited Members
Protected Attributes inherited from Xapian::RangeProcessor
Xapian::valueno | slot
| The value slot to process.
std::string | str
| The prefix (or suffix with RP_SUFFIX) string to look for.
unsigned | flags
| Flags.

## Detailed Description

Handle a byte unit 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).

Each of the range ends can be specified in:

- bytes (suffix 'B')
- KB (suffix 'K')
- MB (suffix 'M')
- GB (suffix 'G')
- TB (suffix 'T') (since 2.1.0)

Since
  Added in Xapian 2.0.0.

## Constructor & Destructor Documentation

## ◆ UnitRangeProcessor()

Xapian::UnitRangeProcessor::UnitRangeProcessor | ( | Xapian::valueno | slot_,
|  | std::string_view | str_ = {} )
| inline

Constructor.

Parameters

  slot_ | The value slot number to query.
  str_ | A string to look for to recognise values as belonging to this numeric range.

The string supplied in str_ is the prefix plus ":" that defines the field upon which the range query is performed.

For example, if str_ is "size:", and the range processor has been added to the queryparser, the queryparser will accept "size:3K..10K" as a valid range.

## Member Function Documentation

## ◆ operator()()

Xapian::Query Xapian::UnitRangeProcessor::operator() | ( | const std::string & | begin,
|  | const std::string & | end )
| virtual

Check for a valid byte value range.

If BEGIN..END is a valid numeric byte range with the specified prefix the prefix is removed, the string converted to a number, unit normalized and encoded with Xapian::sortable_serialise(), and a value range query is built.

Parameters

  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.

Reimplemented from Xapian::RangeProcessor.

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

- xapian/queryparser.h