Repository navigation
Expand file tree
/
Copy pathSimpleType.hpp
More file actions
71 lines (59 loc) · 2.5 KB
/
Copy pathSimpleType.hpp
File metadata and controls
71 lines (59 loc) · 2.5 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
/**
* @file SimpleType.hpp
* @author huangjian
* @date 2022-02-21
* @version 1.0
* @copyright huangjian
**/
#ifndef SIMPLETYPE_HPP
#define SIMPLETYPE_HPP
#include "Type.hpp"
class SimpleType;
typedef RefObject<SimpleType> SimpleTypeRef;
/// @brief The SimpleType class 简单类型类,用于表示一个简单类型,如int, char, float,或者自定义类型等,
/// 内置类型可通过BuiltinType获取,如BuiltinType::Int, BuiltinType::Float等,
/// 其他类型可通过simpleType_获取,如simpleType_("MyType")
class SimpleType : public Type {
public:
static const uint16_t ID;
public:
static SimpleTypeRef create(const String &codeType, TypeRef parent = nullptr);
public:
SimpleType(const String &codeType, TypeRef parent = nullptr);
public:
virtual int typeWrite(Dequque &leftSide, Dequque &rightSide) override;
virtual uint16_t id() const override {
return SimpleType::ID;
}
private:
String m_type;
};
/// @brief 创建一个简单类型,使用方式为simpleType_("MyType"),生成一个MyType的类型
/// @param codeType 类型名称
/// @param parent 父类,一般不需要使用,若不为空,则会生成 " 父类 当前类 " 的类型,例如父类是一个某类型指针,然后在其基础上添加其他的引用等
/// @return
inline static SimpleTypeRef simpleType_(const String &codeType, TypeRef parent = nullptr) {
return SimpleType::create(codeType, parent);
}
/// @brief 创建一个简单类型,使用方式为type_("MyType"),生成一个MyType的类型
/// @param codeType 类型名称
/// @param parent 父类,一般不需要使用,若不为空,则会生成 " 父类 当前类 " 的类型,例如父类是一个某类型指针,然后在其基础上添加其他的引用等
/// @return
inline static SimpleTypeRef type_(const String &codeType, TypeRef parent = nullptr) {
return SimpleType::create(codeType, parent);
}
/// @brief 内置类型类,用于表示一些内置类型,如int, char, float等
class CODEC_GENERATOR_API BuiltinType {
public:
static SimpleTypeRef Int;
static SimpleTypeRef UInt;
static SimpleTypeRef Float;
static SimpleTypeRef Double;
static SimpleTypeRef Char;
static SimpleTypeRef Long;
static SimpleTypeRef ULong;
static SimpleTypeRef Short;
static SimpleTypeRef UShort;
static SimpleTypeRef Void;
};
#endif // SIMPLETYPE_HPP