File tree Expand file tree Collapse file tree 1 file changed +18
-16
lines changed Expand file tree Collapse file tree 1 file changed +18
-16
lines changed Original file line number Diff line number Diff line change 8
8
#include < cstdint>
9
9
10
10
enum DynamicType: int8_t {
11
- BOOLEAN_TYPE = 1 ,
12
- DOUBLE_TYPE = 2 ,
11
+ BOOLEAN = 1 ,
12
+ NUMBER = 2 ,
13
+ INT64 = 3 ,
14
+ UNDEFINED = 3 ,
13
15
};
14
16
15
17
class Dynamic {
16
18
public:
17
19
Dynamic (double value) {
18
- this ->d = value;
19
- this ->type = DynamicType::DOUBLE_TYPE ;
20
+ this ->number = value;
21
+ this ->type = DynamicType::NUMBER ;
20
22
}
21
23
22
24
Dynamic (bool value) {
23
- this ->b = value;
24
- this ->type = DynamicType::BOOLEAN_TYPE ;
25
+ this ->boolean = value;
26
+ this ->type = DynamicType::BOOLEAN ;
25
27
}
26
28
27
- void setValue ( double value) {
28
- this ->d = value;
29
- this ->type = DynamicType::DOUBLE_TYPE ;
30
- };
29
+ Dynamic ( int64_t value) {
30
+ this ->int64 = value;
31
+ this ->type = DynamicType::INT64 ;
32
+ }
31
33
32
- void setValue (bool value) {
33
- this ->b = value;
34
- this ->type = DynamicType::BOOLEAN_TYPE;
35
- };
34
+ Dynamic () {
35
+ this ->type = DynamicType::UNDEFINED;
36
+ }
36
37
private:
37
38
DynamicType type;
38
39
39
40
union {
40
- double d;
41
- bool b;
41
+ double number;
42
+ bool boolean;
43
+ int64_t int64;
42
44
};
43
45
};
44
46
You can’t perform that action at this time.
0 commit comments