-
Notifications
You must be signed in to change notification settings - Fork 0
/
Post.h
40 lines (35 loc) · 1.14 KB
/
Post.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
#pragma once
#include "Comment.h"
#include "Vector.hpp"
#include "MyString.h"
#include "UtilityFunctions.h"
class Post
{
size_t id = 0;
MyString title;
Vector<Comment> comments;
static size_t postIdentificator;
public:
Post() = default;
Post(const MyString& title);
size_t getId()const;
size_t getCommentsSize()const;
const MyString& getTitle()const;
size_t getIdentificator()const;
const Vector<Comment>& getComments()const;
Vector<Comment>& getComments();
void showComments()const;
bool checkId(size_t id)const;
void addComments(Comment&& newComment);
void addReply(size_t id,SharedPointer<Comment>&& newReply);
void addUpvoteToComment(size_t id);
void addDownvoteToComment(size_t id);
void removeUpvoteFromComment(size_t id);
void removeDownvoteFromComment(size_t id);
int searchCommentById(size_t id)const;
void printPost()const;
friend std::ofstream& operator<<(std::ofstream& out, const Post& post);
friend std::ifstream& operator>>(std::ifstream& in, Post& post);
};
std::ofstream& operator<<(std::ofstream& out, const Post& post);
std::ifstream& operator>>(std::ifstream& in, Post& post);