Repository navigation
Expand file tree
/
Copy pathTypeModifier.hpp
More file actions
96 lines (78 loc) · 2.38 KB
/
Copy pathTypeModifier.hpp
File metadata and controls
96 lines (78 loc) · 2.38 KB
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
/**
* @file TypeModifier.hpp
* @author huangjian
* @date 2022-02-21
* @version 1.0
* @copyright huangjian
**/
#ifndef TYPEMODIFIER_HPP
#define TYPEMODIFIER_HPP
#include "Type.hpp"
class TypeModifier;
class ConstType;
class StaticType;
typedef RefObject<TypeModifier> TypeModifierRef;
typedef RefObject<ConstType> ConstTypeRef;
typedef RefObject<StaticType> StaticTypeRef;
/**
* @brief The TypeModifier class 类型修饰符,用于表示类型的修饰符,如const, static等
*/
class TypeModifier : public Type {
public:
static const uint16_t ID;
public:
static TypeModifierRef create(const String &modifier, bool header, TypeRef parent = nullptr);
public:
TypeModifier(const String &modifier, bool header, TypeRef parent = nullptr);
public:
virtual int typeWrite(Dequque &leftSide, Dequque &rightSide) override;
virtual uint16_t id() const override {
return TypeModifier::ID;
}
private:
String m_modifier;
bool m_header;
};
/**
* @brief The ConstType class 常量类型修饰符,用于表示const类型修饰符,可通过const_(父类型进行添加)
*/
class ConstType : public TypeModifier {
public:
static const uint16_t ID;
public:
static ConstTypeRef create(TypeRef parent = nullptr);
public:
ConstType(TypeRef parent = nullptr);
public:
virtual uint16_t id() const override {
return ID;
}
};
/**
* @brief The StaticType class 静态类型修饰符,用于表示static类型修饰符,可通过static_(父类型进行添加)
*/
class StaticType : public TypeModifier {
public:
static const uint16_t ID;
public:
static StaticTypeRef create(TypeRef parent = nullptr);
public:
StaticType(TypeRef parent = nullptr);
public:
virtual uint16_t id() const override {
return ID;
}
};
/// @brief 创建一个const修饰类型,修饰传入的父类型
/// @param parent
/// @return 返回一个const修饰后的类型
inline static ConstTypeRef const_(TypeRef parent = nullptr) {
return ConstType::create(parent);
}
/// @brief 创建一个static修饰的类型,修饰传入的父类型
/// @param parent
/// @return 返回一个static修饰后的类型
inline static StaticTypeRef static_(TypeRef parent = nullptr) {
return StaticType::create(parent);
}
#endif // TYPEMODIFIER_HPP