-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMovieData.cpp
More file actions
50 lines (46 loc) · 1.76 KB
/
MovieData.cpp
File metadata and controls
50 lines (46 loc) · 1.76 KB
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
#include "MovieData.h"
MovieData::MovieData(std::ifstream &movie_file, std::set<std::string> &title_all,
std::set<std::string>&year_all, std::set<std::string>&runtime_all,
std::set<std::list<std::string> > &Genre_all, std::set<std::list<std::string> > &Actor_all,
std::set<std::list<std::string> > &Role_all) {
std::string str;
int tmpint;
movie_file >> title >> year >> runtime;
title_all.insert(title);
year_all.insert(year);
runtime_all.insert(runtime);
movie_file >> tmpint;
for (int i = 0; i < tmpint; i++) {
movie_file >> str;
GenreList.push_back(str);
}
movie_file >> tmpint;
for (int i = 0; i < tmpint; i++) {
movie_file >> str;
ActorList.push_back(str);
}
movie_file >> tmpint;
for (int i = 0; i < tmpint; i++) {
movie_file >> str;
RoleList.push_back(str);
}
Genre_all.insert(GenreList);
Actor_all.insert(ActorList);
Role_all.insert(RoleList);
}
// called by ds_hashset::print()
void MovieData::print(std::map<std::string, std::string> &actornamelist) {
std::cout << title << std::endl << year << std::endl << runtime << std::endl
<< GenreList.size();
for (std::list<std::string>::iterator iter = GenreList.begin();
iter != GenreList.end(); iter++) {
std::cout << ' ' << *iter;
}
std::cout << std::endl << ActorList.size();
std::list<std::string>::iterator iter2 = RoleList.begin();
std::list<std::string>::iterator iter = ActorList.begin();
for (; iter != ActorList.end(); iter++, iter2++) {
std::cout << ' ' << actornamelist[*iter] << " (" << *iter2 << ')';
}
std::cout << std::endl;
}