-
Notifications
You must be signed in to change notification settings - Fork 0
/
Query.h
39 lines (29 loc) · 789 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
38
39
#ifndef QUERY_H
#define QUERY_H
#include "TextQuery.h"
#include "QueryResult.h"
#include <string>
#include <memory>
#include <iostream>
#include "Query_base.h"
#include "WordQuery.h"
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 &s) : q(new WordQuery(s)) {}
std::string rep() const {
return q->rep();
}
QueryResult eval(const TextQuery &t) const {
return q->eval(t);
}
Query_base *get() const { return q.get(); }
Query_base &value() const { return *q; }
private:
Query(std::shared_ptr<Query_base> query) : q(query) {}
std::shared_ptr<Query_base> q;
};
std::ostream &operator<<(std::ostream &, const Query &);
#endif