forked from pezy/CppPrimer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
textquery.h
52 lines (40 loc) · 1.15 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
44
45
46
47
48
49
50
51
52
/***************************************************************************
* @file textquery.h
* @author Alan.W
* @date 30 DEC 2013
* @remark The TextQuery class using StrBlob
***************************************************************************/
//!
//! Exercise 12.32:
//! Rewrite the TextQuery and QueryResult classes to use a StrBlob instead of a
//! vector<string> to hold the input file.
// Relevant post on Stack Overflow:
// http://stackoverflow.com/questions/20823225/what-will-happen-if-a-user-defined-constructor-omits-ininitialization-for-data-m
//!
#ifndef TEXTQUERY_H
#define TEXTQUERY_H
#include "StrBlob.h"
#include <map>
#include <set>
#include <string>
#include <memory>
#include <fstream>
class QueryResult;
/**
* @brief The TextQuery class using StrBlob
*/
class TextQuery
{
public:
typedef StrBlob::size_type line_no;
//! constructor
TextQuery(std::ifstream& fin);
//! query operation
QueryResult query(const std::string&) const;
private:
//! data members
StrBlob file;
std::map<std::string,
std::shared_ptr<std::set<line_no>>> wordMap;
};
#endif // TEXTQUERY_H