forked from jaege/Cpp-Primer-5th-Exercises
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Query.h
37 lines (28 loc) · 740 Bytes
/
Query.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
#ifndef QUERY_H
#define QUERY_H
class TextQuery;
class QueryResult;
class Query_base;
#include <memory>
#include <string>
#include <iostream>
class Query {
friend Query operator~(const Query &);
friend Query operator&(const Query &, const Query &);
friend Query operator|(const Query &, const Query &);
public:
Query(const std::string &);
QueryResult eval(const TextQuery &t) const;
std::string rep() const;
private:
Query(std::shared_ptr<Query_base> query) : pq(query) {
#if DEBUG_LEVEL >= 1
std::cout << "Query::Query(std::shared_ptr<Query_base>)" << std::endl;
#endif
}
std::shared_ptr<Query_base> pq;
};
inline std::ostream &operator<<(std::ostream &os, const Query &q) {
return os << q.rep();
}
#endif