-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathTextQuery.h
35 lines (27 loc) · 829 Bytes
/
TextQuery.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
#ifndef TEXTQUERY_H
#define TEXTQUERY_H
#include<iostream>
#include<fstream>
#include<memory>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<tuple>
class TextQuery;
typedef std::tuple<std::string, std::shared_ptr<std::set<std::vector<std::string>::size_type>>, std::shared_ptr<std::vector<std::string>>> QueryResult;
class TextQuery
{
public:
using line_no = std::vector<std::string>::size_type;
TextQuery(std::ifstream &);
QueryResult query(const std::string &) const;
TextQuery(const TextQuery & tq) = default;
TextQuery & operator=(const TextQuery & tq) = default;
~TextQuery() = default;
private:
std::shared_ptr<std::vector<std::string>> file;
std::map<std::string, std::shared_ptr<std::set<line_no>>> wm;
};
std::ostream & print(std::ostream & os, const QueryResult &qr);
#endif