JODA  0.13.1 (59b41972)
JSON On-Demand Analysis
ComparePredicate.h
Go to the documentation of this file.
1 //
2 // Created by Nico Schäfer on 11/13/17.
3 //
4 
5 #ifndef JODA_COMPAREPREDICATE_H
6 #define JODA_COMPAREPREDICATE_H
7 
9 
10 #include "Predicate.h"
11 
12 namespace joda::query {
16 class NotComparableException : public std::exception {
17  virtual const char *what() const throw() {
18  return "The given values are not comparable by '<', '<=','>' or '>='";
19  }
20 };
21 
25 class ComparePredicate : public Predicate {
26  public:
27  ComparePredicate(std::unique_ptr<IValueProvider> &&lhs,
28  std::unique_ptr<IValueProvider> &&rhs, bool greater = true,
29  bool include = true);
30  bool check(const RapidJsonDocument &val) override;
31  bool isCompatible(Predicate *other) override;
32  std::string getType() override;
33  void accept(class PredicateVisitor &v) override;
34 
35  std::string toString();
36  std::vector<std::string> getAttributes() const;
37  std::unique_ptr<Predicate> duplicate() const;
38  bool isGreater() const;
39  bool isInclude() const;
40  std::unique_ptr<IValueProvider> &getLhs();
41  std::unique_ptr<IValueProvider> &getRhs();
42 
43  protected:
44  std::unique_ptr<IValueProvider> lhs;
45  std::unique_ptr<IValueProvider> rhs;
46  bool greater = true;
47  bool include = true;
48 };
49 } // namespace joda::query
50 
51 #endif // JODA_COMPAREPREDICATE_H
Definition: RapidJsonDocument.h:22
Definition: ComparePredicate.h:25
std::string toString()
Definition: ComparePredicate.cpp:91
std::unique_ptr< IValueProvider > rhs
Definition: ComparePredicate.h:45
std::unique_ptr< IValueProvider > lhs
Definition: ComparePredicate.h:44
std::vector< std::string > getAttributes() const
Definition: ComparePredicate.cpp:103
std::unique_ptr< IValueProvider > & getRhs()
Definition: ComparePredicate.cpp:122
bool check(const RapidJsonDocument &val) override
Definition: ComparePredicate.cpp:19
bool greater
Definition: ComparePredicate.h:46
void accept(class PredicateVisitor &v) override
Definition: ComparePredicate.cpp:87
bool include
Definition: ComparePredicate.h:47
bool isInclude() const
Definition: ComparePredicate.cpp:115
ComparePredicate(std::unique_ptr< IValueProvider > &&lhs, std::unique_ptr< IValueProvider > &&rhs, bool greater=true, bool include=true)
Definition: ComparePredicate.cpp:8
bool isCompatible(Predicate *other) override
Definition: ComparePredicate.cpp:81
std::unique_ptr< IValueProvider > & getLhs()
Definition: ComparePredicate.cpp:118
std::string getType() override
Definition: ComparePredicate.cpp:84
std::unique_ptr< Predicate > duplicate() const
Definition: ComparePredicate.cpp:110
bool isGreater() const
Definition: ComparePredicate.cpp:114
Definition: ComparePredicate.h:16
Definition: PredicateVisitor.h:29
Definition: Predicate.h:20
Definition: AttributeStatAggregator.h:12