1 |
|
|
/* |
2 |
|
|
* The ManaPlus Client |
3 |
|
|
* Copyright (C) 2010 The Mana Developers |
4 |
|
|
* Copyright (C) 2011-2019 The ManaPlus Developers |
5 |
|
|
* Copyright (C) 2019-2021 Andrei Karas |
6 |
|
|
* |
7 |
|
|
* This file is part of The ManaPlus Client. |
8 |
|
|
* |
9 |
|
|
* This program is free software; you can redistribute it and/or modify |
10 |
|
|
* it under the terms of the GNU General Public License as published by |
11 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
12 |
|
|
* any later version. |
13 |
|
|
* |
14 |
|
|
* This program is distributed in the hope that it will be useful, |
15 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 |
|
|
* GNU General Public License for more details. |
18 |
|
|
* |
19 |
|
|
* You should have received a copy of the GNU General Public License |
20 |
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
21 |
|
|
*/ |
22 |
|
|
|
23 |
|
|
#ifndef VARIABLEDATA_H |
24 |
|
|
#define VARIABLEDATA_H |
25 |
|
|
|
26 |
|
|
#include <string> |
27 |
|
|
|
28 |
|
|
#include "localconsts.h" |
29 |
|
|
|
30 |
|
|
class VariableData notfinal |
31 |
|
|
{ |
32 |
|
|
public: |
33 |
|
|
enum DataType |
34 |
|
|
{ |
35 |
|
|
DATA_NONE = 0, |
36 |
|
|
DATA_INT, |
37 |
|
|
DATA_STRING, |
38 |
|
|
DATA_FLOAT, |
39 |
|
|
DATA_BOOL |
40 |
|
|
}; |
41 |
|
|
|
42 |
|
|
VariableData() |
43 |
|
215726 |
{ } |
44 |
|
|
|
45 |
|
|
A_DELETE_COPY(VariableData) |
46 |
|
|
|
47 |
|
|
virtual ~VariableData() |
48 |
|
|
{} |
49 |
|
|
|
50 |
|
|
virtual int getType() const A_WARN_UNUSED = 0; |
51 |
|
|
}; |
52 |
|
|
|
53 |
|
55932 |
class IntData final : public VariableData |
54 |
|
|
{ |
55 |
|
|
public: |
56 |
|
55932 |
explicit IntData(const int value) : |
57 |
|
|
VariableData(), |
58 |
|
111864 |
mData(value) |
59 |
|
|
{ } |
60 |
|
|
|
61 |
|
|
A_DELETE_COPY(IntData) |
62 |
|
|
|
63 |
|
|
int getData() const noexcept2 A_WARN_UNUSED |
64 |
|
976 |
{ return mData; } |
65 |
|
|
|
66 |
|
976 |
int getType() const override final A_WARN_UNUSED |
67 |
|
976 |
{ return DATA_INT; } |
68 |
|
|
|
69 |
|
|
private: |
70 |
|
|
int mData; |
71 |
|
|
}; |
72 |
|
|
|
73 |
|
107870 |
class StringData final : public VariableData |
74 |
|
|
{ |
75 |
|
|
public: |
76 |
|
53935 |
explicit StringData(const std::string &value) : |
77 |
|
|
VariableData(), |
78 |
|
161805 |
mData(value) |
79 |
|
|
{ } |
80 |
|
|
|
81 |
|
|
A_DELETE_COPY(StringData) |
82 |
|
|
|
83 |
|
|
const std::string &getData() const noexcept2 A_WARN_UNUSED |
84 |
|
3842 |
{ return mData; } |
85 |
|
|
|
86 |
|
3844 |
int getType() const override final A_WARN_UNUSED |
87 |
|
3844 |
{ return DATA_STRING; } |
88 |
|
|
|
89 |
|
|
private: |
90 |
|
|
std::string mData; |
91 |
|
|
}; |
92 |
|
|
|
93 |
|
1318 |
class FloatData final : public VariableData |
94 |
|
|
{ |
95 |
|
|
public: |
96 |
|
1318 |
explicit FloatData(const double value) : |
97 |
|
|
VariableData(), |
98 |
|
2636 |
mData(value) |
99 |
|
|
{ } |
100 |
|
|
|
101 |
|
|
A_DELETE_COPY(FloatData) |
102 |
|
|
|
103 |
|
|
double getData() const noexcept2 A_WARN_UNUSED |
104 |
|
59 |
{ return mData; } |
105 |
|
|
|
106 |
|
59 |
int getType() const override final A_WARN_UNUSED |
107 |
|
59 |
{ return DATA_FLOAT; } |
108 |
|
|
|
109 |
|
|
private: |
110 |
|
|
double mData; |
111 |
|
|
}; |
112 |
|
|
|
113 |
|
104541 |
class BoolData final : public VariableData |
114 |
|
|
{ |
115 |
|
|
public: |
116 |
|
104541 |
explicit BoolData(const bool value) : |
117 |
|
|
VariableData(), |
118 |
|
209082 |
mData(value) |
119 |
|
|
{ } |
120 |
|
|
|
121 |
|
|
A_DELETE_COPY(BoolData) |
122 |
|
|
|
123 |
|
|
bool getData() const noexcept2 A_WARN_UNUSED |
124 |
|
2401 |
{ return mData; } |
125 |
|
|
|
126 |
|
2401 |
int getType() const override final A_WARN_UNUSED |
127 |
|
2401 |
{ return DATA_BOOL; } |
128 |
|
|
|
129 |
|
|
private: |
130 |
|
|
bool mData; |
131 |
|
|
}; |
132 |
|
|
|
133 |
|
|
#endif // VARIABLEDATA_H |