-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReaction.cpp
More file actions
60 lines (47 loc) · 1.26 KB
/
Copy pathReaction.cpp
File metadata and controls
60 lines (47 loc) · 1.26 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
#include "Reaction.h"
Reaction::Reaction(size_t id, size_t createrId, size_t commentId, bool isUpvote)
: SecondaryDataObject(id, createrId), commentId(commentId), isUpvote(isUpvote)
{}
void Reaction::setCommentId(size_t commentId)
{
this->commentId = commentId;
}
size_t Reaction::getCommentId() const
{
return commentId;
}
void Reaction::setReactionType(bool isReactionUpvote)
{
this->isUpvote = isReactionUpvote;
}
bool Reaction::getIsUpvote() const
{
return isUpvote;
}
void Reaction::deserialize(std::istream& is)
{
char emptyLine = is.get();
//std::cout << emptyLine;
size_t id;
is >> id;
setId(id);
size_t commentId;
is >> commentId;
setCommentId(commentId);
size_t createrId;
is >> createrId;
setCreaterId(createrId);
bool isUpvote;
is >> isUpvote;
setReactionType(isUpvote);
/* std::cout << "Record with id: " << getId() << ' '
<< getCommentId() << ' ' << getCreaterId() << ' '
<< "Is upvote: " << getIsUpvote() << std::endl; */
}
void Reaction::serialize(std::ostream& os) const
{
os << getId() << ' '
<< getCommentId() << ' '
<< getCreaterId() << ' '
<< getIsUpvote() << std::endl;
}