File: IOConfig.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 (346 lines) | stat: -rw-r--r-- 9,806 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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
/*************************************************************************
* 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_IOCONFIG
#define HEADER_IOCONFIG

#include "Version.h"
#include <string>
#include <Poco/DOM/Element.h>

/*!
 * \brief Input/Output configuration for games/scenarii
 *
 * Contains information about XML names among others
 */
class IOConfig
{
    private:
        //! Name of the XML root element 
        std::string sRootName;
        //! Name of the XML plot element
        std::string sPlotName;
        //! Name of the XML properties element
        std::string sPropertiesName;
        //! Name of the XML image element
        std::string sImageName;
        //! Name of the XML property element
        std::string sPropertyName;
        //! Name of the XML character's short description attribute
        std::string sDescriptionName; 
        //! Flag of availability of image elements
        bool bHasImages;
        //! Flag of availability of the expanded state
        bool bHasExpanded;
        //! Version
        Version vVersion;
        //! Flag of validity of the configuration
        bool bValid;
        //! Flag of availability of metadata
        bool bHasMetadata;
        //! Flag of archive format
        bool bArchived; 
        //! Temporary directory
        std::string sTempDir;
    public:
        /*!
         * \brief Constructor
         * \param version Software version to be compatible with
         */
        IOConfig(const Version &version);
        /*!
         * \brief Getter for the name of the root element
         * \return Name of the root element
         */
        inline std::string rootName() const;
        /*!
         * \brief Setter for the name of the root element
         * \param rootName New name of the root element
         */
        inline void setRootName(const std::string &rootName);
        /*!
         * \brief Getter for the name of the plot element
         * \return Name of the plot element
         */
        inline std::string plotName() const;
        /*!
         * \brief Setter for the name of the plot element
         * \param plotName New name of the plot element
         */
        inline void setPlotName(const std::string &plotName);
        /*!
         * \brief Getter for the name of the properties element
         * \return Name of the properties element
         */
        inline std::string propertiesName() const;
        /*!
         * \brief Setter for the name of the properties element
         * \param propertiesName New name of the properties element
         */
        inline void setPropertiesName(const std::string &propertiesName);
        /*!
         * \brief Getter for the name of the image element
         * \return Name of the image element
         */
        inline std::string imageName() const;
        /*!
         * \brief Setter for the name of the image element
         * \param imageName New name of the image element
         */
        inline void setImageName(const std::string &imageName);
        /*!
         * \brief Getter for the name of the property element
         * \return Name of the property element
         */
        inline std::string propertyName() const;
        /*!
         * \brief Setter for the name of the property element
         * \param propertyName New name of the property element
         */
        inline void setPropertyName(const std::string &propertyName);
        /*!
         * \brief Getter for the flag of availability of image elements
         * \return Flag of availability of image elements
         */
        inline bool hasImages() const;
        /*!
         * \brief Setter for the flag of availability of image elements
         * \param hasImages New flag of availability of image elements
         */
        inline void setHasImages(bool hasImages);
        /*!
         * \brief Getter for the flag of availability of the expanded state
         * \return Flag of availability of the expanded state
         */
        inline bool hasExpanded() const;
        /*!
         * \brief Setter for the flag of availability of the expanded state
         * \param hasExpanded New flag of availability of the expanded state
         */
        inline void setHasExpanded(bool hasExpanded);
        /*!
         * \brief Getter for the version
         * \return Version of the file
         */
        inline Version version() const;
        /*!
         * \brief IOConfig detector
         * \param fileName File name of the XML file (extracted if needed from the game file)
         * \param root Root element of the corresonding XML tree
         * \param isArchived Indicates if the game file is an archive
         * \return IO configuration corresponding to the given file
         */
        static IOConfig detect(const std::string &fileName, const Poco::XML::Element *root, bool isArchived);
        /*!
         * \brief Getter for the flag of validity
         * \return Validity of the configuration
         */
        inline bool isValid() const;
        /*!
         * \brief Getter for the flag of availability of metadata
         * \return Flag of availability of metadata
         */
        inline bool hasMetadata() const;
        /*!
         * \brief Setter for the flag of availability of metadata
         * \param hadMetadata New flag of availability of metadata
         */
        inline void setHasMetadata(bool hadMetadata);
        /*!
         * \brief Getter for the flag of archive format
         * \return Flag of archive format
         */
        inline bool isArchived() const;
        /*!
         * \brief Setter for the flag of archive format
         * \param isArchived New flag of archive format
         */
        inline void setArchived(bool isArchived);
        /*!
         * \brief Getter for the temporary directory
         * \return Temporary directory
         */
        inline std::string temporaryDirectory() const;
        /*!
         * \brief Getter for the name of the short description attribute
         * \return Name of the short description attribute
         */
        inline std::string descriptionName() const;
        /*!
         * \brief Setter for the name of the short description attribute
         * \param descriptionName New name of the short description attribute
         */
        inline void setDescriptionName(const std::string &descriptionName);
};

std::string IOConfig::rootName() const
{
    return sRootName;
}

std::string IOConfig::plotName() const
{
    return sPlotName;
}

std::string IOConfig::propertiesName() const
{
    return sPropertiesName;
}

std::string IOConfig::imageName() const
{
    return sImageName;
}

Version IOConfig::version() const
{
    return vVersion;
}

std::string IOConfig::propertyName() const
{
    return sPropertyName;
}

bool IOConfig::hasImages() const
{
    return bHasImages;
}

bool IOConfig::hasExpanded() const
{
    return bHasExpanded;
}

bool IOConfig::isValid() const
{
    return bValid;
}

bool IOConfig::hasMetadata() const
{
    return bHasMetadata;
}

bool IOConfig::isArchived() const
{
    return bArchived;
}

void IOConfig::setRootName(const std::string &rootName)
{
    if (rootName != sRootName)
    {
        sRootName = rootName;
        bValid = false;
    }
}

void IOConfig::setPlotName(const std::string &plotName)
{
    if (plotName != sPlotName)
    {
        sPlotName = plotName;
        bValid = false;
    }
}

void IOConfig::setPropertiesName(const std::string &propertiesName)
{
    if (propertiesName != sPropertiesName)
    {
        sPropertiesName = propertiesName;
        bValid = false;
    }
}

void IOConfig::setPropertyName(const std::string &propertyName)
{
    if (propertyName != sPropertyName)
    {
        sPropertyName = propertyName;
        bValid = false;
    }
}

void IOConfig::setImageName(const std::string &imageName)
{
    if (imageName != sImageName)
    {
        sImageName = imageName;
        bValid = false;
    }
}

void IOConfig::setHasImages(bool hasImages)
{
    if (hasImages != bHasImages)
    {
        bHasImages = hasImages;
        bValid = false;
    }
}

void IOConfig::setHasExpanded(bool hasExpanded)
{
    if (hasExpanded != bHasExpanded)
    {
        bHasExpanded = hasExpanded;
        bValid = false;
    }
}

void IOConfig::setHasMetadata(bool hasMetadata)
{
    if (hasMetadata != bHasMetadata)
    {
        bHasMetadata = hasMetadata;
        bValid = false;
    }
}

void IOConfig::setArchived(bool isArchived)
{
    if (isArchived != bArchived)
    {
        bArchived = isArchived;
        bValid = false;
    }
}

std::string IOConfig::temporaryDirectory() const
{
    return sTempDir;
}

std::string IOConfig::descriptionName() const
{
    return sDescriptionName;
}

void IOConfig::setDescriptionName(const std::string &descriptionName)
{
    if (descriptionName != sDescriptionName)
    {
        sDescriptionName = descriptionName;
        bValid = false;
    }
}

#endif