-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.h
38 lines (32 loc) · 1.04 KB
/
database.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
#ifndef DATABASE_H
#define DATABASE_H
#include <fstream>
#include <cstring>
#define STRSIZE 64
enum class FilterOption {genreFilter, actorFilter};
class DatabaseNode {
public:
char name[STRSIZE], genre[STRSIZE], mainActor[STRSIZE], rating;
size_t year;
DatabaseNode() { }
DatabaseNode(char *_name, size_t _year, char *_genre, char *_mainActor, char _rating);
DatabaseNode(std::istream &input);
DatabaseNode(DatabaseNode &other);
void write(std::ostream &output);
bool operator<(DatabaseNode &other) { return strcmp(name, other.name) < 0; }
};
class Database {
private:
std::fstream file;
size_t quantity;
char filename[STRSIZE];
public:
Database(char const *filename);
size_t update(DatabaseNode *&nodes);
void add(DatabaseNode newNode);
void remove(size_t index);
size_t filter(DatabaseNode *&nodes, char *filter, char margin = -1, FilterOption option = FilterOption::actorFilter);
size_t graphingData(size_t *&values, size_t minYear, size_t maxYear);
DatabaseNode leastPopular();
};
#endif