forked from Mooophy/Cpp-Primer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex13_42_TextQuery.h
More file actions
36 lines (30 loc) · 846 Bytes
/
Copy pathex13_42_TextQuery.h
File metadata and controls
36 lines (30 loc) · 846 Bytes
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
#ifndef CP5_TEXTQUERY_H_
#define CP5_TEXTQUERY_H_
#include <string>
#include <memory>
#include <iostream>
#include <fstream>
#include <map>
#include <set>
#include "ex13_42_StrVec.h"
class QueryResult;
class TextQuery {
public:
TextQuery(std::ifstream &);
QueryResult query(const std::string&) const;
private:
std::shared_ptr<StrVec> input;
std::map<std::string, std::shared_ptr<std::set<size_t>>> result;
};
class QueryResult {
public:
friend std::ostream& print(std::ostream &, const QueryResult&);
public:
QueryResult(const std::string &s, std::shared_ptr<std::set<size_t>> set, std::shared_ptr<StrVec> v) : word(s), nos(set), input(v) { }
private:
std::string word;
std::shared_ptr<std::set<size_t>> nos;
std::shared_ptr<StrVec> input;
};
std::ostream& print(std::ostream &, const QueryResult&);
#endif