-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb_parser.h
44 lines (34 loc) · 955 Bytes
/
db_parser.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
#ifndef DBPARSER_H
#define DBPARSER_H
#include <iostream>
#include <string>
#include <map>
#include "datastore.h"
#include "product.h"
#include "user.h"
#include "product_parser.h"
class DBParser {
public:
DBParser();
virtual ~DBParser();
void addProductParser(ProductParser* p);
bool parse(std::string db_filename, DataStore& ds);
protected:
enum PState { INIT, PRODUCTS, FIND_USERS, READ_USERS, FIND_REVIEWS, READ_REVIEWS, DONE };
Product* parseProduct(const std::string& category,
std::istream& is);
virtual User* parseUser(std::istream& is);
virtual Review* parseReview(std::istream& is,
std::string prodname);
virtual Review* makeReview(std::string& prodname,
std::string& username,
int& rating,
std::string& date,
std::string& review_text);
private:
int lineno_;
std::string errorMsg_;
bool error_;
std::map<std::string, ProductParser*> parsers_;
};
#endif