-
Notifications
You must be signed in to change notification settings - Fork 0
/
MovieDatabase.h
58 lines (48 loc) · 1.58 KB
/
MovieDatabase.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
53
54
55
56
57
58
#ifndef MOVIEDATABASE_INCLUDED
#define MOVIEDATABASE_INCLUDED
#include <string>
#include <vector>
#include "treemm.h"
class Movie;
class MovieDatabase
{
public:
MovieDatabase();
bool load(const std::string& filename);
Movie* get_movie_from_id(const std::string& id) const;
std::vector<Movie*> get_movies_with_director(const std::string& director) const;
std::vector<Movie*> get_movies_with_actor(const std::string& actor) const;
std::vector<Movie*> get_movies_with_genre(const std::string& genre) const;
private:
TreeMultimap<std::string, Movie> m_movieID;
TreeMultimap<std::string, Movie> m_movie_Directors;
TreeMultimap<std::string, Movie> m_movie_Actors;
TreeMultimap<std::string, Movie> m_movie_Genres;
void splitStringByCommas(std::vector<std::string>& movie_info, std::string line)
{
std::string info = "";
for(int i = 0; i < line.size(); i++)
{
if(line[i] != ',')
{
info += line[i];
}
else
{
movie_info.push_back(info);
info = "";
}
}
movie_info.push_back(info);
}
std::string makeLower(const std::string &s) const
{
std::string lower = "";
for(int i = 0; i < s.size(); i++)
{
lower += tolower(s[i]);
}
return lower;
}
};
#endif // MOVIEDATABASE_INCLUDED