ManaPlus
src
variabledata.h
Go to the documentation of this file.
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
{ }
44
45
A_DELETE_COPY
(
VariableData
)
46
47
virtual ~
VariableData
()
48
{}
49
50
virtual
int
getType
() const
A_WARN_UNUSED
= 0;
51
};
52
53
class
IntData
final
: public
VariableData
54
{
55
public
:
56
explicit
IntData
(
const
int
value) :
57
VariableData
(),
58
mData
(value)
59
{ }
60
61
A_DELETE_COPY
(
IntData
)
62
63
int getData() const
noexcept2
A_WARN_UNUSED
64
{
return
mData
; }
65
66
int
getType
() const
override
final
A_WARN_UNUSED
67
{
return
DATA_INT
; }
68
69
private
:
70
int
mData
;
71
};
72
73
class
StringData
final
:
public
VariableData
74
{
75
public
:
76
explicit
StringData
(
const
std::string &value) :
77
VariableData
(),
78
mData
(value)
79
{ }
80
81
A_DELETE_COPY
(
StringData
)
82
83
const
std
::
string
&getData() const
noexcept2
A_WARN_UNUSED
84
{
return
mData
; }
85
86
int
getType
() const
override
final
A_WARN_UNUSED
87
{
return
DATA_STRING
; }
88
89
private
:
90
std::string
mData
;
91
};
92
93
class
FloatData
final
:
public
VariableData
94
{
95
public
:
96
explicit
FloatData
(
const
double
value) :
97
VariableData
(),
98
mData
(value)
99
{ }
100
101
A_DELETE_COPY
(
FloatData
)
102
103
double getData() const
noexcept2
A_WARN_UNUSED
104
{
return
mData
; }
105
106
int
getType
() const
override
final
A_WARN_UNUSED
107
{
return
DATA_FLOAT
; }
108
109
private
:
110
double
mData
;
111
};
112
113
class
BoolData
final
:
public
VariableData
114
{
115
public
:
116
explicit
BoolData
(
const
bool
value) :
117
VariableData
(),
118
mData
(value)
119
{ }
120
121
A_DELETE_COPY
(
BoolData
)
122
123
bool getData() const
noexcept2
A_WARN_UNUSED
124
{
return
mData
; }
125
126
int
getType
() const
override
final
A_WARN_UNUSED
127
{
return
DATA_BOOL
; }
128
129
private
:
130
bool
mData
;
131
};
132
133
#endif
// VARIABLEDATA_H
BoolData
Definition:
variabledata.h:114
BoolData::BoolData
BoolData(const bool value)
Definition:
variabledata.h:116
BoolData::mData
bool mData
Definition:
variabledata.h:130
BoolData::getType
int getType() const
Definition:
variabledata.h:126
FloatData
Definition:
variabledata.h:94
FloatData::FloatData
FloatData(const double value)
Definition:
variabledata.h:96
FloatData::getType
int getType() const
Definition:
variabledata.h:106
FloatData::mData
double mData
Definition:
variabledata.h:110
IntData
Definition:
variabledata.h:54
IntData::getType
int getType() const
Definition:
variabledata.h:66
IntData::mData
int mData
Definition:
variabledata.h:70
IntData::IntData
IntData(const int value)
Definition:
variabledata.h:56
StringData
Definition:
variabledata.h:74
StringData::mData
std::string mData
Definition:
variabledata.h:90
StringData::StringData
StringData(const std::string &value)
Definition:
variabledata.h:76
StringData::getType
int getType() const
Definition:
variabledata.h:86
VariableData
Definition:
variabledata.h:31
VariableData::getType
virtual int getType() const =0
VariableData::VariableData
VariableData()
Definition:
variabledata.h:42
VariableData::DataType
DataType
Definition:
variabledata.h:34
VariableData::DATA_BOOL
@ DATA_BOOL
Definition:
variabledata.h:39
VariableData::DATA_STRING
@ DATA_STRING
Definition:
variabledata.h:37
VariableData::DATA_NONE
@ DATA_NONE
Definition:
variabledata.h:35
VariableData::DATA_FLOAT
@ DATA_FLOAT
Definition:
variabledata.h:38
VariableData::DATA_INT
@ DATA_INT
Definition:
variabledata.h:36
localconsts.h
override
#define override
Definition:
localconsts.h:47
A_WARN_UNUSED
#define A_WARN_UNUSED
Definition:
localconsts.h:161
notfinal
#define notfinal
Definition:
localconsts.h:261
noexcept2
#define noexcept2
Definition:
localconsts.h:50
final
#define final
Definition:
localconsts.h:46
A_DELETE_COPY
#define A_DELETE_COPY(func)
Definition:
localconsts.h:53
PlayerInfo::mData
PlayerInfoBackend mData
Definition:
playerinfo.cpp:56
std
Definition:
mseprimitives.h:398
Generated on Wed Mar 17 2021 19:19:10 for ManaPlus by
1.9.1