File: Metadata.h

package info (click to toggle)
gm-assistant 1.2.4-1.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,116 kB
  • sloc: cpp: 7,281; makefile: 3
file content (276 lines) | stat: -rw-r--r-- 7,217 bytes parent folder | download | duplicates (4)
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
/*************************************************************************
* Copyright © 2013-2020 Vincent Prat & Simon Nicolas
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*************************************************************************/

#ifndef HEADER_METADATA
#define HEADER_METADATA

#include <string>
#include <Poco/DOM/Document.h>
#include <Poco/DOM/Element.h>

/*!
 * \brief Class encapsulating metadata for games
 */
class Metadata
{
    public:
        class Date
        {
            public:
                /*!
                 * \brief Default constructor
                 *
                 * Initialize the date to today
                 */
                Date();
                /*!
                 * \brief Full constructor
                 * \param day Day of the month
                 * \param month Month of the year
                 * \param year Year
                 */
                Date(int day, int month, int year);
                /*!
                 * \brief Constructor from a string
                 * \param date Date of the form dd/mm/yyyy
                 */
                Date(const std::string &date);
                /*!
                 * \brief Getter for the day
                 * \return Day of the month
                 */
                inline int day() const;
                /*!
                 * \brief Getter for the month
                 * \return Month of the year
                 */
                inline int month() const;
                /*!
                 * \brief Getter for the year
                 * \return Year
                 */
                inline int year() const;
                /*!
                 * \brief Comparison operator
                 * \param date Date to compare with
                 * \return True if both are different, false otherwise
                 */
                bool operator!=(const Date &date) const;
            private:
                //! Day
                int iDay;
                //! Month
                int iMonth;
                //! Year
                int iYear;
        };
        //! Default constructor
        Metadata();
        /*!
         * \brief Getter for the title
         * \return Title of the game
         */
        inline std::string title() const;
        /*!
         * \brief Setter for the title
         * \param title New title
         */
        inline void setTitle(const std::string &title);
        /*!
         * \brief Getter for the author
         * \return Author of the game
         */
        inline std::string author() const;
        /*!
         * \brief Setter for the author
         * \param author New author
         */
        inline void setAuthor(const std::string &author);
        /*!
         * \brief Getter for the creation date
         * \return Creation date of the game
         */
        inline Date creationDate() const;
        /*!
         * \brief Setter for the creation date
         * \param creationDate New creation date
         */
        inline void setCreationDate(const Date &creationDate);
        /*!
         * \brief Getter for the description
         * \return Description of the game
         */
        inline std::string description() const;
        /*!
         * \brief Setter for the description
         * \param description New description
         */
        inline void setDescription(const std::string &description);
        /*!
         * \brief Getter for the role-playing game
         * \return Role-playing game
         */
        inline std::string rpg() const;
        /*!
         * \brief Setter for the role-playing game
         * \param rpg New role-playing game
         */
        inline void setRpg(const std::string &rpg); 
        /*!
         * \brief Getter for the players
         * \return Players
         */
        inline std::string players() const;
        /*!
         * \brief Setter for the players
         * \param players New players
         */
        inline void setPlayers(const std::string &players);
        /*!
         * \brief Getter for the game date
         * \return Game date
         */
        inline Date gameDate() const;
        /*!
         * \brief Setter for the game date
         * \param gameDate New game date
         */
        inline void setGameDate(const Date &gameDate);
        /*!
         * \brief XML loader
         * \param root Root of the XML subtree
         */
        void fromXML(const Poco::XML::Element *root);
        /*!
         * \brief XML saver
         * \param root Root of the XML subtree
         */
        void toXML(Poco::XML::Element *root) const;
        /*!
         * \brief Comparison operator
         * \param metadata Metadata to compare with
         * \return True if both are different, false otherwise
         */
        bool operator!=(const Metadata &metadata) const;
    private:
        //! Title of the game
        std::string sTitle;
        //! Author of the game
        std::string sAuthor;
        //! Creation date
        Date dCreation;
        //! Description
        std::string sDescription;
        //! Role-playing game
        std::string sRpg;
        //! Players
        std::string sPlayers;
        //! Game date
        Date dGame;
};

// inline Metadata::Date methods

int Metadata::Date::day() const
{
    return iDay;
}

int Metadata::Date::month() const
{
    return iMonth;
}

int Metadata::Date::year() const
{
    return iYear;
}

// inline Metadata methods

std::string Metadata::title() const
{
    return sTitle;
}

void Metadata::setTitle(const std::string &title)
{
    sTitle = title;
}

std::string Metadata::author() const
{
    return sAuthor;
}

void Metadata::setAuthor(const std::string &author)
{
    sAuthor = author;
}

Metadata::Date Metadata::creationDate() const
{
    return dCreation;
}

void Metadata::setCreationDate(const Date &creationDate)
{
    dCreation = creationDate;
}

std::string Metadata::description() const
{
    return sDescription;
}

void Metadata::setDescription(const std::string &description)
{
    sDescription = description;
}

std::string Metadata::rpg() const
{
    return sRpg;
}

void Metadata::setRpg(const std::string &rpg)
{
    sRpg = rpg;
}

std::string Metadata::players() const
{
    return sPlayers;
}

void Metadata::setPlayers(const std::string &players)
{
    sPlayers = players;
}

Metadata::Date Metadata::gameDate() const
{
    return dGame;
}

void Metadata::setGameDate(const Date &gameDate)
{
    dGame = gameDate;
}

#endif