-
Notifications
You must be signed in to change notification settings - Fork 0
/
basicType.h
70 lines (62 loc) · 1.54 KB
/
basicType.h
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
#pragma once
#include <string>
#include "manageable.h"
#include <QObject>
#include <QtScript/QScriptValue>
using namespace std;
enum TYPE{FLOAT,INT,STR,BOOL,_NULL,PLACEHOLDER};
static long long getCurrentTime()
{
return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
}
class Basic : public manageable
{
public:
virtual TYPE getType() { return _NULL; } //直接创建的basic对象视为null
virtual ~Basic() {}
virtual string toStr() { return "Null"; }
};
class Placeholder : public Basic
{
public:
virtual TYPE getType() override { return PLACEHOLDER; }
virtual string toStr() override { return "Placeholder"; }
};
class Int : public Basic
{
public:
int val;
virtual TYPE getType() override {return INT;}
Int(int val) : val(val) {}
virtual string toStr() override { return to_string(val); }
};
class Float : public Basic
{
public:
float val;
virtual TYPE getType() override {return FLOAT;}
Float(float val) : val(val) {}
virtual string toStr() override { return to_string(val); }
};
class Str : public Basic
{
public:
string val;
virtual TYPE getType() override {return STR;}
Str(string val) : val(val) {}
virtual string toStr() override { return val; }
};
class Bool : public Basic
{
public:
bool val;
virtual TYPE getType() override {return BOOL;}
Bool(bool val) : val(val) {}
virtual string toStr() override
{
if(val)
return "true";
else
return "false";
}
};