/
SaveInfo.cpp
181 lines (162 loc) · 2.9 KB
/
SaveInfo.cpp
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#include "SaveInfo.h"
#include "GameSave.h"
#include "Client.h"
SaveInfo::SaveInfo(SaveInfo & save):
id(save.id),
date(save.date),
votesUp(save.votesUp),
votesDown(save.votesDown),
vote(save.vote),
Favourite(false),
Comments(save.Comments),
Views(save.Views),
Version(save.Version),
userName(save.userName),
name(save.name),
Description(save.Description),
Published(save.Published),
gameSave(NULL)
{
std::list<std::string> tagsSorted = save.tags;
tagsSorted.sort();
tags = tagsSorted;
if (save.gameSave)
gameSave = new GameSave(*save.gameSave);
}
SaveInfo::SaveInfo(int _id, int _date, int _votesUp, int _votesDown, std::string _userName, std::string _name):
id(_id),
date(_date),
votesUp(_votesUp),
votesDown(_votesDown),
vote(0),
Favourite(false),
Comments(0),
Views(0),
Version(0),
userName(_userName),
name(_name),
Description(""),
Published(false),
tags(),
gameSave(NULL)
{
}
SaveInfo::SaveInfo(int _id, int date_, int _votesUp, int _votesDown, int _vote, std::string _userName, std::string _name, std::string description_, bool published_, std::list<std::string> tags_):
id(_id),
date(date_),
votesUp(_votesUp),
votesDown(_votesDown),
vote(_vote),
Favourite(false),
Comments(0),
Views(0),
Version(0),
userName(_userName),
name(_name),
Description(description_),
Published(published_),
tags(),
gameSave(NULL)
{
std::list<std::string> tagsSorted = tags_;
tagsSorted.sort();
tags=tagsSorted;
}
SaveInfo::~SaveInfo()
{
if(gameSave)
{
delete gameSave;
}
}
void SaveInfo::SetName(std::string name)
{
this->name = name;
}
std::string SaveInfo::GetName()
{
return name;
}
void SaveInfo::SetDescription(std::string description)
{
Description = description;
}
std::string SaveInfo::GetDescription()
{
return Description;
}
void SaveInfo::SetPublished(bool published)
{
Published = published;
}
bool SaveInfo::GetPublished()
{
return Published;
}
void SaveInfo::SetVote(int vote)
{
this->vote = vote;
}
int SaveInfo::GetVote()
{
return vote;
}
void SaveInfo::SetUserName(std::string userName)
{
this->userName = userName;
}
std::string SaveInfo::GetUserName()
{
return userName;
}
void SaveInfo::SetID(int id)
{
this->id = id;
}
int SaveInfo::GetID()
{
return id;
}
void SaveInfo::SetVotesUp(int votesUp)
{
this->votesUp = votesUp;
}
int SaveInfo::GetVotesUp()
{
return votesUp;
}
void SaveInfo::SetVotesDown(int votesDown)
{
this->votesDown = votesDown;
}
int SaveInfo::GetVotesDown()
{
return votesDown;
}
void SaveInfo::SetVersion(int version)
{
this->Version = version;
}
int SaveInfo::GetVersion()
{
return Version;
}
void SaveInfo::SetTags(std::list<std::string> tags)
{
std::list<std::string> tagsSorted = tags;
tagsSorted.sort();
this->tags=tagsSorted;
}
std::list<std::string> SaveInfo::GetTags()
{
return tags;
}
GameSave * SaveInfo::GetGameSave()
{
return gameSave;
}
void SaveInfo::SetGameSave(GameSave * saveGame)
{
delete gameSave;
gameSave = saveGame;
}