11#ifndef RD_RANGEQUERY_H
12#define RD_RANGEQUERY_H
25template <
class MatchFuncArgType,
class DataFuncArgType = MatchFuncArgType,
26 bool needsConversion =
false>
28 :
public Query<MatchFuncArgType, DataFuncArgType, needsConversion> {
30 RangeQuery() : d_upper(0), d_lower(0) { this->df_negate =
false; }
32 RangeQuery(MatchFuncArgType lower, MatchFuncArgType upper)
33 : d_upper(upper), d_lower(lower), df_upperOpen(true), df_lowerOpen(true) {
34 this->df_negate =
false;
38 void setUpper(MatchFuncArgType what) { this->d_upper = what; }
40 const MatchFuncArgType
getUpper()
const {
return this->d_upper; }
42 void setLower(MatchFuncArgType what) { this->d_lower = what; }
44 const MatchFuncArgType
getLower()
const {
return this->d_lower; }
48 this->df_lowerOpen = lower;
49 this->df_upperOpen = upper;
53 return std::make_pair(this->df_lowerOpen, this->df_upperOpen);
57 void setTol(MatchFuncArgType what) { this->d_tol = what; }
59 const MatchFuncArgType
getTol()
const {
return this->d_tol; }
61 bool Match(
const DataFuncArgType what)
const override {
62 MatchFuncArgType mfArg =
64 int lCmp =
queryCmp(this->d_lower, mfArg, this->d_tol);
65 int uCmp =
queryCmp(this->d_upper, mfArg, this->d_tol);
66 bool lowerRes, upperRes;
67 if (this->df_lowerOpen) {
72 if (this->df_upperOpen) {
78 bool tempR = !(lowerRes && upperRes);
79 if (this->getNegation()) {
94 res->
setEndsOpen(this->df_lowerOpen, this->df_upperOpen);
102 std::ostringstream res;
103 res << this->getDescription();
104 if (this->getNegation()) {
107 res <<
" " << this->d_lower <<
" val " << this->d_upper;
113 bool df_upperOpen{
true}, df_lowerOpen{
true};
class to allow integer values to pick templates
Base class for all queries.
void setDataFunc(MatchFuncArgType(*what)(DataFuncArgType))
sets our data function
void setNegation(bool what)
sets whether or not we are negated
std::string d_description
a Query implementing a range: arguments must fall in a particular range of values.
std::string getFullDescription() const override
returns a fuller text description
RangeQuery(MatchFuncArgType lower, MatchFuncArgType upper)
construct and set the lower and upper bounds
void setTol(MatchFuncArgType what)
sets our tolerance
void setUpper(MatchFuncArgType what)
sets our upper bound
bool Match(const DataFuncArgType what) const override
returns whether or not we match the argument
const MatchFuncArgType getLower() const
returns our lower bound
const MatchFuncArgType getUpper() const
returns our upper bound
std::pair< bool, bool > getEndsOpen() const
returns the state of our ends (open or not)
const MatchFuncArgType getTol() const
returns our tolerance
void setEndsOpen(bool lower, bool upper)
sets whether or not the ends of the range are open
void setLower(MatchFuncArgType what)
sets our lower bound
Query< MatchFuncArgType, DataFuncArgType, needsConversion > * copy() const override
returns a copy of this Query
#define RDKIT_QUERY_EXPORT
int queryCmp(const T1 v1, const T2 v2, const T1 tol)