-
Notifications
You must be signed in to change notification settings - Fork 14
/
TextQuery.h
44 lines (37 loc) · 1.02 KB
/
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
35
36
37
38
39
40
41
42
43
#ifndef TEXTQUERY_H
#define TEXTQUERY_H
#include<iostream>
#include<fstream>
#include<memory>
#include<set>
#include<map>
#include<string>
#include "StrVec.h"
class QueryResult;
class TextQuery
{
public:
using line_no = size_t;
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<StrVec> file;
std::map<std::string, std::shared_ptr<std::set<line_no>>> wm;
};
class QueryResult
{
friend std::ostream & print(std::ostream &, const QueryResult &);
public:
QueryResult(std::string s, std::shared_ptr<std::set<TextQuery::line_no>> p, std::shared_ptr<StrVec> f) : sought(s), lines(p), file(f) { }
std::set<TextQuery::line_no>::iterator begin();
std::set<TextQuery::line_no>::iterator end();
std::shared_ptr<StrVec> get_file();
private:
std::string sought;
std::shared_ptr<std::set<TextQuery::line_no>> lines;
std::shared_ptr<StrVec> file;
};
#endif