-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.h
More file actions
94 lines (68 loc) · 3.88 KB
/
function.h
File metadata and controls
94 lines (68 loc) · 3.88 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#pragma once
#include <iostream>
#include <sstream>
#include <string>
#include <cctype>
#include <vector>
#include <fstream>
#include <iomanip>
#include <stdexcept>
#include "Media.h" //Base Class
#include "Movie.h"
#include "Book.h"
#include "Song.h"
using namespace std;
// Custom Exception Types Generated with ChatGPT prompt "Can you make a simple c++ custom exception class"
class yearError : public exception {
public:
yearError(const std::string& message) : message_(message) {}
const char* what() const noexcept override {
return message_.c_str();
}
private:
std::string message_;
};
class boolError : public exception {
public:
boolError(const std::string& message) : message_(message) {}
const char* what() const noexcept override {
return message_.c_str();
}
private:
std::string message_;
};
/* ================================================================================================
Functions in function.cpp
*/
int readMediaList(istream& i, ostream& o, vector<Media*>& m, vector<Movie>& movies, vector<Book>& books, vector<Song>& songs);
//PRE: input and error output file are opened and Media_List vector is empty
//POST Load Media_List vector with Media class objects and output any errors to error output file
void addNewMedia(istream& inCommands, ostream& out, ostream& outErr, vector<Media*>& m, vector<Movie>& movies, vector<Book>& books, vector<Song>& songs);
//PRE: mediaCommands.txt is opened and Media_List vector is fully loaded
//POST: Add new media objects into Media_List vector and print to error file any errors that occur
// All overload functions print media with a type (book, movie, song) with a certain sorting criteria like a certain rating or genre
void printMovieList(istream& in, ostream& out, ostream& outErr, vector<Movie>& m);
void printMovieList(istream& in, ostream& out, ostream& outErr, vector<Movie>& m, string str_sortCriteria);
//PRE: Media_List vector is fully loaded and output files are opened to write to
//POST: Outputs a list of all movies in the output file and prints any errors to error output file
void printBookList(istream& in, ostream& out, ostream& outErr, vector<Book>& b);
void printBookList(istream& in, ostream& out, ostream& outErr, vector<Book>& b, string str_sortCriteria);
//PRE: Media_List vector is fully loaded and output files are opened to write to
//POST: Outputs a list of all books in the output file and prints any errors to error output file
void printSongList(istream& in, ostream& out, ostream& outErr, vector<Song>& s);
void printSongList(istream& in, ostream& out, ostream& outErr, vector<Song>& s, string str_sortCriteria);
//PRE: Media_List vector is fully loaded and output files are opened to write to
//POST: Outputs a list of all songs in the output file and prints any errors to error output file
void printAllMedia(istream& in, ostream& out, ostream& outErr, vector<Media*>& m);
void printAllMedia(istream& in, ostream& out, ostream& outErr, vector<Media*>& m, string str_sortCriteria);
//PRE: Media_List vector is fully loaded and output files are opened to write to
//POST: Outputs a list of all media in the output file and prints any errors to error output file
void printTotals(ostream& out);
void listMovieStars(istream& inCommands, ostream& out, ostream& outErr, vector<Movie>& m, string str_sortCriteria);
void findStarInMovie(istream& inCommands, ostream& out, ostream& outErr, vector<Movie>& m, string str_sortCriteria);
/* ============================================================================
Functions in function2.cpp
*/
void readMovieinput(string& input_line, ostream& o, vector<Media*>& m, vector<Movie>& movies);
void readBookinput(string& input_line, ostream& o, vector<Media*>& m, vector<Book>& books);
void readSonginput(string& input_line, ostream& o, vector<Media*>& m, vector<Song>& songs);