-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathcpp_var_type.h
More file actions
96 lines (81 loc) · 2.14 KB
/
Copy pathcpp_var_type.h
File metadata and controls
96 lines (81 loc) · 2.14 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
// Copyright (C) 2022 Satya Das and CppParser contributors
// SPDX-License-Identifier: MIT
#ifndef DEE52E89_9A5C_4A01_B51A_D0D4786BC7EF
#define DEE52E89_9A5C_4A01_B51A_D0D4786BC7EF
#include "cppast/cpp_enum.h"
#include "cppast/cpp_function.h"
#include "cppast/cpp_type_modifier.h"
#include "cppast/cpp_var_type.h"
#include "cppast/cppconst.h"
#include <string>
namespace cppast {
class CppFunctionPointer;
class CppEnum;
/**
* @brief Models variable type in C++.
*
* It can be used to define a variable or function parameter.
* @see CppVar.
*/
class CppVarType : public CppAttributeSpecifierSequenceContainer
{
public:
CppVarType(std::string baseType, CppTypeModifier modifier);
CppVarType(CppCompound* compound, CppTypeModifier modifier);
CppVarType(CppFunctionPointer* fptr, CppTypeModifier modifier);
CppVarType(CppEnum* enumObj, CppTypeModifier modifier);
CppVarType(const CppVarType& varType);
const std::string& baseType() const
{
return baseType_;
}
void baseType(std::string baseTypeArg)
{
baseType_ = std::move(baseTypeArg);
}
const CppEntity* compound() const
{
return compound_.get();
}
std::uint32_t typeAttr() const
{
return typeAttr_;
}
void typeAttr(std::uint32_t attr)
{
typeAttr_ = attr;
}
void addAttr(std::uint32_t attr)
{
if ((attr & CppIdentifierAttrib::CONST) == 0)
typeAttr_ |= attr;
else
typeModifier_.constBits_ |= 1;
}
const CppTypeModifier& typeModifier() const
{
return typeModifier_;
}
CppTypeModifier& typeModifier()
{
return typeModifier_;
}
void parameterPack(bool paramPack)
{
paramPack_ = paramPack;
}
bool parameterPack() const
{
return paramPack_;
}
private:
CppVarType(std::string baseType, std::uint32_t typeAttr, CppTypeModifier modifier);
private:
std::string baseType_; // This is the basic data type of var e.g. for 'const int*& pi' base-type is int.
std::unique_ptr<CppEntity> compound_;
CppTypeModifier typeModifier_;
std::uint32_t typeAttr_ {0};
bool paramPack_ {false};
};
} // namespace cppast
#endif /* DEE52E89_9A5C_4A01_B51A_D0D4786BC7EF */