-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
30 lines (30 loc) · 720 Bytes
/
main.cpp
File metadata and controls
30 lines (30 loc) · 720 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
#include <iostream>
#include <stdexcept>
#include "Query.h"
#include "TextQuery.h"
#include "QueryResult.h"
using namespace std;
int main(int argc, char **argv)
{
ifstream infile(argv[1]);
if (!infile) { cerr << "No input file!" << endl; exit(1); }
TextQuery tq(infile);
tq.display_map();
while (true)
{
cout << "Enter search command, or q to quit:" << endl;
string line;
getline(cin, line);
if (line.empty() || line == "q") break;
shared_ptr<QueryBase> q;
try {
q = QueryBase::factory(line);
}
catch( const invalid_argument& e ) {
cout << e.what() << endl << endl;
continue;
}
print(cout, q->eval(tq)) << endl;
}
return(0);
}