-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNotQuery.h
50 lines (43 loc) · 1.15 KB
/
NotQuery.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef NOTQUERY_H
#define NOTQUERY_H
#include "Query.h"
#include <cstddef>
class NotQuery : public Query_base {
friend Query operator~(const Query &);
NotQuery(const Query &q) : query(q) {
std::cout << "NotQuery::NotQuery" << std::endl;
}
std::string rep() const override {
std::cout << "NotQuery::rep" << std::endl;
return "~(" + query.rep() + ")";
}
QueryResult eval(const TextQuery &) const override;
NotQuery *clone() const override {
return new NotQuery(query);
}
// Copy constructor
NotQuery(const NotQuery &nq) : Query_base(nq), query(nq.query) {}
// Move constructor
NotQuery(NotQuery &&nq) noexcept : Query_base(std::move(nq)), query(std::move(nq.query)) {}
// Copy-assignment operator
NotQuery &operator=(const NotQuery &rhs) {
Query_base::operator=(rhs);
query = rhs.query;
return *this;
}
// Move-assignment operator
NotQuery &operator=(NotQuery &&rhs) noexcept {
if (this != &rhs) {
Query_base::operator=(std::move(rhs));
query = std::move(rhs.query);
}
return *this;
}
// Destructor
~NotQuery() = default;
Query query;
};
inline Query operator~(const Query &operand) {
return new NotQuery(operand);
}
#endif