-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPost.cpp
More file actions
60 lines (48 loc) · 1.17 KB
/
Post.cpp
File metadata and controls
60 lines (48 loc) · 1.17 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 "Post.h"
Post::Post(const MyString& title, size_t id, size_t createrId, size_t topicId)
: title(title), SecondaryDataObject(id, createrId), topicId(topicId)
{
}
const MyString& Post::getTitle() const
{
return this->title;
}
void Post::setTitle(const MyString& title)
{
this->title = title;
}
void Post::setTopicId(size_t id)
{
topicId = id;
}
size_t Post::getTopicId() const
{
return topicId;
}
void Post::serialize(std::ostream& os) const
{
os << getId() << std::endl
<< getTopicId() << std::endl
<< getCreaterId() << std::endl
<< getTitle() << std::endl << std::endl;
}
void Post::deserialize(std::istream& is)
{
char emptyLine = is.get();
//std::cout << emptyLine;
size_t id;
is >> id;
setId(id);
emptyLine = is.get();
size_t topicId;
is >> topicId;
setTopicId(topicId);
emptyLine = is.get();
size_t createrId;
is >> createrId;
setCreaterId(createrId);
emptyLine = is.get();
is >> title;
//std::cout << "Record with id: " << getId() << ' '
// << getCreaterId() << ' ' << getTitle() << std::endl;
}